Quiz Entry - updated: 2026.07.05
What is the Node.js event loop?
The event loop lets a single Node.js thread serve many clients by pulling events off a queue and running each handler one at a time.
How it works:
- HTTP requests and system events enter an event queue
- The event loop takes events from the queue one at a time
- Each event is processed (handler function runs)
- Loop waits for next event when queue is empty
Important implications:
- Single event queue for all clients (like browser JavaScript)
- Keep handlers fast - slow handlers block all other requests
- Long-running tasks should be async (database, file I/O)
Diagram:
HTTP Requests → Event Queue → Event Loop → Process Event
System Events ↗ ↓
Wait for next
Tip: Never do CPU-intensive work in a request handler - it blocks the entire server.
Go deeper:
Node.js: The event loop, timers, and process.nextTick() — official breakdown of the loop's phases and why slow handlers stall everything.