title: NGINX active connections and workers_connections
body: <p>We are experiencing troubles with our Nginx webserver and we don't understand what is happening (behind it we have Unicorn and Puma for a Rails application).</p>
  <p>We have 6 processors and a configuration with <code>worker_processes auto;</code>. In events we have the default <code>worker_connections 768;</code>.</p>
  <p>We are under the impression that we are able to handle 6 x 768 = 4608 active connections.</p>
  <p>We are monitoring NGINX with NewRelic and the NGINX plugin.</p>
  <p>Sometimes we have connections dropping (user getting an error 500 from NGINX) and we can see this famous error in our log : <code>768 worker_connections are not enough</code></p>
  <p>A simple <code>systemctl reload nginx</code> and the issue is gone.</p>
  <p>When we look at NewRelic we can see that the active connections just doubled (getting from 400 to 800) when this issue occurs. An important point is that we are running B2B application with a limited number of customers so we don't have more traffic when active connection count doubles. We can see that the request per second stay the same. And looking at our access log we don't see attacks.</p>
  <p>So our questions are :</p>
  <ul>
  <li>why have we active connections doubling ?</li>
  <li>why are our workers not able to handle these active connections as there are only 800 active connections and our config should be able to handle at least 4000 connections</li>
  </ul>
  <p>Do we have &quot;dead&quot; nginx workers ? Why everything goes back fine after a reload ?</p>
  <p>Many thanks for your help !</p>
  <p>Here is a screenshot of our NewRelic Dashboard when this is happening</p>
  <p><a href="https://i.stack.imgur.com/qXOBg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qXOBg.png" alt="NewRelic NGINX Dashboard" /></a></p>