Lighttpd runs circles around Apache
Recently we did some work for a customer who has been struggling with keeping load under control. The servers run a few websites, and most of the web traffic is for a handful of sites that process lots of short web transactions in PHP against a MySQL backend database. Since each transaction is mostly unique, caching wouldn’t help.
We have heard some mixed reviews of Lighttpd and decided to test it out, since it was built mainly for speed and performance. With only about an hour’s work of building, configuring, and testing, we had a fully functional Lighttpd web server running with PHP running in FastCGI mode. FastCGI offers a way to keep PHP running in memory, independently of each web server process.
In most LAMP environments, PHP is running in Apache via an Apache module, mod_php. In this case, mod_php is loaded by each Apache child process. With all of the libraries and files required, this is not very effecient. FastCGI keeps php processes running on their own, and then php scripts are passed off to it by the web server processes when needed.
We were impressed by the results.
This first graph shows the load averages on one server over the course of several days. The green dot indicates the point when we switched one of the main websites on this server over to Lighttpd.

We just did another switch to Lighttpd on a similar type of server, where most traffic consists of short high-volume transactions. Both servers are running Apache and Lighttpd side by side, with some websites still running on Apache and the high traffic ones running on Lighttpd.

May 4th, 2007 at 8:46 pm
You are right … After suffering for many weeks to optimize apache for best performance on a VPS with a memory limit of 512 MB running heavy forum I couldn’t make any great improvement … So moved to lighttpd … yes it could be much faster with so much lower memory usage …
- I’ve faced really one big problem that the I/O load could get very high sometimes due to the php-fastcgi … I’ve then decreased the number of running php processes and used xcache with much memory caching allowed … then I could get great results .. the memory usage doesn’t exceed 250MB and the CPU load average is 0.50 …
Those are great results …