Nginx · The edge of your stack

How does Nginx's architecture work?

Mediumarchitectureevent loopworkersUpdated Oct 2026
Quiz this track

Short answer

A master process reads configuration and manages worker processes. Each worker runs a single-threaded event loop that multiplexes many sockets, so connections cost memory rather than a dedicated thread.

Nginx separates control from work. The master validates configuration, binds listening sockets and forks workers. Workers accept connections and process requests through an event loop built on epoll, kqueue or another platform mechanism.

nginx
worker_processes auto;

events {
    worker_connections 4096;
}

http {
    include /etc/nginx/mime.types;
    include /etc/nginx/conf.d/*.conf;
}
The main context controls process-level settings; the events context controls connection handling.

Why this scales

  • Workers do not block on a connection while waiting for the client or upstream
  • One worker can manage thousands of sockets with a small memory footprint
  • Workers are independent, so a crash affects only one process
  • Shared memory zones hold rate limit, connection and cache metadata
  • The cache manager and cache loader are separate helper processes
A single-threaded event loop still runs one request's CPU work at a time. Expensive Lua or regex processing can block a worker, so CPU-heavy work belongs upstream or must be bounded.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1What happens to existing connections during a reload?
  2. 2Why does Nginx not use one thread per connection?
  3. 3What is stored in shared memory zones?
  4. 4Can a blocking module hurt throughput?

Say it in the interview

Nginx has a master process that validates config, binds sockets and manages workers. Each worker handles many connections with a single-threaded event loop using epoll or kqueue. That means idle and slow connections consume memory rather than a thread. Shared memory zones coordinate rate limits, connection limits and cache metadata, while separate cache manager and loader processes handle disk cache.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Nginx mock interview and get scored feedback on depth, clarity and confidence.