Apache vs. Lighttpd (Or, Why I Switched Web Daemons)

Lighttpd logoAfter doing some research online and conducting some benchmarks using ab, I decided to make the switch from Apache 2.2 to Lighttpd. My personal benchmarks confirmed what I read.

Before doing any benchmarking, you need to level the playing field. Disable unnecessary modules. Do not use mod_php5. Use FastCGI instead.

With a few concurrent connections (i.e., a few users), the performance between Apache and Lighttpd is minimal. Apache may even outperform Lighttpd by a negligible amount, especially when serving static content. However, as the number of concurrent users increases (or spikes, like when Slashdotted or Dugg), Lighttpd is able to seriously outperform Apache, as shown by TextDrive's blog post on taking a full frontal Slashdot.

In my findings, with 20 concurrent connections and 50 requests, Lighttpd was about twice as fast. At 50 connections with 200 requests, Lighttpd continues to outperform Apache by a factor of two. Even under SSL (using mod_ssl on Apache 2 and Lighttpd's built-in SSL engine), at 20 connections with 100 requests, Lighttpd is more than twice as fast.

Personally, I don't know when I or someone I share my server with may get Slashdotted or Dugg, but I'd rather be prepared for it and use Lighttpd in the meanwhile. For that reason, I decided it was worth the switch -- and the fact that Lighttpd's url.rewrite isn't too bad and it supports IPv6 and SSL made it easier)