title: Increase PHP-FPM idle timeout setting
body: <p>We have recently migrated to PHP-FPM. However we have encountered a problem with some long running scripts. The code looks roughly like:</p>
  
  <pre><code>foreach ($items as $item) {
       set_time_limit(30);
       proccessThatTakesAround2secs(); 
  }
  </code></pre>
  
  <p>The normal PHP script time limit is also 30 secs. This was previously working fine in that we reset the remaining time limit back to 30 secs for each item. There are around 1000 items meaning the script in total would normally take about 30 mins to complete. However we have since reached the following problem:</p>
  
  <blockquote>
    <p>FastCGI: comm with server "/usr/local/php-5.6.24/sbin/php5-fpm" aborted: idle timeout (30 sec)</p>
  </blockquote>
  
  <p>Now my question is, is it sensible to increase the idle timeout to something like an hour but still ensure the PHP scripts don't run for longer than 30 secs, unless we use <code>set_time_limit</code>? Is there a way to set the idle timeout on a per script basis (something akin to a <code>set_time_limit</code>?)</p>
  
  <p>Here is our pool configuration:</p>
  
  <pre><code>[www]
  user = www-data
  group = www-data
  listen = /var/run/php5-fpm.sock
  listen.owner = www-data
  listen.group = www-data
  pm = static
  pm.max_children = 55
  pm.max_requests = 10000
  
  php_value[memory_limit] = 128M
  php_value[max_execution_time] = 30
  php_value[upload_max_filesize] = 20M
  php_value[post_max_size] = 20M
  php_value[max_input_vars] = 9999
  </code></pre>
  
  <p>And here is our fastcgi.conf</p>
  
  <pre><code>&lt;IfModule mod_fastcgi.c&gt;
      AddType application/x-httpd-fastphp5 .php
      Action application/x-httpd-fastphp5 /php5-fcgi
      Alias /php5-fcgi /usr/local/php-5.6.24/sbin/php5-fpm
      FastCgiExternalServer /usr/local/php-5.6.24/sbin/php5-fpm -socket /var/run/php5-fpm.sock -idle-timeout 30 -pass-header Authorization
      &lt;Directory /usr/local/php-5.6.24/sbin/&gt;
          Require all granted
     &lt;/Directory&gt;
  &lt;/IfModule&gt;
  </code></pre>