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.
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.
The test was done on an AMD 64 3000+ test server with 1GB of RAM, 7200 RPM SATA disk.
We used Ubuntu Edgy 6.10, Apache 2.0.55, MySQL 5.0.24, and PHP 5.1.6.
APC is installed via pecl, version 3.0.13, with default parameters.
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
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/
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|
|millisecs per request||183.49||37.16||493.86%||32.64||562.15%||113.83%|
|millisecs per request||175.62||33.21||528.83%||29.19||601.71%||113.78%|
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.
We would like to benchmark Xcache against the above tests to see how it compares.