title: Nginx with php5-fpm Magento Optimization
body: <p>I have an Nginx setup with php5-fpm with the following server:</p>
  
  <p>Amazon EC2 instance
  t2.medium
  cpu: 2 vcore
  memory: 4 GB
  Storage: EBS Only</p>
  
  <p>The Max user concurrently online is stable around 250 users once it gets to 300 users it starts showing error request. This test is over 30 seconds.</p>
  
  <p>The home page that I use in the test is about 5MB.</p>
  
  <p>Just wondering if I could optimize more to allow more users. Note - the data base is host on another server. so don't take database into account. </p>
  
  <p>I always thought Nginx server is suppose to solve the 10K problem. well even in this case it is not static page, It would expect the user to be more than 300 users.</p>
  
  <p>Maybe php-fpm is the bottle neck</p>
  
  <p>Ulimit Setting</p>
  
  <pre><code>ulimit -a
  core file size          (blocks, -c) 0
  data seg size           (kbytes, -d) unlimited
  scheduling priority             (-e) 0
  file size               (blocks, -f) unlimited
  pending signals                 (-i) 31534
  max locked memory       (kbytes, -l) 64
  max memory size         (kbytes, -m) unlimited
  open files                      (-n) 1024
  pipe size            (512 bytes, -p) 8
  POSIX message queues     (bytes, -q) 819200
  real-time priority              (-r) 0
  stack size              (kbytes, -s) 8192
  cpu time               (seconds, -t) unlimited
  max user processes              (-u) 31534
  virtual memory          (kbytes, -v) unlimited
  file locks                      (-x) unlimited
  </code></pre>
  
  <p>Nginx conf</p>
  
  <pre><code>events {
          worker_connections 2048;
          multi_accept on;
  }
  </code></pre>
  
  <p>php5-fpm conf</p>
  
  <pre><code>;;;;;;;;;;;;;;;;;;
  ; Global Options ;
  ;;;;;;;;;;;;;;;;;;
  
  [global]
  
  pid = /var/run/php5-fpm.pid
  
  
  
  
  
  
  
  ;;;;;;;;;;;;;;;;;;;;
  ; Pool Definitions ;
  ;;;;;;;;;;;;;;;;;;;;
  
  include=/etc/php5/fpm/pool.d/*.conf
  </code></pre>
  
  <p>php pool conf</p>
  
  <pre><code>[www]
  
  user = www-data
  group = www-data
  
    listen = 127.0.0.1:7161
  
  pm = dynamic
  request_terminate_timeout = 600
  chdir = /
  </code></pre>