PHP Caching and Acceleration with XCache

December 20, 2006 by · 53 Comments 

Anyone who runs a dedicated server for web hosting will tell you that a great way to decrease the load on your server and decrease the page load time is to use a PHP Cache such as APC or eAccelerator. While the largest noticeable improvements are for those site that receive a lot of traffic or are under heavy load, any site, large or small can see benefit from a PHP cache. That said, in addition to the two caches mentioned above, a new player has recently entered the market: XCache.

I first started using APC about 2 years ago when the load on one of my servers was high enough that it was affecting load times and was costing me user traffic. I chose APC over eAccelerator because it was a bit easier to install (at the time) and because APC had a reputation for being a bit faster than eAccelerator. Shortly there after I noticed my httpd processes segfaulting and a bit of research also showed that APC had a bit of a record for instability under heavy load. With that in mind, I took the slight performance hit and installed eAccelerator (which is still way faster than using nothing at all).

Up until today, I was still using eAccelerator on all of my servers. However, a post on the forums prompted me to give XCache, the new PHP accelerator from the maker of lighttpd, a try. I've got to say, while I've only been using it for about 6 hours at this point, it blows eAccelerator out of the water, especially once you enable multiple caches (which benefits SMP systems).

If you're interested in some benchmarks of XCache, eAccelerator, APC, etc. then checkout the Five Opcode Cache Comparison on PHP on Fire.

The install is relatively simple, even from source, but the included config file doesn't actually do anything unless you make changes. As such, I've decided to put together a simple src.rpm for easily building XCache for your PHP server. I've tested the src.rpm with my PHP 5.1.6 and 5.2.0 tutorials, as well as the stock 4.3.9 install for CentOS 4.

The src.rpm will build an RPM package that includes the Cacher module. A default cache size of 32MB will be used and the number of caches will automatically be set to the number of processors on the build system (which is why I'm providing a src.rpm instead of an rpm). In addition, I've set the management console to be copied to "/var/www/html" in a folder called "xcache" (you will, however, have to set a password in on your own). In any case, the link to the source package is below, let me know how it works out if you try it.

Update (2/23/2007): The src.rpm below has been updated to take advantage of the patch at

Update (7/3/2007): The src.rpm below has been updated to use the 1.2.1 sources.

Update (9/24/2009): Package deleted, use the yum repository instead.

Digg this story


53 Responses to “PHP Caching and Acceleration with XCache”
  1. alan says:

    awesome! thanks much!

  2. Devilfish says:

    Hi folks,

    Excellent read so far...

    I have a problem which I was hoping to resolve. XCache is caching var data but not php data, the php list is empty.

    Running PHP 5.2.14 and XCache 1.3.1.

    Configured mod_fcgid as I was getting tons of clog counts and that seems to have fixed that but still no php data caching.

    Thanks for any advice! 🙂

  3. Wil says:

    Just updated to php5.3 somewhat reluctantly due to software requirements. Would love to use your xcache, but seems your repo is not yet thinking in terms of php53-xcache yet? I'm getting conflicts on php-xcache naturally due to php-common vs php53-common

    any ideas? i know this article is old, but couldn't find anything new and relevant in your search.

This site is no longer updated. If you have a need for RHEL/CentOS LAMP Stack updates outside the normal channels, I recommend ART.