Backend development

Stage 1 · Lesson 6 of 10

The event loop

Your language and how HTTP works

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

  • CoursePaid
    Grokking JavaScript Fundamentals

    Design Gurus · Beginner · $50

    JavaScript itself in a sensible order: scope, closures, promises and async code

  • GuideFree
    Node.js Learn

    OpenJS Foundation · Beginner

    Official guides on the event loop, async work, the http module and environment variables

Practise

  • Your language track: small exercises with free mentor feedback on idiomatic code

Keep handy

  • Read Everyday Types and Narrowing first, then keep it open while you write TypeScript

  • Read the HTTP overview, methods, headers and status code pages until they feel obvious

Also worth your time

Mark this stage as not done?