Web / NGINX Interview questions
How does NGINX handle concurrent client connections?
NGINX handles concurrency with an event-driven, non-blocking model rather than allocating a dedicated OS thread or process per connection.
Each worker process runs an event loop built on the operating system's efficient polling mechanism - epoll on Linux, kqueue on BSD/macOS. Instead of blocking while waiting for I/O (like a slow disk read or an upstream response), the worker registers interest in that event and moves on to service other connections. When the I/O completes, the event loop picks the connection back up.
This means a single worker can juggle thousands of simultaneous connections, since most of the time a connection spends "open" is actually idle, waiting on network I/O rather than consuming CPU. The worker_connections directive caps how many a single worker will hold at once, and NGINX typically runs one worker per CPU core.
More Related questions...