title: Gunicorn with max-request limit blocks on high load
body: <p>I'm trying to understand the following scenario:</p>
  
  <ul>
  <li>I have a website with nginx in front (serving with SSL, config see below)</li>
  <li>requests to the Django application are handled by gunicorn (0.18, config see below, managed by supervisord)</li>
  <li>when a user loads the website, 10 requests are handled by the gunicorn (the other ones are static files served by nginx) - this requests are not long running requests</li>
  <li>the gunicorn is configured to take <a href="http://docs.gunicorn.org/en/18.0/settings.html#max-requests" rel="noreferrer">maximum of 1000 requests</a> per worker until the worker is respawned </li>
  <li>about 450 people are able to load the page within a short time range (1-2 minutes)</li>
  <li>afterwards the gunicorn somehow blocks and does not handle any more connections, the result is that nginx responds with <code>Gateway Timeout</code> after a while</li>
  </ul>
  
  <p>I suppose the restarting of the workers does not really happen or the mechanism is blocked by the load? I want to understand what is happening to fix this issue.</p>
  
  <p><strong>Can anyone explain what is happening here? Thanks a lot!</strong></p>
  
  <p><em>PS: I'm tied to use gunicorn 18.0, newer version is currently not possible.</em></p>
  
  <p>Here are the configs I use.</p>
  
  <p>nginx:</p>
  
  <pre><code># nginx
  upstream gunicorn_app {
      server 127.0.0.1:8100;
  }
  server {
      listen 443 ssl;
      ...
      # skipping static files config
      ...
      location @proxy_gunicorn_app {
          proxy_read_timeout 1800;
          proxy_set_header   Host $host;
          proxy_set_header   X-Real-IP $remote_addr;
          proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header   X-Forwarded-Proto https;
          proxy_pass         http://gunicorn_app;
      }
  }
  </code></pre>
  
  <p>gunicorn (started via supervisord):</p>
  
  <pre><code># gunicorn
  python manage run_gunicorn --workers 4 --max-requests 1000 -b 127.0.0.1:8100 --timeout 1800
  </code></pre>