Jumat, 5 Maret 2021
  • Login
Harian Aceh Indonesia
  • HOME
  • IN-DEPTH
  • ACEH
  • NASIONAL
    • HUKUM
    • POLITIK
    • PERISTIWA
    • SOROTAN PUBLIK
  • DUNIA
  • EKONOMI
  • EDUKASI
    • LITERASI
  • ISLAM
  • OPINI
  • LIFESTYLE
  • LINGKUNGAN
  • SEJARAH
  • OTO
  • HIBURAN
  • SEPAK BOLA
    • BOLA NASIONAL
    • LIGA INGGRIS
    • LIGA ITALIA
    • LIGA SPANYOL
  • TEKNO
    • APLIKASI
    • GADGET
    • INTERNET
  • FOTO
  • VIDEO
  • CEK FAKTA
No Result
View All Result
Harian Aceh Indonesia
Jumat, 5 Maret 2021
No Result
View All Result
Harian Aceh Indonesia
No Result
View All Result

How to Scale WordPress with MySQL Replicas and HyperDB

Redaksi HAI Redaksi HAI
Selasa, 17/01/2017 - 06:44 WIB
HyperDB. Photo credited by WordPress.org

HyperDB. Photo credited by WordPress.org

Sebar ke FacebookSebar ke Twitter
Print Friendly, PDF & Email

Learn how to distribute requests to replica MySQL databases on WordPress using HyperDB.

Advantages of MySQL Replication

Typical WordPress sites are limited to the capacity of a single database to serve read and write requests. As a result, high traffic sites can experience latency as requests are fulfilled. MySQL replication rapidly copies content from the “master” database to one or more “replica” databases. This allows you to spread requests across multiple databases to improve site performance and load times.

About HyperDB

The HyperDB plugin replaces the standard wpdb class so that WordPress is able to write and read from additional database servers. The drop-in plugin supports database replication, failover, load balancing, and partitioning — all tools for scaling WordPress.

Keep in mind, HyperDB is a powerful tool with several tuning options based on database architecture and network topology. Before you implement a complex configuration, it’s best to see if a simpler configuration suits your needs.

Install and Configure HyperDB

Before you begin, a Customer Success Manager (CSM) must change your site service level to “Elite”. The platform will automatically configure and manage your master and replica databases.

Download the archive of HyperDB from the WordPress plugin repository and move the db.php file into the /wp-content directory. This is a drop-in plugin and does not require activation at any time.

BACAAN LAINNYA

Wordpress Multisite. FOTO/tolotratlt

How to Install and Set Up a WordPress Multisite

04/03/2021 - 00:38 WIB
Tuning MySQL For High Performance. IMAGE/Illustrasion

Get High Performance With Tuning These MySQL System Variables

15/02/2021 - 05:44 WIB
Cyberpanel dari Litespeed. FOTO/Net

How To Free Up Disk Space Usage 100% on CyberPanel

10/02/2021 - 00:30 WIB
MySQL and Mariadb. FOTO/Net

Tip and Trick To Disable Binary Logging in MariaDB and MySQL

18/07/2020 - 02:50 WIB

loading...

Next, configure the master/replica databases within db-config.php. This file should be stored within the same directory as the site’s wp-config.php file.

When the db.php database drop-in is deployed to production, WordPress will begin allocating MySQL database reads and writes based on the configuration details you’ve provided in db-config.php.

The following sample configurations can be used in place of the dp-config.php file provided within the plugin archive. These examples require no additional edits for sites running on Pantheon. For more advanced options, refer to the db-config.php file provided in the HyperDB plugin archive.

Split Reads Between Master and Replica

Split reads between the master and the replica, to simply distribute the load between two servers.

<?php
/**
 * Register the master server to HyperDB
 */
$wpdb->add_database( array(
        'host'     => DB_HOST,
        'user'     => DB_USER,
        'password' => DB_PASSWORD,
        'name'     => DB_NAME,
        'write'    => 1, // master server takes write queries
        'read'     => 1, // ... and read queries
) );
/**
 * Register replica database server if it's available in this environment
 */
