Open Source
10 items
10 items
The event-driven web server that handles millions of concurrent connections - powering 34% of the web
Nginx (pronounced "engine-x") solves the C10K problem - handling 10,000+ concurrent connections efficiently. Unlike Apache's process-per-connection model, Nginx uses an event-driven, non-blocking architecture where a single worker process handles thousands of connections using epoll/kqueue. This makes Nginx extremely memory-efficient (2.5MB per 10K idle connections vs 2.5GB for Apache). Beyond serving static files, Nginx excels as a reverse proxy, load balancer, and API gateway.
One worker process handles thousands of connections using non-blocking I/O and event notifications (epoll on Linux, kqueue on BSD). No thread-per-connection overhead means predictable memory usage regardless of connection count.
A master process manages configuration and worker lifecycle. Workers are independent - if one crashes, others continue serving. This enables zero-downtime configuration reloads and binary upgrades.
Request handling is split into phases (post-read, rewrite, access, content, log). Modules hook into specific phases, enabling clean separation between authentication, caching, proxying, and logging.
Nginx was created by Igor Sysoev in 2002 to solve Rambler's (Russian search engine) scaling problems. At the time, Apache dominated the web server market but struggled with high concurrency - the C10K problem.
The C10K Problem: How do you handle 10,000+ simultaneous connections on a single server?
Apache's approach: one process (or thread) per connection - 10,000 connections = 10,000 processes - Each process: ~2-10MB memory overhead - Result: 20-100GB RAM just for connection handling - Context switching kills performance
Nginx's approach: event-driven, non-blocking I/O - 10,000 connections = 1 worker process - Memory: ~2.5KB per connection - Result: ~25MB for 10,000 connections - No context switching between connections
Common use cases today: