The Event Loop — Senior¶
At senior level, focus on this question:
Why does a single slow, synchronous callback stall every other task sharing the same event loop?
Prerequisite: middle.md.
The loop is single-threaded; a callback runs to completion before the next¶
This is precisely the same "cooperative scheduling" issue from the Async/Await concurrency-model page's middle.md, made concrete at the event-loop mechanism level: because the loop is single-threaded and runs one callback to completion before moving to the next, any callback that blocks synchronously (a synchronous file read, a CPU-heavy computation, a non-async database driver call) freezes the entire loop — every other task, regardless of how ready or fast it would otherwise be, is starved for that callback's entire duration.
Diagnosing this in practice¶
🎯 Senior takeaway: this single-threaded, run-to-completion property is the direct mechanistic reason why "never call a blocking/synchronous operation inside async code" is the single most important async programming rule — a violation doesn't just slow down the specific request; it stalls every concurrent request the event loop is currently servicing, converting a localized slow operation into a system-wide outage for the duration of that one blocking call.
Test yourself¶
- Why does the event loop's single-threaded, run-to-completion design mean one slow callback affects every other pending task, not just its own request?
- What symptom would you look for in production monitoring to diagnose this specific bug pattern?
- Why is this bug pattern often intermittent/hard to reproduce in testing, but severe in production?
Continue to professional.md to compare io_uring's different architecture against epoll's readiness-based model.