Stage 1 · Lesson 6 of 10
The event loop
runs your on a single thread, so it does one thing at a time. is the part that decides what runs next. It picks up a (a function waiting to run) when a timer fires or when a network or file call finishes.
Meanwhile, a library called libuv does the actual network and file work in the background. After each callback, Node.js first runs all waiting callbacks, called microtasks, before the loop moves on. So a resolved promise runs before a setTimeout of 0.
This design lets one process hold thousands of open connections cheaply, as long as every callback finishes quickly.
Common trapheavy CPU work done in one go, such as parsing a 50 MB JSON file, a large sort or synchronous crypto: while it runs, every other request waits. Move that work to worker_threads or a background job.
A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking JavaScript Fundamentals
Design Gurus · Beginner · $50
JavaScript itself in a sensible order: scope, closures, promises and async code
- GuideFreeNode.js Learn
OpenJS Foundation · Beginner
Official guides on the event loop, async work, the http module and environment variables
Practise
Keep handy
Also worth your time
The DNS, TCP, TLS and HTTP steps behind every request your backend will handle