Performancenon-blocking i/oasync i/oreactor

Event loop

Definition

An event loop repeatedly asks the operating system which sockets or timers are ready (via epoll, kqueue or io_uring) and runs the handlers for those events, never blocking on a single request.

In practice

Node.js, Netty, Python asyncio and nginx use event loops to handle very high concurrency for I/O-bound work: a waiting request costs a small object in memory rather than an OS thread with its own stack. That makes them a good fit for proxies, gateways, chat servers and other services that mostly wait on the network.

The loop runs one handler at a time, so any blocking call or CPU-heavy step stalls every other request on that loop, which shows up as sudden tail latency. CPU work must go to worker threads, and async code tends to spread through a codebase. Virtual threads and goroutines offer similar cheap waiting with a blocking programming style.

Example

A Node.js gateway holds 20,000 open connections on one loop, but a 300 ms synchronous JSON.parse of a large payload delays every other request by 300 ms.