Improving the Performance of Zend Cache

We just upgraded to a new version of concrete5, and were noticing a disturbing drop in performance. This new version of concrete5 uses several more libraries from the widely used Zend Framework, and we thought their addition was the culprit. The libraries? Zend Locale and Zend Cache. These libraries provide some great functionality, but Zend's libraries can require more memory than home-grown solutions. We assumed this was the case.

Looking into the processes on our server, we discovered that our httpd threads were running with very high CPU usage. It wasn't out of the ordinary for an average httpd thread to hit 80-100% usage. MySQL usage wasn't terribly high. Unfortunately, the problem wasn't easily reproduced. Certain pages loaded quickly at certain times. At other times they lagged for an eternity.

However, I found the answer when digging into the Zend Cache internals. It turns out that Zend Cache helpfully includes an option for garbage collection and periodic cache cleaning.


According to Zend, this option "tune(s) the automatic cleaning process (garbage collector): 0 means no automatic cache cleaning, 1 means systematic cache cleaning and x > 1 means automatic random cleaning 1 times in x write operations."

Sadly, this default setting was wreaking havoc with our highly trafficked server. So, I disabled it, with the following line of code in our config/site.php:

define('CACHE_FRONTEND_OPTIONS', serialize(array('automatic_cleaning_factor' => 0)));

The result? Average httpd thread has dropped from 50-100% down to 6-7%. I would encourage anyone running the default Zehd file cache adapter to check out this option. The improvement in speed has been dramatic.

Loading Conversation