Apache vs. Lighttpd: "echo" performance - Blog - Open Source - schlitt.info

schlitt.info - php, photography and private stuff

Apache vs. Lighttpd: "echo" performance

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 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

image_1

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. I actually have no clue if this is correct, but it sounded valid to me. Maybe someone can enlighten us?

If you liked this blog post or learned something, please consider using flattr to contribute back: .

Trackbacks

Comments

Add new comment

Fields with bold names are mandatory.