if ( ! empty( $_ENV['REPLICA_DB_HOST'] ) ) {
        $wpdb->add_database(array(
                'host'     => $_ENV['REPLICA_DB_HOST'] . ':' . $_ENV['REPLICA_DB_PORT'],
                'user'     => $_ENV['REPLICA_DB_USER'],
                'password' => $_ENV['REPLICA_DB_PASSWORD'],
                'name'     => $_ENV['REPLICA_DB_NAME'],
                'write'    => 0, // replica doesn't take write queries
                'read'     => 1, // ... but it does take read queries
        ));
}
// That's it!

Pass Front-end Read Queries to Replica, WordPress Dashboard Reads and Writes to Master

Pass all front-end database read queries to the replica, leaving the master dedicated to WordPress dashboard reads and writes. This can better ensure WordPress dashboard availability during high front-end load.

<?php
/**
 * Use HyperDB to just use the replica for frontend reads.
 * Register the master server to HyperDB
 */
$wpdb->add_database( array(
        'host'     => DB_HOST,
        'user'     => DB_USER,
        'password' => DB_PASSWORD,
        'name'     => DB_NAME,
        'write'    => 1, // master server takes write queries
        'read'     => is_admin() || empty( $_ENV['REPLICA_DB_HOST'] ) ? 1 : 0, // ... but only takes read queries in the admin if the replica is available
) );
/**
 * Register replica database server if it's available in this environment
 */
if ( ! empty( $_ENV['REPLICA_DB_HOST'] ) && ! is_admin() ) {
        $wpdb->add_database(array(
                'host'     => $_ENV['REPLICA_DB_HOST'] . ':' . $_ENV['REPLICA_DB_PORT'],
                'user'     => $_ENV['REPLICA_DB_USER'],
                'password' => $_ENV['REPLICA_DB_PASSWORD'],
                'name'     => $_ENV['REPLICA_DB_NAME'],
                'write'    => 0, // replica doesn't take write queries
                'read'     => 1, // ... but it does take read queries
        ));
}
// That's it!

In this example, you’ll want some form of cache fallback if reads to the replica begin failing.

Page 1 of 2
12Selanjutnya
Tags: How To Scale WordPressHow-ToHyperDBMySQLMySQL Replicaswordpress
Share1Tweet1PinSend

Sebelumnya

Tuning MySQL, This is the Tip to Reduce the Memory Usage of MySQL

Selanjutnya

Produktivitas padi pola tanam hazton capai 11 ton/ha

BACAAN LAINNYA

Ilustrasi Serangan Siber

Sekolah Online di Inggris Berhenti Gara-Gara Serangan Siber

05/03/2021 - 17:47 WIB
Google Chrome

Google Chrome akan Rilis Pembaruan Tiap 4 Minggu

05/03/2021 - 15:57 WIB
Nintendo Switch Kuning Neon

Nintendo Perbarui Konsol Switch dengan Layar Lebih Besar

05/03/2021 - 11:51 WIB
SehatQ Bekerjasama dengan Rumah Sakit & Apotik Online

SehatQ Bekerjasama dengan Rumah Sakit & Apotik Online

05/03/2021 - 11:37 WIB
Jajaran Redmi Note 10.

Xiaomi Rilis Jajaran Redmi Note 10, Ini Spesifikasinya

05/03/2021 - 10:01 WIB
Sebuah ilustrasi foto menunjukkan logo aplikasi perpesanan media sosial Whatsapp.

Aplikasi Desktop WhatsApp Kini Miliki Fitur Video Call

04/03/2021 - 22:43 WIB
Lewat PP Postelsiar, Kemenkominfo bisa memerintahkan operator mengelola trafik OTT.

Pemerintah Dinilai Sudah Sangat Bagus Membuat PP Postelsiar

04/03/2021 - 22:25 WIB
Ponsel Pintar (ilustrasi)

Cara Menemukan Ponsel iPhone atau Android yang Hilang

04/03/2021 - 12:32 WIB
Instagram

