Tuning your Memcached settings

The Memcache Admin Drupal module (included in the Memcache API and Integration project) provides statistics about how Memcached is behaving on your application. By analyzing these statistics, you can decide whether or not you need to allocate more memory to Memcached on your infrastructure.

To use the Memcache Admin module:

  1. Enable the Memcache Admin module in the Memcache API and Integration project. There is no need to enable the Memcache module. However, if you do enable it, you can receive notifications when you need to update the module.
  2. View the Memcache statistics on your Drupal application’s Administration > Reports > Memcache statistics page.

Review the Memcache statistics page to determine how the cache is behaving. This page reports the following:

  • Amount of memory the Memcached daemon is using.

  • Percentage of Memcached memory used compared to the total memory allocated to it.

  • Number of evictions since the last time the service was started or the stats were reset.

    Compare the ratio of evictions to total Memcache activity. If evictions are a high proportion of total Memcache activity, consider whether you should allocate more memory to Memcached. Bear in mind, however, that if you allocate more memory to Memcached on your infrastructure, you’ll have less memory for other infrastructure functions, including PHP. Proper memory allocation depends on your application configuration.

For more information, see this Knowledge Base article about monitoring and flushing Memcache using the nc command.

By default (with stampede protection enabled), when a thread encounters a locked cache entry, it waits five seconds, and then attempts to access the cache entry again. The Drupal Memcache module includes a memcache_stampede_wait_time variable that you can use to control the amount of time a thread waits before trying again, and a memcache_stampede_wait_limit variable to control how many attempts are made by a thread. You can also use configuration variables to disable stampede protection for specific cache bins or patterns of cache IDs. For more information, see the ignore settings in the module. If your application is experiencing many threads in a lock wait state, you may be able to improve performance by adjusting these settings.