Apache versus LightTPD
Ever wondered why none of the Ruby on Rails websites run on Apache?
If you start with Perl, PHP, or other web development languages you don’t give the webserver a second thought - you just run Apache, like everyone else. If you start playing with Ruby on Rails you get the WEBrick development server built in so that’s what you start using, right? When my development work was done, I wanted to set up a production Apache server, but the docs were scarce. Wait - no one’s using Apache for RoR production environments?
Names like WEBrick, LightTPD, Mongrel and nginx keep popping up in the search results but no, no one mentions Apache. So, I chose to try Apache, stubborn as I am. Now I get it - Apache is a dead end for RoR: it’s way too slow (and yes, I had FastCGI enabled). It took Apache a few seconds to generate and serve a simple page, even with caching enabled, unacceptable.
LightTPD
Maybe it’s time to start believing everyone else who isn’t using Apache? Let’s try LightTPD (pronounced ‘lighty’) instead. For the record: I only compared LightTPD and Apache, there may be better solutions but as Joyent (a rather large Rails hosting provider) uses LightTPD, it has decent documentation, a recent release had just come out.
After installing LightTPD, I ran a few performance tests (requesting the first page of my website) with Apache on one port and LightTPD on another port. The table shows the completion time in seconds on the server for each request:
| Apache | LightTPD |
|---|---|
| 0.55353 | 0.172610 |
| 0.53983 | 0.312950 |
| 0.55328 | 0.174420 |
| 0.57171 | 0.173330 |
| 0.55858 | 0.210530 |
| 0.55082 | 0.173850 |
| 0.55589 | 0.309210 |
| 0.56931 | 0.178770 |
| 1.07452 | 0.173580 |
| 0.56005 | 0.180660 |
| 0.56576 | 0.265820 |
| 0.57710 | 0.326370 |
| 0.55825 | 0.253460 |
| 0.57263 | 0.315560 |
Conclusion
The test clearly shows the performance differences between Apache and LightTPD. It takes Apache 61.5% longer to render the same page showing that LightTPD is significantly faster for my website. There may be even better solutions out there as I only evaluated LightTPD but I think I’ll stick with lighty for now!