title: nginx : Its Multithreaded but uses multiple processes?
body: <p>I'm trying to understand what makes Nginx so fast, and I have a few questions.</p>
  <p>As I understand it, Apache either spawns a new process to serve each request OR spawns a new thread to serve each request. Since each new thread shares virtual address space the memory usage keeps climbs if there are a number of concurrent requests coming in.</p>
  <p>Nginx solves this by having just one listening process(Master), with a single execution thread AND 2 or 3(number is configurable) worker processes. This Master process/thread is running an event loop. Effectively waiting for any incoming request. When a request comes in it gives that request to one of the worker processes.</p>
  <p>Please correct me if my above understanding is not correct</p>
  <p>If the above is correct, then I have a few questions:</p>
  <ol>
  <li><p>Isn't the worker process going to spawn multiple threads and going to run into the same problem as apache ?</p>
  </li>
  <li><p>Or is nginx fast because its event based architecture uses nonblocking-IO underneath it all. Maybe the worker process spawns threads which do <strong>only</strong> non-blocking-IO, is that it ?</p>
  </li>
  <li><p>What &quot;exactly&quot; is &quot;event based architecture&quot;, can someone really simplify it, for soemone like me to understand. Does it just pertain to non-blocking-io or something else as well ?</p>
  </li>
  </ol>
  <p>I got a reference of <a href="http://www.kegel.com/c10k.html#top" rel="noreferrer"><strong>c10k</strong></a>, I am trying to go through it, but I don't think its about event based arch. it seems more for nonblocking IO.</p>