Description:
This patch modifies Drupal core so it can be configured to send specified queries to a one or more MySQL replication slaves, helping to distribute the database load. This patch alone does not change where any queries are run.
An optional 'replication-slave.patch' utilizes the changes made in the first patch. It causes all temporary tables to be created on the slaves, sends all pager queries to the slaves, and sends some queries from node_load to the slaves.
To use, apply the patch, then edit settings.php and define $db_slave_url much like you define $db_url. Also like $db_url, $db_slave_url can define one or mutiple servers. The simplest configuration is as follows:
$db_url = 'mysqli://username:password@localhost/masterdatabasename';
$db_slave_url = 'mysqli://username:password@localhost/slavedatabasename';
If you would like to split the load between multiple slaves, you can make $db_slave_url an array. The patch will then randomly select one of the slaves each time the page loads. An example configuration with multiple slaves:
$db_url = 'mysqli://username:password@localhost/masterdatabasename';
$db_slave_url = array(
'mysqli://username:password@localhost/slave1databasename',
'mysqli://username:password@localhost/slave2databasename');
Finally, it is possible to teach Drupal about multiple named databases, where one is named 'default'. If you configured $db_url as an array to support multiple named databases, you also have to configure the named databases for $db_slave_url. The 'default' database is required:
$db_url = array(
'default' => 'mysqli://username:password@localhost/masterdatabasename',
);
$db_slave_url = array(
'default' => 'mysqli://username:password@localhost/slavedatabasename',
);
As before, it's also possible to define multiple slaves:
$db_url = array(
'default' => 'mysqli://username:password@localhost/masterdatabasename',
);
$db_slave_url = array(
'default' => array(
'mysqli://username:password@localhost/slave1databasename',
'mysqli://username:password@localhost/slave2databasename')
);
Patch:
http://tag1consulting.com/patches#replication
Status:
This patch has not been merged into any release of Drupal.
The original version of this patch was deployed on Drupal.org.
Patch source:
Drupal.org, original patch by David Strauss
https://infrastructure.drupal.org/node/12
