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.
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.
Most comparisons use Apache Prefork process model. This uses a process per request. But Apache *is* event based with the “Event MPM”, and you can also use FastCGI with Apache. These are just a few settings.