Apache vs. Lighttpd: A Comparison! October 29, 2006
Posted by Coimbatore Sankar Raman Shyam Sundar in Geek.trackback
Tobias Schlitt - a php passionist made an interesting comparison between Apache and Lighttpd in “echo” performance.
From schlitt.info - Tobias’s Blog:
For a little private project, which makes extensive use of caching, I recently checked, where I could get gather some more performance from. Kore told me, that Lighttpd ships all of the pages of one of his projects in about 0.001 seconds, while mine still took 0.004 seconds on Apache. After some tracing I found the actual point of problem: The echo ing of the final output, which took most of the time. I tried to run the same project on Lighttpd and guess what: There were the 0.001 seconds.
After this adventure, I made a little benchmark between Apache (with mod_php) and Lighttpd (with fastcgi). I took 3 files of different sizes: a small one, with about 30kb, 1 medium size (about 70kb) and a large image (about 280kb). The only thing my PHP script does is reading the file using file_get_contents() (this part is not measured) and echoing it to the browser (this part is measured). The results, in seconds, are (average values from 1000 script runs):
| Files | Apache | Lighttpd |
| Small | 8.74919891357E-05 | 6.94532394409E-05 |
| Medium | 0.000167278051376 | 0.000110051393509 |
| Large | 0.00403597259521 | 0.00102773714066 |

Note: For this image I multiplied the “medium” and “small” numbers with 10!
I found this results quite impressive and it confirmed my usage of Lighttpd, although I wondered, where this may come from. A discussion in our usergroup brought up the thesis, that fastcgi uses shared memory to transfer data, while mod_php seems to use something else.
—
Ofcourse shared memory improves performance but FastCGI has its own limitations. Reason why mod_php is slower is : Embedding php interpreter (mod_php) in the httpd process often sucks away precious memory in each Apache process thus making it harder to scale higher traffic sites up in volume and results in a pathetic performance.
[...] Auch große Websites, wie YouTube, Wikipedia, mySpace oder SourceForge haben Lighty bereits für sich entdeckt und nutzen den enormen Performance-Vorteil für ihre großen Besucheranstürme (siehe auch hier). [...]