Cache Drupal with Memcached

Memcached is a server caching system used by, for example, Facebook and Digg to boost performance. Memcached stores rendered Drupal pages in the RAM memory. All you need is good RAM. Memcached can work on multiple servers. To use Drupal with Memcached, have a look at the Memcache integration module.

 I really recommend using Memcached. You can use it to cache both anonymous and registered users. Or you could choose to cache only registered users, in case you are using Varnish or Boost modules for the anonymous frontend.

Recently, Acquia is offering hosted Memcache solutions.

Example settings.php configuration

Here is an example for 4 Memcached bins. This depends on your Memcache installation.

$conf = array(
  'cache_inc'           => './sites/all/modules/contrib/memcache/memcache.inc',
  'session_inc'         => './sites/all/modules/contrib/memcache/memcache-session.inc',
  'memcache_servers'    => array(
                            'localhost:11211' => 'default',
                            'localhost:11212' => 'page',
                            'localhost:11213' => 'views',
                            'localhost:11214' => 'other',
                          ),
  'memcache_bins'       => array(
                            'cache' => 'default',
                            'cache_content' => 'page',
                            'cache_page' => 'page',
                            'cache_views_data' => 'views',
                            'session' => 'other',
                            'users' => 'other'
                          ),
  'memcache_key_prefix' =>  'domain_com',
);

Advantages

  • Boosts site performance
  • Can cache both anonymous and registered users

Disadvantages

  • You need at least a VPS with some spare RAM
  • Does not work on shared hosting

References

Morningtime