Knowledgebase
Drupal Memcache Configuration
Posted by Daniel Pooley on 10 November 2015 02:13 PM

This knowledge base article applies to the Umbrellar Low Density Shared Hosting plans.

What is Memcached?

Memcached (Mem-Cache-D) is a general-purpose distributed memory caching daemon. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read. This can greatly increase the speed of websites, such as Drupal that heavily utilise database resources.

Disambiguation: Memcached vs Memcache

Memcached is the name of the server-side daemon; memcache is the name of the PHP extension that adds the libraries that create the PHP functions for communication with the daemon there is also a PHP library called memcached, which also facilitates communication with the daemon. The memcached PHP extension is often see as the successor to the memcache extension as it implements more memcache functions and is actively under development. In the below configuration example, we will be utilising the memcached PHP extension.

How do I configure Drupal to use Memcached?

1. Login to your Drupal administrative interface (e.g. http://example.com/?q=admin)

2. Click on 'Modules' at the top then click the 'Install or update module' link.

3. Copy the following link into the 'Install from a URL' text box and click 'Install'

http://ftp.drupal.org/files/projects/memcache-7.x-1.5.zip
Note: At the time of writing this tutorial the latest version of the module is 7.x-1.5, newer versions can be found here: https://www.drupal.org/project/memcache

4. Enable the module by clicking on Modules at the top, then find the 'Memcache' and 'Memcache Admin' modules names and place a check in the box next to each, click the 'Save Configuration' button at the bottom.

5. Open the Drupal Configuration file in a text edit (sites/default/settings.php) and append the following to the end of the file

// Umbrellar Memcached Configuration
$conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';
$conf['lock_inc'] = 'sites/all/modules/memcache/memcache-lock.inc';
$conf['memcache_servers'] = array('/var/www/vhosts/example.com/memcached/example.com.sock' => 'default');

// Umbrellar Memcached Additional Configuratation
$conf['cache_default_class'] = 'MemCacheDrupal';
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
$conf['memcache_stampede_protection'] = TRUE;
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;

$conf['memcache_options'] = array(
  Memcached::OPT_COMPRESSION => FALSE,
);

Note: the example.com domain name is used in the above configuration; you will have to update this to your domain name.

Once the above steps have been completed your Drupal installation will be utilising Memcached and you should see an increase in performance.

 

(3 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).