I tested several PHP accelerators with lighttpd on an Ubuntu Server, x86_64 architecture.
A PHP accelerator is an extension designed to boost the performance of software applications written using the PHP programming language. Most PHP accelerators work by caching the compiled bytecode of PHP scripts to avoid the overhead of parsing and compiling source code on each request (some or all of which may never even be executed).
OK, so I have read all the hype, where’s the Beef ? How do these PHP accelerators work with lighttpd ?
I ran these benchmarks on a LAN to reduce the variables introduced when benchmarking oer teh internet.
Lighttpd 1.4.19 (with fastcgi)
Zend Optimizer 3.3.3
XCache 1.2.2 (cache size = 16 m)
Document Path: /index.php
Document Length: 9168 bytes
Benchmark ab ab is available in Ubuntu in the “apache2-utils” package.
ab -n 100 -c 10 http://server/index.php
Since these accelerators cache php, the ab command was run twice, and the results are for the second instance.
APC and xcache gave the best performance and were very close.
lighttpd + fastcgi (Baseline)
Requests / sec : 6.61 [#/sec]
Time / request : 151.214 [ms]
Transfer rate : 63.52 [Kbytes/sec]
RAM Use : 250 Mb
Requests / sec : 24.77 [#/sec]
Time / request : 40.364 [ms]
Transfer rate : 237.94 [Kbytes/sec]
RAM Use : 371 Mb
APC + Zend Incompatible
Requests / sec : 6.56 [#/sec]
Time / request :152.444 [ms]
Transfer rate : 63.00 [Kbytes/sec]
RAM Use : 1261 Mb
eaccelerator + Zend
Requests / sec : 6.42 [#/sec]
Time / request : 155.698 [ms]
Transfer rate : 61.69 [Kbytes/sec]
RAM Use : 1275 Mb
xcache (cache 16 Mb)
Requests / sec : 24.77 [#/sec]
Time / request : 40.370 [ms]
Transfer rate : 237.91 [Kbytes/sec]
RAM Use : 363 Mb
xcache + Zend
Requests / sec : 22.36 [#/sec]
Time / request : 44.722 [ms]
Transfer rate : 214.76 [Kbytes/sec]
RAM Use : 360 Mb
Requests / sec : 6.40 [#/sec]
Time / request : 156.345 [ms]
Transfer rate : 61.43 [Kbytes/sec]
RAM Use : 1320 Mb
Summary of benchmarks
APC and xcache were very similar and gave the best performance.
eAccelerator did not add to the performance of lighttpd.
Zend actually reduced the performance, both alone and when used with eAccelerator or xcache (APC is incompatible with Zend Optimizer).
Both APC and xcache had a smaller RAM “footprint” then eAccelerator or Zend.
These results show the importance of running your own benchmarks.
“Real World Testing”
In testing a server over the internet, there was not a big difference between eAccelerator and xcache (APC was not tested). This should not be a surprise in the the limiting factor is not with PHP Accelerators, but rather in the internet connections themselves. Zend did not slow down eAccelerator or xcache.
13.80 [Pages / sec]
200.82 [Kbytes / sec]
20.77 [Pages / sec]
302.09 [Kbytes / sec]
20.61 [Pages / sec]
299.82 [Kbytes / sec]
20.28 [Pages / sec]
295.02 [Kbytes / sec]
7.07 [Pages / sec]
102.82 [Kbytes / sec]
As you might guess, I went with xcache. The advantages of xcache are :
- xcache is in the Ubuntu repositories (php5-xcache) and is thus easier to install and keep up to date.
- xcache has a lower footprint (ram requirements).
Update : Benchmarks can also be deceiving. I was not happy with the xcache performance, and actually was getting some 505 (internal errors) so in the end I went with APC.