Suffix

Apache versus LightTPD

Ever wondered why none of the Ruby on Rails websites run on Apache?

If you start with Perl, PHP or whatever programming language you are used to you never wonder about the web server, you run Apache, just like everyone else does. 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 finished, I looked for a way to get a production server running with Apache, but it seemed hard to find any documentation. What? No one is 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 understand why 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 build and render 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 as 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, and the newest release was brand new.

After installing LightTPD I ran a few performance tests (request 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
Apache & LightTPD performance deviation chart
Apache vs LightTPD performance chart

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 indeed a lot 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!