Testing Database Replication in the Drupal Pressflow Build (Updated June 26, 2010)

Pressflow, a high performance version of Drupal, supports master slave setups in its database include files. It adds two functions to support this feature: db_query_slave(), db_query_range_slave() and also modifies the pager_query() to send its queries to the slave database.

I assumed that along with Pressflow’s many performance improvements over the regular Drupal, that it would implement many slave-safe queries its core modules. Unfortunately, this is not the case: my Pressflow-backed site only sent 3.6% of its queries to the slave during my regular usage patterns test.

Update (June 26, 2010): I’ve looked through the core module tables for easy conversions to Pressflow slave queries. Most modules I looked at did not have straight forward code that could be converted to use db_query_slave() and db_query_range_slave(). It’s hard to know how that code will be executed over the entirety of the Drupal application, including the insert/update/delete heavy admin section of the site.

My first pass of changes altered the Menu, Path, and Path Alias Cache (included with Pressflow) modules. So far, I have not seen any adverse effects after running through most of the site’s front-end and admin functionality. Both logged in and logged out users now send about 30% of their queries to the slave during the course of my regular usage patterns test.