PHP Accelerators
PHP Accelerators/Cachers will boost the performance of your PHP applications, by caching the compiled form of php scripts to avoid the overhead of parsing and compiling the code every time the page is loaded. A PHP accelerator typically reduces server load and increases the speed of your PHP code by 1-10 times. Normally you will install these in the form of a php extension.
This list contains all the php accelerator solutions available at this time, with a short description and some personal notes. When choosing a php accelerator for your site, you should evaluate:
- evaluate the speed improvement. Normally any php application will gain at least 100% in speed only by installing any php accelerator, but you should do your own benchmark to see if it is useful or not.
- look for any problems caused by this. Your application might break or crash randomly after installing a php accelerator. The current solutions look pretty stable, but still this might happen. Enough with the introduction… here we go (in alphabetic order…):
1. APC (Alternative PHP Cache) - http://pecl.php.net/package/APC
“APC is a free, open, and robust framework for caching and optimizing PHP intermediate code.”
Latest stable version: 3.0.12p2 (2006-09-05)
Download link: http://pecl.php.net/package/APC
Official installation help: inside the source
MyOpinion: recommended:
- stable
- works with all PHP versions including PHP5.1
- actively maintained
2. eAccelerator - http://eaccelerator.net/
“eAccelerator was born in December 2004 as a fork of the Turck MMCache project. Turck MMCache was created by Dmitry Stogov and much of the eAccelerator code is still based on his work. eAccelerator also contains a PHP encoder and loader. The latest release, 0.9.5, supports PHP 4 and all PHP 5 releases including 5.2. In older releases, the encoder will only work with PHP versions from the 4.x.x branch. eAccelerator will not work with any other versions of PHP.”
Latest stable version: 0.9.5 (2006-10-11)
Download link: http://bart.eaccelerator.net/source/0.9.5/
Official installation help: http://eaccelerator.net/wiki/InstallFromSource
MyOpinion: recommended:
- the latest version 0.9.5 works fine with PHP5.1
- actively maintained
- very good performance
3. XCache - http://trac.lighttpd.net/xcache/
“XCache is a fast, stable PHP opcode cacher that has been tested and is now running on production servers under high load. It is tested (on linux) and supported on all of the latest PHP cvs branches such as PHP_4_3 PHP_4_4 PHP_5_0 PHP_5_1 PHP_5_2 HEAD(6.x). ThreadSafe/Windows is also supported. It overcomes a lot of problems that has been with other competing opcachers such as being able to be used with new PHP versions.”
Latest stable version: 1.0.3-rc1 (2006-10-11)
Download link: http://210.51.190.228/pub/XCache/rc/1.0.3-rc1/
Official installation help: http://trac.lighttpd.net/xcache/wiki/InstallFromSource
MyOpinion: looks very interesting
- new kid on the block developed by mOo who is also a developer of Lighttpd.
- actively maintained (different releases stable/unstable/devel)
- many interesting features
- developed to overcome some of the limitations of the existing solutions at that time.
Others (commercial/discontinued, etc):
Zend Optimizer - http://www.zend.com/products/zend_optimizer
MyOpinion: closed source, not really an optimizer (normally you will not see a real performance improvement from this)… useful only for the encoder if needed by some commercial scripts.
Zend Platform - http://www.zend.com/products/zend_platform
MyOpinion: commercial product; more than an optimizer that has features that serious developers might find useful.
ionCube PHP Accelerator (PHPA) - http://www.php-accelerator.co.uk/
MyOpinion: discontinued, closed source.
Turck MMCache - http://turck-mmcache.sourceforge.net/index_old.html
MyOpinion: this was a great product and many peoples still use it even though it is now discontinued. The natural upgrade for newer versions of php is eAccelerator.
Conclusion: APC, eAccelerator and XCache are all great solutions that can speed up any php application. There are many benchmarks on the internet showing how one or the other is better, but I would suggest running your own tests and finding the one that fits best for your application.
From my experience their performance is very similar, and my personal favorite is eAccelerator, even though I have used APC for some projects also. At this time I am evaluating and testing XCache and the initial results look very good.
Keep in mind when you are installing a php accelerator that this is not the end of your php tunings and optimizations and you should look into optimizing the real application. The opcache is a nice addition that can quickly speed up your application but don’t forget about the application itself. You will be surprised that in real life the biggest improvements are done from the application and not by installing a php accelerator solution.