Nginx can do a lot of what Apache can do, and for maybe 99% of the use cases of Apache, Nginx can also serve the same function intuitively.Nginx will not likely “kill” Apache, however. At best, it’s a great alternative to another great piece of software that lends to the open source world’s much-celebrated diversity in choices. In this post you can read Yet another Nginx Vs Apache comparison by Celingest .They ran all the benchmark in the AWS Cloud using all the resources suitable to this test: ELB, EC2, EBS, RDS and ElastiCache. Moreover, Nginx wasn’t always the winner.
Nginx Vs Apache On EC2 : Performance Comparison
Benchmark Scenario:
We wanted to measure the different performances of Nginx (v. 1.2.6) and Apache (v. 2.2.23) using the vanilla version of Worpress 3.5.1 running on 2 EC2 instances sharing one GlusterFS volume (EBS based), one RDS (small) instance and an ElastiCache small instance, all behind an Elastic Load Balancer. All test were conducted using php-fpm, Apache mpm_worker and Nginx configured to use only one worker with no particular configuration or tuning.
Nginx Vs Apache in AWS: Infrastructure schema
We used ApacheBench (version 2.3) to run the test: ab -n $(($concurrency*1000)) -c $concurrency http://www.mywordpressbenchmark.com/ Test with concurrency of 50 and 100 were conducted from different sites (25 concurrent users per site) to force the ELB to distribute the load on the instances and to avoid to trigger Amazon’s Anti DDoS checks.
Versions of the web servers were: Nginx 1.2.6, Apache 2.2.23 running in the latest x86_64 Amazon Linux AMI, release 2012.09.
The results:
m1.small EC2 instance: 1.7 GiB memory 1 EC2 Compute Unit (1 virtual core with 1 EC2 Compute Unit)
m1.small: phpinfo()
m1.small: WordPress 3.5
c1.medium EC2 instance: 1.7 GiB of memory 5 EC2 Compute Units (2 virtual cores with 2.5 EC2 Compute Units each)
c1.medium: phpinfo()
m1.large EC2 instance: 7.5 GiB memory 4 EC2 Compute Units (2 virtual cores with 2 EC2 Compute Units each)
Updated tests with Nginx workers set according to CPU cores:
Conclusions:
As we can see from the graphics on small instances Nginx prevails always, especially on high concurrency where the Nginx event driven worker show its power running on one core showing a percentage increment between 49% and 201%. While on multicore instances we can see that Nginx, sometimes, suffers a small gap on “pure” WordPress (due to the workers = 1 setting)using file caching or memcached results are always favorable to nginx with a maximum percentage increments of 268%. Beside of the Nginx Vs Apache benchmark we clearly see that caching WordPress is imperative and a plugin that uses correctly Memcached is a must-have.
Drawing our conclusions we’re always considering the highest concurrency (100) while speaking of percentages because You want your site this busy.. right?
Conclusion’s update:
As we can see from data in the last tables using all CPU cores for Nginx it’s not that optimal as with pure php code and high concurrency request/sec. has significative drops.
References:
Nginx Webserver http://nginx.org/
Apache HTTP Server http://httpd.apache.org/
Wordpress CMS http://wordpress.org/
WP Super Cache Plugin http://wordpress.org/extend/plugins/wp-super-cache/
Hyper Cache Plugin http://wordpress.org/extend/plugins/hyper-cache/
GlusterFS http://www.gluster.org/
Amazon Web Services: EC2, Elastic Block Store, Elastic Load Balancing, RDS, ElastiCache.
Recommended : A quick video tutorial explains how to install the nginx web server under RHEL / CentOS 6. on