Update: We later conducted tests that include XCache and published them in our article on benchmarking Drupal with PHP op-code caches: APC, eAccelerator and XCache compared.
In an earlier article on PHP op-code caches and accelerators, we stated that empirical observations show that APC feels faster compared to eAccelerator.
We decided to run some benchmarks to validate this observation, and come out with some hard conclusions.
Drupal
So, we used Drupal 5.1, using a checkout of the repository as of March 5, 2007, as well as a HEAD checkout, which includes some menu system improvements by Karoly Negyesi (still work in progress).
All the core modules were enabled, but otherwise, it was a default install.
Hardware
The test was done on an AMD 64 3000+ test server with 1GB of RAM, 7200 RPM SATA disk.
System Software
We used Ubuntu Edgy 6.10, Apache 2.0.55, MySQL 5.0.24, and PHP 5.1.6.
APC
APC is installed via pecl, version 3.0.13, with default parameters.
eAccelerator
eAccelerator is 0.9.5 installed from source using the following commands:
phpize ./configure --enable-eaccelerator=shared make make install
The configuration parameters are as follows:
zend_extension = "/usr/lib/php5/20051025/eaccelerator.so" eaccelerator.shm_size = 0 eaccelerator.cache_dir = "/var/cache/eaccelerator" eaccelerator.enable = 1 eaccelerator.optimizer = 1 eaccelerator.check_mtime = 1 eaccelerator.shm_max = 0 eaccelerator.shm_ttl = 0 eaccelerator.shm_prune_period = 0 eaccelerator.shm_only = 0 eaccelerator.compress = 1 eaccelerator.compress_level = 7
Tests performed
The test was an ab2 run with 1000 requests for each configuration, using this command:
ab2 -n1000 http://head.example.com/
ab2 -n1000 http://5.example.com/
Results
The results are summarized in this table. Attached to this article you can find a spreadsheet (ODS format) with the raw data and calculations.
PHP | with APC | % over PHP | with eAccelerator | % over PHP | eA vs. APC | |
Drupal 5 | ||||||
Total seconds | 183.49 | 37.16 | 493.85% | 32.64 | 562.16% | 113.83% |
Requests/second | 4.45 | 26.91 | 604.72% | 30.64 | 688.54% | 113.86% |
millisecs per request | 183.49 | 37.16 | 493.86% | 32.64 | 562.15% | 113.83% |
HEAD | ||||||
Total seconds | 175.62 | 33.21 | 528.83% | 29.18 | 601.85% | 113.81% |
Requests/second | 5.69 | 30.11 | 529.17% | 34.26 | 602.11% | 113.78% |
millisecs per request | 175.62 | 33.21 | 528.83% | 29.19 | 601.71% | 113.78% |
Conclusion
On the test setup, both APC and eAccelerator show marked improvement over plain PHP. eAccelerator consistently faster by 13% over APC.
Other tests, not included in this benchmark, show that eAccelerator saves about 5MB per Apache process over APC, so there are other benefits. See the results for memory here.
Future tasks
We would like to benchmark Xcache against the above tests to see how it compares.
Comments
Visitor (not verified)
thanks!
Tue, 2007/06/19 - 08:24Thanks for the hard work on this study. I have wondered how effective eAccelerator really is for dymanic sites like Drupal. After reviewing the study, I have compiled it and installed it on my test server.
Visitor (not verified)
Drupal is complex system
Wed, 2008/03/26 - 06:50Drupal is complex system with many scripts includes. Try to set PHP variables:
and you can get performance boost by 10%-50%.
Khalid
Thanks
Wed, 2008/03/26 - 09:23Thanks for the tip.
Did you check to see if this has an effect when the server has an op-code cache (e.g. APC), vs. without an op-code cache?
If you are using an op-code cache, I would think that these parameters do not matter at all, and would have no effect.
On the other hand, on shared hosts where you don't have an op-code cache, these may provide some help.
--
2bits -- Drupal and Backdrop CMS consulting
anjjriit (not verified)
Serious awesome tip
Fri, 2012/10/05 - 15:01wonderfull...
just folow your post.
simple tip with awesome output.
Thanks alot
You are my Hero.
Visitor (not verified)
Thank you! I went with
Sat, 2008/04/19 - 01:46Thank you! I went with eAccelerator - it's easier to install than APC. This just confirms my choice. There are just too many PHP thingamajigs - it's hard for a novice like me to know which one to pick.
Visitor (not verified)
Thank you very much for such an interesting article
Thu, 2008/09/11 - 01:59Thank you very much for such an interesting article
Visitor (not verified)
Concurrency
Sat, 2008/09/20 - 10:41I see the benchmark only uses 1000 requests and not providing multiple concurrency levels, which is a more typical usage. I would test with "-c" from 5 to 20.
Visitor (not verified)
comparison between eAccelerator and apc
Wed, 2009/03/11 - 10:56Very interesting post.
I tried eAccelerator (I followed these instructions: http://www.valent-blog.eu/en/2009/02/18/eaccelerator/) and apc. eAccelerator is the fastest opcache but I need to compile it and this is a security problem (I have Debian Etch before and now I am testing Lenny), so we must install complilation softwares and then remove them.
Apc is a little slower then eAccelerator but no build tools are required.
I did not try Xcache, maybe in future.
Compliments, I bookmark your post.
Khalid
Another comparison
Wed, 2009/03/11 - 11:01Here is another comparison that compares all of the three free ones.
benchmarking Drupal with PHP op-code caches: APC eAccelerator and XCache compared.
I still use, and recommend, APC because it is the most stable and stays up to date with PHP releases.
Visitor (not verified)
If you disable compression
Mon, 2009/08/17 - 10:13If you disable compression for eAccelerator, you will get even better results. There is no need for compression these days: memory and disks are cheap. Just give 128M to eAccelerator in SHM, that's it.
Pages