title: Is Nginx + php-fpm is suppose be much faster than Apache + mod-php
body: <p>I'm having a PHP based web application running on Apache server which has considerable amount of php processing in back end. Since the overall performance is low I worked on improving the performance of the application. First I followed techniques such as client side caching, gzip enabling, js-css minifying which improved the performance upto a good extend. </p>
  
  <p>In order to further improve the performance I wanted to try out server level improvement. So I tried to compare the application performance by hosting it on Apache and Nginx servers.</p>
  
  <ul>
  <li>Nginx version - 1.0.15;</li>
  <li>Apache version - 2.2.15;</li>
  <li>php version - 5.4.38;</li>
  </ul>
  
  <p>In Apache I user Apache + mod-php and in Nginx I used Nginx + php-fpm for this comparison. As most of the tutorials explained I configured the number of Nginx workers equal to the number of cores in my processor. I used jmeter to do the stress testing and following are the graphs I could generate out of it.</p>
  
  <p>In all these graphs x-axis is each request I sent and y-axis is milliseconds for getting response for each request.</p>
  
  <p><strong>Access the login page</strong></p>
  
  <p><img src="https://i.stack.imgur.com/qMNyy.png" alt="enter image description here"></p>
  
  <p><strong>Submit the login page</strong></p>
  
  <p><img src="https://i.stack.imgur.com/my6jB.png" alt="enter image description here"></p>
  
  <p><strong>Access home page</strong></p>
  
  <p><img src="https://i.stack.imgur.com/si8Te.png" alt="enter image description here"></p>
  
  <p>I could only perform the testing upto 100 concurrent users logged in within 1 second because it started dropping requests after then in both server setups.</p>
  
  <p><strong>There was a little improvement on performance in Nginx than Apache but it was not a major difference where it's worth to change all my server architecture from Apache to Nginx. And when I observe the server resource utilization also I didn't find much of difference between Nginx and Apache</strong></p>
  
  <p>When I went through other comparisons people have done, I found that they claim Nginx is much more faster in concurrent accesses such as following graph shows.</p>
  
  <p><a href="http://www.eschrade.com/wp-content/uploads/2014/01/event-mpm-nginx.gif" rel="noreferrer">http://www.eschrade.com/wp-content/uploads/2014/01/event-mpm-nginx.gif</a></p>
  
  <p>But I was unable to observe any major difference of performance in Nginx over Apache even with 100 concurrent access within 1 second.</p>
  
  <p>Following are my questions.</p>
  
  <ol>
  <li>Is Nginx + php-fpm is suppose to do server operations much faster than Apache + mod-php due to efficient usage of memory and other resources ?</li>
  <li>Is Nginx only recommended to server static contend and not for heavy server operation sites ?</li>
  <li>Is there any better way of configuring Nginx to gain more performance improvement ?</li>
  </ol>