Using memcache? You should be.

This blog post is more than 5 years old, so the content may be out of date.

Adding memcache to a Drupal site will massively increase the performance (x2 is not unusual).

Here's a basic configuration (add this to the settings.php configuration) - more to follow soon!

/**
 * Memcache configuration.
 */
define('MEMCACHE_PATH', 'sites/all/modules/contrib/memcache/memcache.inc');
 
// Include the base cache, because memcache extends the class provided in the base cache.
include_once('./includes/cache.inc');
// Include the memcache files.
include_once(MEMCACHE_PATH);
 
// Optionally configure a prefix; most sites won't need this.
# $conf['memcache_key_prefix'] = 'foo';
 
// Declare memcache as a potential backend.
$conf['cache_backends'][] = MEMCACHE_PATH;
 
// Set the default cache to use memcache.
$conf['cache_default_class'] = 'MemCacheDrupal';
 
// Form-cache must use non-volatile storage.
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

Comments

How would you compare this to Boost? I assume you would not run both modules side-by-side.

Boost basically writes static files to the file-system (and thanks to the Drupal .htaccess setup, the static files are served directly by Apache, not via Drupal).

Boost will increase the performance of serving cached pages at the expense of file-system space, and Boost is usually considered a limited substitute for a reverse-proxy, for environments where you can't run something like varnish (standard low-cost shared hosting, for example).

Memcache plugs into the Drupal cache architecture to replace the cache lookups in the DB with cache lookups in memcache (which is a quicker operation). It speeds up pretty much all Drupal operations, and serves a different purpose to Boost, so it's quite normal to run both side by side. Drupal with APC (a php op-code cache), memcache, and varnish all running is a fairly standard setup so multiple cache systems isn't too unusual.

Thanks, Marcus. That's great information.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <apache>, <bash>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.