title: Unicorn workers freeze from time to time
body: <p>A couple of days ago I noticed a strange thing - from time to time server stops processing request for some time. At the <code>top</code> output it looks like this:</p>
  
  <ul>
  <li>ten Unicorn workers process requests;</li>
  <li>then, for some reason, they stop doing anything. I mean, all ten workers have 'sleeping' status;</li>
  <li>for a ten-fifteen seconds they sleep;</li>
  <li>and then suddenly all then workers at the same time start processing requests (lots of them were queued for 10s);</li>
  </ul>
  
  <p>I have the following setup:
  nginx, unicorn 4.6.2, postgres, redis for sessions and cache, MRI ruby 2.0.0p353.</p>
  
  <p>My first thought was to blame redid (because if redis doesn't give sessions, all process will wait for it), but it seems it is not the case, because while unicorn workers freeze, redis serving other processes that do background jobs.</p>
  
  <p>I don't understand what is the reason of this strange behaviour.</p>
  
  <p>If someone have some thoughts on the matter I would gladly check it. If you need additional information - just tell me what to do, and I'll try to provide it.</p>
  
  <p>UPDATE:</p>
  
  <ul>
  <li><a href="https://gist.github.com/ArtemPyanykh/8596854" rel="nofollow">Unicorn config</a></li>
  <li><a href="https://gist.github.com/ArtemPyanykh/8596648" rel="nofollow">strace on unicorn worker</a></li>
  <li><a href="https://gist.github.com/ArtemPyanykh/8596693" rel="nofollow">strace on unicorn master</a></li>
  <li><a href="https://gist.github.com/ArtemPyanykh/8596718" rel="nofollow">strace on nginx</a></li>
  </ul>