![]() |
Services | Software | Partners | Articles | Contact |
Configuring Drupal with multiple bins for memcachedIn a recent article, we explained how to build memcached from source and PHP memcache using PECL on Ubuntu Gutsy 7.10. This article is a followup on how to configure memcache for Drupal, and how multiple bins help with performance. Each bin in memcached correspond to one or more cache table in Drupal. To do this, we first setup a start script for memcache that would start each bin with the correct size. This would go into /usr/local/bin/memcache.sh: #!/bin/sh case "$1" in start) /usr/local/bin/memcached -d -u root -m 64 -p 11211 /usr/local/bin/memcached -d -u root -m 320 -p 11212 /usr/local/bin/memcached -d -u root -m 128 -p 11213 ;; stop) killall memcached ;; esac Then we need to change Drupal's settings.php to match that. You see that the page cache and filter cache each have their own bin, running on a separate instance of memcache. Everything else shares a "default" cache, which includes the menu cache and variables. $conf = array( 'cache_inc' => './sites/all/modules/memcache/memcache.inc', 'memcache_servers' => array( 'localhost:11211' => 'default', 'localhost:11212' => 'page', 'localhost:11213' => 'filter', ), 'memcache_bins' => array( 'cache' => 'default', 'cache_menu' => 'default', 'cache_page' => 'page', 'cache_filter' => 'filter', ), ); Here are some statistics for each bin, after running for three weeks.
This one is for the default
The following bin is "page", and it is used for the "cache_page" table.
The filter
The page bin is the one that has the worst hits/misses ratio. The other two are very good. By separating the bins, we get better performance. |


memcache bin size
How do you determine what is the correct size for a bin? Do you just look at how how mb the database table is?
How does it help?
How is it better to run 3 processes totaling 512Mb rather than 1 big process at 512Mb? I dont understand how the hit/miss ratio could effect performance...
Contention not memory
Memory size is not the issue here. Contention is.
When cached items are inserted/deleted independently for each bin, without being affected by what the other bins are doing (locking, flushing, ...etc.)
--
2bits -- Drupal consulting