Turck MMCache

Last modified: May 4, 2009 - 03:08

mmcache development stopped years ago, and is now continued at the eaccelerator project. You should probably be using this instead of mmcache.

The Turck MMCache has been confirmed to work well with Drupal. Installation is quite simple, resulting in a quick and noticeable performance increase.

Overview:
According to the project's home page:

"Turck MMCache is a free open source PHP accelerator, optimizer, encoder and dynamic content cache for PHP. It increases performance of PHP scripts by caching them in compiled state, so that the overhead of compiling is almost completely eliminated. Also it uses some optimizations to speed up execution of PHP scripts. Turck MMCache typically reduces server load and increases the speed of your PHP code by 1-10 times."

Compatibility:
The Turck MMCache runs on Linux and Windows, working with Apache 1.3 and Apache 2.0, compatible with PHP 4.1 and later.

The following versions of MMCache have been tested successfully with Drupal 4.1+: 2.3.15, 2.3.23, 2.4.6.

Installation:
Step-by-step installation instructions can be found here. Once properly installed, you should immediately notice an improvement.

CPU Utilization:
The sar utility from the sysstat collection gathers system activity numbers over time. The following sar snapshot taken from a dedicated Drupal server shows how the installation of MMCache can help reduce system load on even a heavily-optimized web server (MMCache was installed around 12:00PM):

    11:00:00 AM       CPU     %user     %nice   %system     %idle
    11:10:00 AM       all      3.71      0.00      1.85     94.44
    11:20:00 AM       all      3.86      0.00      0.50     95.64
    11:30:00 AM       all      4.49      0.00      0.33     95.18
    11:40:00 AM       all      4.05      0.00      0.36     95.58
    11:50:00 AM       all      3.76      0.00      0.36     95.88
    12:00:00 PM       all      3.38      0.00      0.52     96.11
    12:10:00 PM       all      0.52      0.00      0.10     99.38
    12:20:00 PM       all      0.79      0.00      0.20     99.01
    12:30:00 PM       all      0.57      0.00      0.12     99.31
    12:40:00 PM       all      0.59      0.00      0.12     99.29
    12:50:00 PM       all      0.44      0.00      0.11     99.45

Troubleshooting:
An easy way to tell if MMCache is working properly after following the installation instructions is to see if temporary files are being created in '/tmp/mmcache', or wherever you told them to be written with the 'mmcache.cache_dir' directive. If no files are appearing, something is wrong.

First, be sure that PHP has properly loaded mmcache. Create a short script on your web browser called 'phpinfo.php' as follows:

     <?php
       phpinfo
();
    
?>

Load that file in your browser to find a wealth of useful information. Search for any occurances of the word 'MMCache'. If it's not there, then MMCache is not loaded. Double check your 'Configuration File (php.ini) Path' on that same page, and be sure that you modified the correct 'php.ini' file. Verify that you installed 'mmcache.so' into the directory specified by the 'extension_dir' directive. Also, try restarting your web browser to be sure the latest configuration changes have been made. Finally, be sure to look in your web server's error log to see if there are any hints there. (Note that the phpinfo() function call reveals a _lot_ of information about your system. For security reasons it is very unwise to make this information available to the general public. If you created 'phpinfo.php' in a public place, be sure to remove it when you're finished troubleshooting.)

Additional resources:

 
 

Drupal is a registered trademark of Dries Buytaert.