Web server performance comparison

Over the years, a myriad of web servers have been written.

Apache, being one of the oldest, is the most widely used today. However, it was implemented with a scaling mechanism that can be relatively inefficient in some ways. Some newer web servers have come out in the last few years that attempt to address some of the shortcomings of Apache. The most prominent of these are Lighttpd and Nginx.

All three of these web servers are supported and available pre-configured on DreamHost's VPS hosting platform. Regular Shared Hosting uses Apache (primarily because of its broader feature support).

This article examines the relative performance of each web server to see how they compare head-to-head. Keep in mind that this is not meant to be an exhaustive be-all end-all performance comparison. The hope is to simply give a relative performance comparison under common conditions.

Testing method

  • The method to test these web servers uses ApacheBench (an HTTP server benchmarking tool).
  • In each test, 25,000 requests are made for a 5k PNG file locally from a VPS to remove potentially variable network conditions from the equation.
  • Before each test the web server in question was restarted to clear out any potential caching or other issues that may interfere with results.
  • Each test was run with different numbers of concurrent requests to gauge performance at different levels of usage. (Consider that it's very common for browsers to allow up to 6 concurrent connections per single user you have browsing a site. Therefore 10 users browsing your site at the same time would amount to approximately 60 concurrent connections).

The commands that are used in this test follow this format:

[server]$ ab -n 25000 -c 50 http://www.example.com/dreamhost_logo.png

where the -c flag increased with the concurrency level.

Memory usage

This is important to measure, especially on a VPS where your memory usage has a hard cap and raising it costs you additional money. (Note that memory is in megabytes.)

Webserver memory graph.jpg

As you can see, both Lighttpd and Nginx come out as clear leaders in this test. In fact, the difference is SO dramatic it's almost a bit unbelievable. How can such a huge disparity exist?

It has to do with how Apache handles scaling with more incoming requests. To handle additional requests, it spawns new threads (i.e., processes). As more and more connections come in, more and more Apache processes are spawned to handle them. This causes memory usage to grow fairly quickly.

In comparison, you see that Nginx and Lighttpd both have fairly static memory usage. Lighttpd actually increases more over time (and purportedly has issues with memory leaking), whereas Nginx stays fairly static across the board from start to finish.

Requests per second

This is essentially a measure of how fast the server can receive and serve requests at different levels of concurrency. The more requests they can handle per second, the more able the server is to handle large amounts of traffic. Here's how the servers compare in this arena:

Webserver requests graph.jpg

Nginx clearly dominates in the raw number of requests per second it can serve. At higher levels of concurrency, it can handle fewer requests per second, but still can serve double what Lighttpd does (which was already doing nearly 4x what Apache was able to do).

Remember, the results shown are good only for measuring relative (and not absolute) performance, as the tests were conducted locally on the server.


Remember, Apache supports a larger toolbox of things it can do immediately and is probably the most compatible across all web software out there today. Furthermore, most websites really don't get so many concurrent hits as to gain large performance/memory benefits from Lighttpd or Nginx – but you can check them out to see if they work best for your needs.

See also

Did this article answer your questions?

Article last updated .