title: php-fpm processes monitoring / profiling
body: <p>I have recently encountered an issue with php-fpm processes usage (As in the amount of active processes) peaking to the maximum available processes and by that stopping execution of other scripts until the problematic processes finish.</p>
  
  <p>In a bit more detail,
  my current php-fpm settings are:</p>
  
  <pre><code>pm = static
  pm.max_children = 100
  </code></pre>
  
  <p>I am watching the php-fpm's status page, which most of the time shows:</p>
  
  <pre><code>total processes: 100
  idle processes: 95-99
  active processes: 1-5
  </code></pre>
  
  <p>which is normal.
  However, ever few minutes the active processes count jumps to 100 for a few seconds, and then goes back to normal of 1-5. in that time all other scripts running on the server are simply stuck for that period of time. (From the browser you simply see the page waiting).</p>
  
  <p>Now, i have checked to see if its in specific traffic spikes, but its not. it can also occur with the lowest traffic count of the day.</p>
  
  <p>I believe that a certain script, maybe even only in specific situations, is causing php to simply use all available processes for some reason.</p>
  
  <p>This issue started once we moved to PHP 5.4.X from 5.2.X</p>
  
  <p>We currently have around 60 websites, so its kinda hard going through each website's pages and checking it.</p>
  
  <p>There is nothing in the nginx logs (Nothing critical anyway, there are a few Notices and such).</p>
  
  <p>What i'm trying to do, is somehow trace/profile/monitor which php-fpm script is using the processes so i will know where to start looking for the problem.</p>
  
  <p>Is this possible? Maybe a different approach?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Here is a graph of the PHP-FPM process count in 1 hour, in 1 min intervals:</p>
  
  <p><img src="https://i.imgur.com/dWZxkZ2.png" alt="graph"></p>
  
  <p>I have marked in red the jumps that i'm talking about.
  The memory usage at the time of the spike stays the same</p>