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!
