Apache vs. Nginx – testing performance under heavy load
It has come to my attention, when a client of mine recently experienced unexpected traffic spike, that some industry standard solutions not always work or should i say not 100% reliable all the time. My client's server setup was an-old-school Apache 2.2/mod_php WordPress blog installation. One day they posted some "hot-buzz" celebrity photos and server had become non-responsive under the traffic flow. Of course, at that time i was unaware about high-availability setups and never imagined scenarios like this one, when you get monthly volume of visitors during the 24 hour period.
Since then i have researched a lot of places online and found, that Apache web server is not the only solution to the hosting setup problem. Many others exist and those others, event quite "beta", allow for the great tolerance for the high volume traffic.
Today i'd like to share with you my test results for my current server setup - LEMP or Linux, nginx (Engine-x), MySQL, PHP-FPM versus my old setup for this blog: LAMP - Linux, Apache, MySQL, PHP. Both of those are on the Linode VPS (Linode 360). Before getting rid of the old server configuration i booted it one more time and ran tests using guys from LoadImpact to determine how will each of these survive under the load of 10-20-30-40-50 simulations requests.
So here we are with the performance under the load for the LAMP config:
As you can see this test had timed out at 40 clients - Apache simply took too long to serve all of those. I was also trying to work with a website to post something on the blog and experienced a delay of about 30 seconds to load the page.
Here is the LEMP test:
As you see from above - results are quite different. In this test server was quite responsive with average page load time around 2.1 seconds even with 40+ simultaneous connection. And all this due to the technology behind nginx web server, written by Igor Sysoev.
Feel free to use LoadImpact for you server testing purposes as well, and test mine to see for yourself what nginx can do under high load.
I guess this answers the call - nginx won and my future setups will be based on it, unless there will be a _really_ heavy need for Apache. Oh and by the way, if you are afraid of using Linux based virtual private servers, Linode.COM makes it really easy with a nice resource library and a collection of StackScripts, which simplify your setup. As a matter of fact, i even created my own script and use it for all of my customer's deployments.
Update: recently a client of mine (CompleteBody.COM) did a Groupon promotion. This resulted into a traffic spike from 150 regular daily visitors to their website into 7000 in one day. The Linode VPS (smallest size box configuration) handled it pretty well with CPU spike only of 20%. At the time of writing the website was a WordPress blog hosted on nginx + php-fpm with WP-Cache plugin. Graphs below (2hr averages provided).
Update2: I have decided to go even further and tested my Linode VPS with a 100-300 simultaneous users spike - read results here.

You might also like
| Desktop website performance tool – Apache JMeter Just a post ago i was wondering about testing my website's performance under heavy load and did this... | Simulating high-traffic for Linode VPS via LoadImpact Thanks to the opportunity given to me by guys from LoadImpact.COM i recently tested my Linode 512 MB... | Log only certain file types being downloaded from your website with nginx access_log directive Say you host a website where you have workshops in PDF and would like to get statistics on how many people... | Intermedia hosting outsources technical support to Russia It has come as a surprise, when instead of an Indian person a girl with a russian accent answered my... |
3 Comments to Apache vs. Nginx – testing performance under heavy load
Leave a comment
About
Advertisment
Read more
Riding River Line Light Rail: Along with visit to Princeton today i took a ride on a River Line, a New Jersey Light Rail. More pho...
Golden Gate Park and Japanese Tea Garden: San Francisco is by far one of my favorite cities. One of the places especially I like to spend time...
Zip a folder on the server with php:
I have a spent a day today figuring how to zip a client's web site folder on a Godaddy shared Li...
Point Reyes National Park:
A perfect one-day gateway destination about two hours driving north of San Francisco - Point Reyse...
Mono Lake - sunset and sunrise:
Mono Lake is another point you should consider stopping by if you drive to Yosemite, especially si...
Recent works / current clients
- BellatAuto Inc - New York / New Jersey used car auto dealer: design and coding.
- Colette Maison Lumiere - multimedia artist: design and coding for the CMS.
- Complete Body & Spa - New York City personal training and gym management company: Wordpress template coding.
- DaleStyle Blog Dale Sudakoff’s fashion blog: Wordpress template coding.
- DoctorKalitenko.COM - Sergey Kalitenko : antiaging hollistic doctor performing bioidentical replacement therapy. CMS coding and design.
- Great Jones Spa - premiere New York City Day Spa: coded and designed website and storefront








it is my impression that the issue with apache is that it needs knowledge and proper configuration. of course no site should crawl going from 20 to 30 users, mind you.
my apache server has been on slashdot 5 years ago, when slashdotting was still common, despite being a puny 1.5ghz amd cpu with 1go of ram it never went above 30% cpu usage (pages were cached of course) even when it reached 300-400 clients, for example
its difficult to say how much better nginx is (it actually is slightly faster), but not by the magnitude we can see in your blogs and the like
You might be right about Apache, but nginx works out of the box with no extensive configuration. Why don’t you do a research and prove your point of view by providing Apache configuration and tests?
well, zob could be right or could be worng, but nginx is actually sligtly faster, but who cares. Apache is more reliable. but lighttp is not comparable to nginx, because its also faster than both and more reliable for biggest projects. When I got lighttp set up, its actually takes minimal core (AMD 2.7, 2 GB of RAM)… but there’s no word about Varnish… but servers like facebook usin’ Varnish.