SERVER LOAD TESTING NGINX VS APACHE WITH DRUPAL

here is the million dollar questoin! 😀 what is the best web server ? nginx or apache ? if you dig some deep on this, you’ll come around that unless, you have a very big user base or limited hardware resources, it doesn’t matter.

so i wanted to test this with drupal, whether it actually makes a difference in a practical situation. (theoretically it should) thanks to AWS free tier i setup my test environment using AWS as below.

SETTING UP TEST ENVIRONMENT

following are the actions i performed in AWS console and in EC2,

  • launched an EC2 instance
  • launched RDS instance for mysql (for use as drupal’s DB)
  • installed both apache and nginx servers in EC2 instance
  • installed drupal and connected it to RBD server
  • added some dummy content in drupal site

next i created an image of my EC2 instance (AMI) and launched another instance with the same hardware features as previous EC2 instance in same region from the created AMI.

so the next steps followed are,

  • configured one instance to run apache only and another to run nginx only.
  • pointed drupal installation as root directory in both servers.

after this, i had two drupal installations with same content running on apache and nginx in same location.

CREATING A TEST PLAN

so the basic thing i wanted to test is,

server performance in limited hardware over a large traffic.

i used jmeter with performance monitor plugin for this. performance monitor plugin will allow you to measure server performance metrics in jmeter.(cool right ? 🙂 )

for the test plan, in jmeter

  • added thread group with 1000 threads to simulate 1000 users
  • inside thread group added HTTP GET request to root folder to simulate main page access in druapl site
  • added a performance monitor metric collector to measure server CPU & memory usage
  • added a summary report to get overall statistics
jmeter test plan
jmeter test plan

 

RESULTS

so i performed this same test on both of my EC2 instances. following are the results i obtained.

APACHE

requests failed throughput
1000 18.7% 4.437640063/hr
apache server performances for 1000 users
apache server performances

NGINX

requests failed throughput
1000 7.2% 4.4314258999/hr
nginx server performances for 1000 users
nginx server performances

CONCLUSION

so so so, here it is! answer for the million dollar question.

under a large traffic with same hardware resources, nginx performs way better than apache.

references:
https://www.digitalocean.com/community/tutorials/how-to-use-apache-jmeter-to-perform-load-testing-on-a-web-server