Increase Drupal Performance by using Memcache

When site starting to get bigger with thousands of users and millions of records in database and lots of traffic performance becomes a major issue. Drupal is very powerful tool but it requires some fine tuning. I have built sites with thousands of users and hundreds of modules. What is Mencache? Memcached is an in memory key value store in a form of very small chunks of arbitrary data i.e (strings, objects) from results of database calls, API calls, or page rendering. It is might look simple but it enormously powerful.

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

Following is a basic configuration (add this to the settings.php configuration)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* 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’;
There is a very brilliant mmemcache API module on drupal.org

About Sallah Ud Din Sarwar

I am a multi skilled Software Engineer with over 4 year’s industry experience in designing and developing Object oriented solutions in Multi layered & N-Tired. I have substantial success to my credit. I have consistently handled complex problems to the satisfaction of my clients by working in stressful situations. I enjoy learning and applying new technologies in a dynamic and forward thinking professional environment.

Check Also

Mastering object-oriented programming (OOP) Concepts: A Comprehensive Guide for C# Interviews

Enhance your C# interview preparation with this comprehensive guide on mastering object-oriented programming (OOP) concepts. Unlock essential OOP pillars, understand solid principles, and gain confidence for success.

Leave a Reply