I am setting a hit ratio of 55% on our memcache instance (v1.4.4) and am wondering what can be done to improve the hit ratio. We're in a multisite setup (30+ sites), with two load balanced web servers; there is an instance of memcached on each web server.

In the settings.php, I have:

$conf['memcache_servers'] = array(
         '' => 'default',
         '' => 'default',
$conf['memcache_bins'] = array('cache' => 'default');
$conf['memcache_key_prefix'] = $_SERVER['SERVER_NAME'];

I am looking at using bins to improve hit ratio, but have come across some suggestions that the latest memcache module does this already, but I am unsure as the instructions with the module contain directions on setting up bins.

If bins are they way to go, how do you determine what (table?) needs to have its own bin? These are the cache tables that I have in my sites:

cache_admin_menu (empty)
cache_block (empty)
cache_filter (empty)
cache_form (empty)
cache_image (empty)
cache_media_xml (empty)
cache_page (empty)
cache_path (empty)
cache_token (empty)
cache_update (empty)
cache_views_data (empty)
ctools_css_cache (empty)
ctools_object_cache (empty)

In addition to bins, what else can I be doing to improve memcached usage?

Many thanks!

  • 30 + sites ? Could you please share the Environment details , PHP mem and MySql max_allowed_packet , am also planning to launch lots of sub sites , already have 4 plan to have 10, but was unsure if drupal could handle it.
    – GoodSp33d
    Apr 9, 2012 at 13:40
  • @Kantu - I want to keep this thread about memcached with Drupal. If you post a new question, I'll be happy to weigh in ... or check out similar discussions here or on drupal.org.
    – KM.
    Apr 9, 2012 at 14:28
  • I just wanted to know your server configurations , as running 30 sub sites is very rare
    – GoodSp33d
    Apr 9, 2012 at 14:52
  • so which cache table we have to set to bin. using drupal 8 .Please help me Jun 23, 2020 at 16:59

1 Answer 1


After much research, here is what has helped our hit ratio and memcached usage:

  • Upgraded memcached to 1.4.10 (the latest version with performance improvements)
  • Enabled binary format and compression
  • Use the default for bins

Our memcached conf in settings.php looks something like this now:

$conf['memcache_bins'] = array('cache' => 'default');
$conf['memcache_options'] = array(
$conf['memcache_persistent'] = TRUE;
$conf['memcache_key_prefix'] = $_SERVER['SERVER_NAME'];

Biggest Gains

The biggest gain for us was enabling compression, even though the documentations states that it increases CPU cycles. We have 4 CPUs allocated to our VM, and have not noticed a difference. Time for memcached calls went from ~1250ms to ~150ms (obtained from NewRelic) for creating a piece of content (custom Article in our case).

Hit Ratio

Our hit ratio is now ~70% -- much better than 55% earlier, but not quiet the 90%+ that some have reported ... the quest continues (-:

Hopefully this helps someone else. If you come across other improvements or have corrections/suggestions, please post comments or answers.

Update -- Version of memcahe module

We went from version 1.0-beta4 to 1.0 and our hit ratio now is 87% . I had to restart memcached as hit ratio wasn't going past 70%. We have 64MB allocated to memcached at the moment, so this was not a big deal for us.

  • 1
    I would set the key prefix to something hardcoded and not depend on the given server name. For example if someone accesses your site with or without www. (which you might redirect or something, just an example), you will end up with a different key prefix for the cache. You will have to change the settings.php for each site, however.
    – Berdir
    Apr 9, 2012 at 21:35
  • 1
    Also, hit rate depends heavily on your sites.. if you have many explicit cache clears or if memcache is running full and has to throw out stuff regularly, youre hit rate will obviously drop.
    – Berdir
    Apr 9, 2012 at 21:36
  • Thanks for weighing in @Berdir. I've been checking the slabs and so far the server name as a key has not been an issue, but I can see where it could be. Evictions are low ~ 170 and have 25% (~17MB) room left in memcached. Is there a way to track down the cause of the 30% cache misses? Cache clears or something else ... ?
    – KM.
    Apr 10, 2012 at 13:59
  • Not easily. By the time the cache fails, you can't reproduce what happened with it. What you could try is log cache clear calls including a backtrace to see where they are coming from but not sure if that would help much.
    – Berdir
    Apr 10, 2012 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.