title: PHP5-FPM static, dynamic or on demand?
body: <p>I have a Nginx + PHP5-FPM server with few high traffic websites.</p>
  
  <p>From my understanding of PHP5-FPM pools config, I understood that:</p>
  
  <p>static = can be used to immediately create N child processes so they do not need to be opened/re-opened, they are already opened and can be used when needed, else they are "sleeping".</p>
  
  <p>dynamic = can be used to open a limited number of child processes and re-spawn then when a limit is reached (min/max servers).</p>
  
  <p>ondemand = I specify the max number of child processes to create, and then child processes are created on demand, when needed, and closed when not needed anymore, maintaining a low memory usage but increasing the response time of few milliseconds.</p>
  
  <p>From my tests with a high traffic WordPress website, I noticed that:</p>
  
  <p>If I use "static", the website is for sure faster and can handle immediately high number of concurrent connections, but the memory always increases its usage, and after N hours it seems to use almost the total RAM available. So I have to use a cronjob to periodically (every 1 hour) reload PHP5-FPM with /etc/init.d/php5-fpm reload.</p>
  
  <p>If I use "dynamic" it uses less RAM but after N concurrent connections there are frequent 502 errors (but maybe I configured it not well).</p>
  
  <p>If I use "ondemand" the site is a little slower (like +50/100ms response time), but it can handle all the high traffic without using too much RAM.</p>
  
  <p>So my personal conclusion would be that "ondemand" is really the best method to use in terms of low/controlled memory usage, the only downside is the +50/100 ms in response time but in my case it is not a big problem.</p>
  
  <p>Are my assumptions correct ?</p>