Posts Tagged ‘Nginx’

Benchmarking Nginx and Apache Performance

Tuesday, February 15th, 2011

Last week, I covered basic Apache and Nginx performance details, and my general observations. Without any further delay, I will now cover the technical details of the benchmark, and the exact benchmark numbers.

The test server used in this benchmark was running Debian GNU/Linux 5.0.8. The version of Apache used was 2.2.9, and the version used of Nginx was 0.6.32. The server is equipped with a RAID-0 array benchmarking at 118 MB/sec, and 1.5 GB of RAM. The processor used in the benchmark was a dual core Pentium-4, at 3.0 GHz.

The main benchmarking software used was Seige, version 2.66. Testing was done on a gigabit LAN connection. Pmwiki was the PHP application that was used as a benchmark page, and MySQL support was disabled (to strictly test PHP web application performance). In addition, all non-essential modules in Apache were disabled (mod_ssl, mod_security, etc).

The benchmark was performed a total of 3 times for each amount of concurrent users. As the server’s CPU temperature reached abnormal levels, testing was temporarily paused. Once CPU temperatures reached normal operating levels, testing resumed.

The raw benchmark data is available here: Nginx/Apache Benchmark Data.

The benchmark data presents one conclusion- that Nginx handles high traffic conditions better than Apache, and continues to handle high server loads, as the loads increase. Apache’s failed transactions increases exponentially with a higher concurrent users, whereas Nginx has a lineal increase in failed transactions with a higher concurrent users load. In addition, Apache did fail to respond several times during the benchmark, and required a manual restart of the Apache service. Nginx recovered from high traffic loads gracefully, and did not require restarting of the Nginx service after benchmarking.

One reason that Nginx handles high server loads better than Apache is the reliance of PHP support handled through php-fpm. There are rumors of Nginx supporting PHP in future builds (perhaps similarly to the way that Apache does- via a module). If those rumors are true, Nginx may behave similarly to Apache in regards to PHP performance. Currently, php-fpm launches PHP requests in as a dedicated service, as opposed to Apache’s way of invoking PHP at every request.

In any event, this benchmark shouldn’t be taken as a recommendation of Nginx over Apache. Each web server software solution has it’s advantages and disadvantages, and those should be carefully considered before the selection of a web server. However, if performance under high amounts of traffic is what you need, look no further than Nginx!

Apache vs. Nginx Web Server Performance

Monday, February 7th, 2011

Running a web server isn’t necessarily as easy as it used to be. With more and more high speed users requesting resources from our web servers, web server performance is becoming an important focus with web entrepreneurs. With resources such as social networks, unexpected high server loads can be generated by a single user sharing a link to your web server. DoS attacks can also play a large role in bringing your server down from a high volume of requests, often without warning. If you’ve never had a high volume traffic spike before, it is only a matter of time before you do.

With today’s dynamic websites, web server performance plays a large role in handling an unexpected traffic spike. Although dynamic pages don’t seem to take longer to load on a web server than a static page, heavy server loads (more than 20 concurrent users) result in exponentially long delays in a web server’s response time.

Nginx (pronounced ENGINE-X) is a relatively new web server that is highly praised for it’s performance under high server loads. Although competitor web server software such as Apache offers more features, Nginx is designed primarily with web server performance in mind. Nginx currently has a 6.62% market share in the busiest sites on the Internet, as referenced by Netcraft’s December 2010 Web Server Survey. Nginx’s market share might seem small, but in the highest traffic sites, changes in server software don’t happen overnight.

http://news.netcraft.com/archives/2010/12/01/december-2010-web-server-survey.html

With Nginx’s rising market share, we have to wonder what the performance advantage of switching to Nginx over Apache is. The only real way to show Nginx’s performance advantage is to compare it with a popular web server software solution, such as Apache. According to Netcraft, Apache currently holds the highest market share of web servers.

Pmwiki was used to benchmark Apache and Nginx performance

Pmwiki was used to benchmark Apache and Nginx performance

When I recently benchmarked Apache and Nginx performance, there were several trends that I noticed. Rather than post the hits/second, CPU load, and page render times, I’ve decided instead to post the trends that I noticed while performing this benchmark.  Next week, I will post the exact benchmark scores of each server application, as well as my conclusion.  Here were my observations on the way Nginx and Apache responded to a high amount of concurrent users:

  • Apache and Nginx begin to show noticeable performance loss at around 25-35 concurrent users, averaging around 420 transactions per minute. These are, by far, not normal traffic loads. Bear these numbers in mind when comparing Apache and Nginx performance- under the conditions of the test that I performed, traffic was non-typical.
  • Once failed transactions begin to occur (Apache’s failure point was at around 55-60 concurrent users, Nginx at 180 concurrent users), Apache’s failure rate at higher concurrent users was exponentially higher, whereas Nginx’s failure rate was linearly higher. When Apache was tested with 200 concurrent users, the failure rate was 24%. When Apache was then tested with 220 users, the failure rate grew to 48%. When Nginx was tested with 200 users, the failure rate was 5%. Nginx’s failure rate finally reached 20% at 280 concurrent users.
  • At a high number of concurrent users (200), transactions per second were at 7 for Nginx, and 4 for Apache. At 280 concurrent users, Apache’s transactions per second dropped to a mere 1.66 transactions per second. What this means is that Apache took longer to successfully complete a transaction, at an exponentially larger rate. Nginx’s transactions per second was still at 7.18 transactions per second, at 280 concurrent users.

Next week, I will post the exact benchmark numbers, test conditions, and my conclusion on the test.