Cara Donwload Video dari Instagram

04/03/2021 - 12:00 WIB
Ilustrasi: Lenovo

Lenovo Legion 2 Pro akan Miliki Sistem Pendingin Turbo Ganda

03/03/2021 - 21:08 WIB
Load More

TERPOPULER

  • Kepala Badan Reserse Kriminal Markas Besar Polri Komisaris Jenderal Agus Andrianto. FOTO/Net

    Bareskrim akan Cabut Status Tersangka 6 Arwah Laskar FPI

    69 shares
    Share 28 Tweet 17
  • Bertentangan dengan KUHP, Ahli Hukum Nilai Polisi Ngaco Tetapkan Mayat Laskar FPI jadi Tersangka

    21 shares
    Share 8 Tweet 5
  • Marzuki Alie Terciduk di Bandara Kualanamu, Mau Ikut KLB?

    9 shares
    Share 4 Tweet 2
  • Partai Demokrat Sumut Meluncur ke Arena KLB: Bubarkan, Tolak Moeldoko!

    8 shares
    Share 3 Tweet 2
  • Haruskah Baca Surah Ad-Dhuha saat Salat Dhuha?

    63 shares
    Share 26 Tweet 15
Loading...

PERISTIWA

Bikin Merinding, Air Berwarna Merah Darah Muncul dari Tanah di Sukoharjo

Bikin Merinding, Air Berwarna Merah Darah Muncul dari Tanah di Sukoharjo

05/03/2021

Dugaan Suap Ditjen Pajak, Bukti Kegagalan Sri Mulyani

Dugaan Suap Ditjen Pajak, Bukti Kegagalan Sri Mulyani

04/03/2021

Dari Rumah Nurdin Abdullah Dkk, KPK Amankan Rp 1,4 M Dan Ratusan Ribu Dolar

Dari Rumah Nurdin Abdullah Dkk, KPK Amankan Rp 1,4 M Dan Ratusan Ribu Dolar

04/03/2021

Kesal Ditagih Bon Tuak, Oknum Polisi Polres Binjai Letuskan Pistol

Kesal Ditagih Bon Tuak, Oknum Polisi Polres Binjai Letuskan Pistol

03/03/2021

KPK Sebut Ada Kasus Korupsi yang Kemungkinan Dihentikan Penyidikannya

KPK Sebut Ada Kasus Korupsi yang Kemungkinan Dihentikan Penyidikannya

03/03/2021

  • Tentang Kami
  • Kebijakan Privacy
  • Kode Etik Jurnalistik
  • Pedoman Media Siber
  • Pedoman Pemberitaan Ramah Anak
  • Hak Jawab Dan Koreksi Berita
  • Standar Perlindungan Profesi Wartawan
  • Ketentuan Khusus
  • Menulis di HAI
  • Sitemap
  • Cookie
Aplikasi Android Harian Aceh Indonesia

© 2014 - 2021 - PT. Harian Aceh Indonesia. Made with in Indonesia.

No Result
View All Result
  • HOME
  • IN-DEPTH
  • ACEH
  • NASIONAL
    • HUKUM
    • POLITIK
    • PERISTIWA
    • SOROTAN PUBLIK
  • INTERNASIONAL
  • EKONOMI
  • EDUKASI
    • LITERASI
  • LINGKUNGAN
  • ISLAM
  • OPINI
  • SEJARAH
  • LIFESTYLE
  • KOMUNITAS
  • HIBURAN
  • OLAHRAGA
  • SEPAKBOLA
    • BOLA NASIONAL
    • LIGA ITALIA
    • LIGA INGGRIS
    • LIGA SPANYOL
  • OTOMOTIF
  • TEKNOLOGI
    • APLIKASI
    • GADGET
    • INTERNET
  • FOTO
  • VIDEO
  • CEK FAKTA
  • LOWONGAN KERJA
  • Login

© 2014 - 2021 - PT. Harian Aceh Indonesia. Made with in Indonesia.

Welcome Back!

Login to your account below

Forgotten Password?

Create New Account!

Fill the forms below to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In