You are here

memcache doesn't necessarily speed up your Drupal sites

Sites that show up quickly on a user's screen tend to keep the user's attention for longer and also rank better in Google. So when listening to the excellent Lullabot Podcast 80: Top 40 Drupal Modules Revisited I was caught by Drupal experts stating that Memcache would even speed up your site if it's not a high traffic site. It could off-load the database. I decided to give it a try on a relatively low traffic site of one of my clients. The site is already being served by nginx so the load times are already pretty good. When setting up the experimentation I was a bit confused by the thorough but chaotic instruction to set up memcache. I ran into a problem setting up PECL memcache:
$ sudo pecl install memcache
downloading memcache-2.2.5.tgz ...
Starting to download memcache-2.2.5.tgz (35,981 bytes)
..........done: 35,981 bytes
11 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
shtool at '/tmp/pear/temp/memcache/build/shtool' does not exist or is not executable.
Make sure that the file exists and is executable and then rerun this script.

ERROR: `phpize' failed
Since I run Debian I solved this by running apt-get install php5-memcache instead. I restarted php-fastcgi (needed for nginx) and added $conf['cache_inc'] ='sites/all/modules/memcache/'; to settings.php. Then I ran some tests in Hammerhead.  Not on the front page since there is an embedded Youtube video. I chose a page without any external elements. I was a bit confused at first, and ran several short tests. I forgot to log out and the memcache module was adding a lot of extra information in the bottom.  I thought that was the reason that my site was a lot slower with memcache than without it.  So I logged out and tried again:
count latest median avg
empty cache with memcache 4 1449 1449 1759
primed cache with memcache 4 1277 1186 1184
empty cache without memcache 4 1239 1283 1483
primed cache without memcache 4 1014 900 950
It could be that I'd have to tweak some memcache settings, or run longer tests, but I think these numbers are clear enough: memcache made my site slower instead of faster!