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 ?
Setup
I ran these benchmarks on a LAN to reduce the variables introduced when benchmarking oer teh internet.
Version information:
Lighttpd 1.4.19 (with fastcgi)
APC 3.0.19
Zend Optimizer 3.3.3
XCache 1.2.2 (cache size = 16 m)
eAccelerator 0.9.5.3
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.
Results
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
APC
Requests / sec : 24.77 [#/sec]
Time / request : 40.364 [ms]
Transfer rate : 237.94 [Kbytes/sec]
RAM Use : 371 Mb
APC + Zend Incompatible
eAccelerator
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
Zend Optimizer
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.
lighttpd
13.80 [Pages / sec]
200.82 [Kbytes / sec]
APC
20.77 [Pages / sec]
302.09 [Kbytes / sec]
eaccel
20.61 [Pages / sec]
299.82 [Kbytes / sec]
xcache
20.28 [Pages / sec]
295.02 [Kbytes / sec]
Zend Optimizer
7.07 [Pages / sec]
102.82 [Kbytes / sec]
Conclusion
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.
Interesting read but a few points to add. a) You didn’t include platform info that you were testing on. c) With each test did you do a clean start of the machine or run the tests in parallel?
Platform : Ubuntu 9.04 x86_64
Between tests php was re-configured (to change to a new accelerator profile) and lighttp was re-started. The server was then hit with “ab -n 100 -c 10 http://server/index.php” to load the php into the accelerator (cache).
“ab -n 100 -c 10 http://server/index.php” was then run a second time and those results were used.
Pingback: Shadows of epiphany » Blog Archive » Lighttpd - PHP Acceleration …
Hi,
What’s the code in index.php ?
it must be some realistic code so that your benchmark is valid.
A real test would be to test the welcome page of an OSCommerce website or a Joomla (with loads of articles inside).
Could you explain how you change from one PHP accelerator to another ?
I’m likel to switch from Apache to lighttpd, and with some production website I’ll probably use the same tool to benchmark as you did.
Regards,
Thomas.
I agree with you re: benchmarks. I ran the front page of my blog.
Switching to lighttpd is easy, install it on a test server first and see if it works with your site. The biggest disadvantage of lighttpd is it does not have as many options (modules) available as Apache.
This site has nice information :
http://www.cyberciti.biz/tips/installing-and-configuring-lighttpd-webserver-howto.html
You do not need to compile lighttpd on most distros, although you may if you prefer.
I rarely comment but I figured I had to do it now after coming to your site so often. We readers should show appreciation! Keep up the good work!