This post should be treated as an historical artifact. It probably contain broken external links and it may no longer reflect my views or opinions.
In late December I started looking at alternative web servers, having hit a point where I actually asked aloud (though to no one in particular) why I still use Apache for any http or php needs that may arise.
I installed nginx (v. 0.6.33) from the EPEL (Extra Packages for Enterprise Linux) repositories and ligHTTPD (v. 1.4.20) from the RPMforge repositories (both third party repositories worth writing about in detail at a later date). Apache was already installed (HTTPD 2.2.3), so a virtual-host was configured to serve data from the same document root using all three servers, and ligHTTPD and nginx were both configured to use PHP through fastCGI1.
I then set up a stock WordPress 2.7 blog, some large images, some thumbnails, and created what amount to approximately a 20k index page with nothing cached. Using ApacheBench to fetch 1000 requests, 100 requests at a time, I came up with some simple numbers showing how long it took to return the same page for each web server.
While I openly admit that the benchmarks produced here are synthetic, arbitrary, and superficial, they do give some rough insight (1,000ft overview-level-insight) as to how much faster nginx and fastCGI are over Apache 2.2 and mod_php. ligHTTPD also performed admirably, and with less hassle involved in set up than nginx; I suspect that this may have just been previous familiarity with its configuration.
Some simple graphs and some thoughts as to what they mean and why we (AKA the web hosting community at large) still use Apache by default follows after the jump.
So what does all this mean? Well, the gist of it is that nginx is really, really god-damned fast.
Like, Embarrassingly Fast; note that I didn’t say that Apache is slow. It’s just not nearly as fast as nginx.
However, that being said, nginx is also not nearly as extensible as Apache is. The lack of support for things that are taken for granted nowadays (.htaccess files come to mind) can be a sticking point for use in a shared hosting environment. ligHTTPD doesn’t support most of those “expected” bells and whistles either, and an argument could be made for such things being a waste of cycles…
But the bottom line is that such bells and whistles are expected to work in a shared hosting environment.
As for why the web hosting community at large drops Apache into place whenever we need an http server, I think it boils down to comfort and Admin Laziness. HTTPD is bundled with most Linux distros by default. We know it because it’s been around forever, and the behavior is predictable and familiar under load or otherwise. It’s sort of become the Microsoft Office2 of http daemons (for better or for worse), and it’s not going anywhere any time soon. Even the 800lb gorilla behemoth that is Microsoft IIS has failed to dethrone Apache thanks to sheer ubiquity. I think the performance or security conscious are always going to migrate towards something with better speed and less exposed attack vectors, but the typical admin probably just won’t care.
And me? For now I’m going to continue using Apache, while I work out if using nginx for any of the sites I host for people would be a problem. If I can get the rewrite rules taken care of, and work out simple site provisioning, I might well make the switch. nginx seems like a no-brainer on single site virtual servers, where resources are scarce, and Apache isn’t getting any slimmer these days.