Apache vs. lighttpd vs. WEBrick

While Apache has the advantage of coming pre-installed on leased servers and virtual servers, I am way more enthusiastic about using lighttpd as the front end for Rails applications. For one thing, all you need to do is install the Perl Compatible Regular Expression and then lighttpd, and then Rails will automatically and painlessly use lighttpd in development mode. Installing lighttpd and Rails in production mode is also easier than dealing with Apache (here are good directions).

Although what I am going to say next goes against common Rails wisdom, I would also like to add that it sometimes makes sense to deploy in production mode with WEBrick. Here are a few application specific details that might make you decide, at least for a long while, to just use WEBrick:
  • You need your web application to run in a very low memory environment (like a virtual server with a very small amount of allocated memory)
  • You expect a small number of concurrent users
  • Most content is dynamically generated
If I run a small web application in production mode on WEBrick + Rails it takes about 22MB. If I run the same web application using lighttpd + Rails (using two FCGI processes), I use a total of about 60 MB, but obviously with better performance. (This is a moot point for me because I lease two virtual servers with 192MB and 224 MB of allocated physical memory.)

For a lot of reasons I like to not use a shared server (i.e., share Apache, get a unique port for Rails, etc.): ability to customize the OS, what services to run, choose lighttpd instead of Apache, secondary uses like backup and subversion services, etc. It has been my experience that I get better service (automated backups, restarts after hardware replacements, etc.) using Xen based virtual servers rather than cheap leased servers. You can also usually buy just what you need and reconfigure as needed; one scenario is setting up a low volume web portal using WEBrick + Rails and an inexpensive low memory virtual server. If necessary for either reducing server latency or handling many more concurrent users, just order more allocated memory and switch to using lighttpd + Rails with very little trouble.

I have not tried SwitchTower yet, but the documentation looks good and I am looking forward to trying it out.


Popular posts from this blog

Ruby Sinatra web apps with background work threads

My Dad's work with Robert Oppenheimer and Edward Teller

Time and Attention Fragmentation in Our Digital Lives