Event Driven Concurrency
Event driven concurrency flips the thread per request model. Instead of blocking a thread while waiting, the program registers interest in events and lets a single event loop dispatch work as those events become ready. Node and Nginx are famous examples.
At the core sits a readiness mechanism such as epoll or kqueue. The loop asks the kernel which sockets are ready to read or write, then runs short callbacks or resumes coroutines for exactly those sockets. Because no thread parks on a slow socket, one thread can juggle tens of thousands of connections.
The discipline is strict:
- Never block Any long synchronous call freezes the whole loop and stalls every connection.
- Offload CPU work Heavy computation must move to a worker pool so the loop stays responsive.
- Compose carefully Logic splits across callbacks, which async await and promises tame into readable chains.
The payoff is dramatic for IO bound workloads where most time is spent waiting on the network. The risk is that a single careless blocking line, like a synchronous file read or a tight loop, degrades latency for thousands of users at once.
Key idea
One event loop multiplexes thousands of connections by reacting to readiness events, but a single blocking call can stall everything.