System Atlas
the atlas
NET · Networking7 minApplied

Why Nginx is so popular

One event loop that quietly handles tens of thousands of connections at once.

the gist

Nginx won by replacing the old thread-per-connection model with an event-driven, asynchronous architecture that handles enormous concurrency on tiny memory. That efficient core makes it a natural fit for the jobs that sit at the network edge: reverse proxy, load balancer, static file server, TLS terminator, and cache — often all at once.

ANALOGY // A thread-per-connection server is a call center that hires one agent per caller and pays them to sit on hold; Nginx is a handful of expert agents wearing headsets, instantly switching to whichever line actually starts talking.
living diagram01 / 06
An efficient core, then the edge roles it enables
01
Event-driven core
async · non-blocking workers
02
Reverse proxy
fronts app servers
03
Load balancer
spreads traffic · health checks
04
Static file server
sendfile · assets from disk
05
TLS termination
HTTPS at the edge
06
Caching
low memory · high concurrency
01

The event-driven core

Nginx's foundation is a small number of worker processes, each running a single-threaded event loop. Instead of dedicating a thread to every connection and blocking while it waits, a worker registers thousands of connections and reacts only when one has data ready. This non-blocking model is why a couple of workers can juggle tens of thousands of simultaneous clients on very little memory.

02

Reverse proxy

The most common role is as a reverse proxy sitting in front of application servers. Clients connect to Nginx, which forwards their requests to the backend and relays the response, so the real servers are never exposed directly. This gives you a single stable front door, centralizes logging and security, and lets you change backends without clients noticing.

03

Load balancer

Because it already proxies to backends, Nginx naturally distributes traffic across a pool of them. It supports algorithms like round-robin, least-connections and IP-hash, and it health-checks upstreams so failed servers are skipped. This turns a set of identical app instances into one resilient, horizontally scalable service.

04

Static file server

Serving static assets — images, CSS, JavaScript, downloads — straight from disk is something Nginx does exceptionally well, using efficient system calls like sendfile to push bytes with minimal overhead. Offloading this from your application servers frees them to do real work. Many sites use Nginx purely as a blazing-fast static front end.

05

TLS termination

Nginx commonly terminates TLS at the edge: it holds the certificates, decrypts incoming HTTPS, and forwards plain HTTP to the backends over the trusted internal network. This concentrates certificate management in one place and spares each application server the cost of the TLS handshake. It is the standard way to add HTTPS in front of an app.

06

Caching & high concurrency

Finally, Nginx can cache upstream responses so repeated requests are answered directly without troubling the backend. Combined with its low per-connection memory footprint, this lets a single modest server absorb huge, spiky traffic. The sum of these traits — efficiency plus a stack of edge roles in one binary — is why Nginx became ubiquitous.

the full picture
01

The problem Nginx was born to solve

In the late 1990s and early 2000s, the dominant web server, Apache, handled each connection with a dedicated process or thread. That model is intuitive and works beautifully at low scale, but it hits a wall famously known as the C10k problem: serving ten thousand simultaneous connections. Each thread consumes memory for its stack, and the operating system spends more and more time context-switching between thousands of mostly-idle threads that are just waiting on slow network clients. Memory and CPU are burned on overhead rather than useful work.

Nginx, created by Igor Sysoev and released in 2004, was designed from scratch to beat this. Its answer was a completely different concurrency model, and that architectural choice — more than any single feature — is why it went on to power a huge fraction of the world's busiest sites. Understanding *why* it is efficient explains everything else about where and how it is used.

02

The event-driven architecture

Instead of one thread per connection, Nginx runs a small, fixed number of worker processes — typically one per CPU core. Each worker is single-threaded and runs an event loop: it asks the operating system (via mechanisms like epoll on Linux) which of its many connections have data ready, then services exactly those, and never blocks waiting on any one of them.

The consequence is profound. A single worker can hold tens of thousands of open connections while actively working on only the handful that need attention at any instant. Because idle connections cost almost nothing but a small bit of memory to track, concurrency is decoupled from thread count. This is asynchronous, non-blocking I/O, and it is why Nginx's memory use stays flat and predictable as connections climb into the hundreds of thousands, where a thread-per-connection server would have long since exhausted its RAM. The efficiency of this core is the foundation everything else is built on.

03

The edge roles it enables

An efficient, connection-juggling core is exactly what you want at the *edge* of a system — the point where lots of client connections meet your infrastructure — so Nginx grew into the go-to tool for several jobs there. It is rarely just one thing; the same binary typically does many at once:

  • Reverse proxy — it fronts your application servers, accepting client requests and forwarding them to backends, so the real servers stay hidden and swappable behind one stable address.
  • Load balancer — it spreads requests across a pool of backends using round-robin, least-connections or hashing, and health-checks them so dead instances are bypassed.
  • Static file server — it streams assets straight from disk with efficient kernel calls, far faster and cheaper than routing them through an application.

Each of these is a natural fit because each is about efficiently shuttling many connections between clients and backends — precisely what the event loop excels at.

04

TLS, caching, and doing it all at once

Two more roles round out why Nginx is so often the first thing traffic hits. TLS termination means Nginx holds your certificates, performs the expensive HTTPS handshake, and forwards decrypted plain HTTP to backends across the trusted internal network. This centralizes certificate management and offloads cryptographic work from application servers that would otherwise each pay it. Caching lets Nginx store upstream responses and serve repeats itself, shielding backends from redundant load and cutting latency.

The reason all of this matters together is consolidation. A single Nginx instance can be your HTTPS endpoint, your load balancer, your static server and your cache simultaneously, and thanks to the low-memory event model it does so while sustaining very high concurrency on modest hardware. That combination — one efficient, battle-tested binary covering the whole edge tier — is what made it a default choice.

05

Trade-offs and where it fits

Nginx is not magic, and its design imposes real constraints. The event-loop model demands that work stay non-blocking: a slow operation inside a worker would stall every connection that worker is handling, which is why Nginx historically leaned on static content and proxying rather than running heavy application logic itself. Dynamic code generally lives in separate backend processes that Nginx proxies to. Its configuration is powerful but declarative and can be unintuitive, and while newer tools like Envoy offer richer dynamic control for service-mesh scenarios, they add complexity Nginx often avoids.

In practice, Nginx sits at the front of an enormous share of production stacks precisely because it hits a sweet spot: extremely efficient, endlessly capable across the common edge jobs, stable, and light on resources. When you need something to terminate TLS, balance load, serve assets and proxy to an app — without a fleet of specialized boxes — Nginx remains the pragmatic default, which is exactly how it earned its popularity.

what to remember
01

Event-driven, asynchronous architecture: a few worker processes each run an event loop handling thousands of connections.

02

This avoids the thread-per-connection model, whose memory and context-switching overhead collapses under high concurrency (the C10k problem).

03

As a reverse proxy it fronts application servers, hiding them and forwarding requests.

04

As a load balancer it spreads traffic across backends with health checks and multiple algorithms.

05

It serves static files extremely fast and terminates TLS at the edge so backends speak plain HTTP.

06

It caches responses and, thanks to low memory use, sustains very high concurrency on modest hardware.

check yourself

Quick quiz

Q1

What makes Nginx handle huge concurrency on little memory?

Q2

What does 'TLS termination' at Nginx mean?

follow the thread