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.
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:
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!