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:

Clicking on the image will open the page with the results at LoadImpact.COM

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:

Clicking on the image will open test results page at LoadImpact.COM

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.



Tags: , , , ,

Sunday, April 11th, 2010 Hacks, Hosting, Reviews

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

  1. 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

  2. zob on March 25th, 2011
  3. 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?

  4. Oleksiy Deverishchev on March 25th, 2011
  5. 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.

  6. uknown_proxy on June 30th, 2011

Leave a comment

About


Oleksiy Deverishchev is a freelance web developer living in New York City. In this blog he shares his experience with various gadgets and web technologies.

He is available for the following gigs:
  • Microsoft Access projects
  • website design and re-design services
  • php/MySQL developement
  • Java and Grails development
  • virtual private server (VPS) migration, setup and tune-up

For more information and hiring availability please send an email to alex@webandblog.com

Advertisment

Read more

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

I am a Freelancers Union Member

Freelancers Union Member Badge