title: Very high CPU consumption for Drupal7 + NginX and PHP-FPM
body: <p>We are working on an application which is using Drupal 7 on (NginX + PHP-FPM). But during performance testing we have observed that Applications Server consuming very high CPU. Average CPU consumption was in the range of 90% (Max processor is consumed by PHP-FPM). Memory consumption is on very lower side.</p>
  
  <p>We have tried with various Concurrent Users load like 25-50-100. But even with this User load we observed CPU consumption was ~90% due to which response time is very high.</p>
  
  <p>We are using 4 Core CPU with RHEL (AWS EC2) OS.
  Application flow is <strong>Reverse Proxy (Nginx) -> Application Server (Drupal 7+NginX+PHP-FPM)</strong></p>
  
  <p>Below are the configuration changes I did-</p>
  
  <p>nginx.conf:-</p>
  
  <pre><code>user              nginx;
  worker_processes 4;
  error_log  /var/log/nginx/error.log;
  pid        /var/run/nginx.pid;
  worker_rlimit_nofile    20480;
  events {
     use epoll;
     worker_connections  10240;
     multi_accept on;
  }
  http {
      include       /etc/nginx/mime.types;
      default_type  application/octet-stream;
  
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
  
      access_log  /var/log/nginx/access.log  main;
      sendfile        on;
      tcp_nopush     on;
      tcp_nodelay     on;
      server_tokens   off;
      keepalive_timeout  65;
      gzip  on;
  ...
  }
  </code></pre>
  
  <p>virtual.conf:-</p>
  
  <pre><code>location ~ '\.php$|^/update.php' {
      fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
      fastcgi_index  index.php;
  
      fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
      fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
  
      fastcgi_buffer_size 128k;
      fastcgi_buffers 256 16k;
      fastcgi_busy_buffers_size 256k;
      fastcgi_temp_file_write_size 256k;
  
      include fastcgi_params;
  }
  </code></pre>
  
  <p>php-fpm.conf:-</p>
  
  <pre><code>emergency_restart_threshold = 10
  emergency_restart_interval = 1m
  process_control_timeout = 15s
  daemonize = no
  </code></pre>
  
  <p>php-fpm/www.conf:-</p>
  
  <pre><code>listen = /var/run/php-fpm/php-fpm.sock
  listen.owner = nginx
  listen.group = nginx
  listen.mode = 0664
  user = nginx
  group = nginx
  pm = dynamic
  pm.max_children = 50
  pm.start_servers = 5
  pm.min_spare_servers = 5
  pm.max_spare_servers = 35
  </code></pre>
  
  <p>Can someone please  guide us how to resolve this issue? </p>