Screens

Public Track/t/:slug

/ node-runtime-internals

Node.js runtime internals

From the call stack to production profiling: how Node.js schedules work, manages memory and where latency comes from.

Topics
12
Lessons
27
Quiz questions
65
Study time
≈4h

Only the original Track can be forked.

EnglishPublic Fork

After this Track you can
  • Trace a delayed callback through the event loop.
  • Read a heap snapshot and identify what keeps an object alive.

01Route

Every Topic opens the next ones.

12 Topics in dependency order. Select a Topic on the map to see what it covers.

Select a Topic to preview it

02Lesson

Read a little. Answer. Remember.

This is how the first Lesson of the Track opens. In your own copy you answer the Quiz and see the right answer with an explanation.

The first Lesson

Its opening and one question from its Quiz. You can read the whole Lesson now, without signing in.

L01 · 6 min

Inside a stack frame

setTimeout(fn, 100) does not promise that fn runs after 100 ms. It promises that fn will not run sooner.

Node.js keeps timers in a min-heap ordered by expiry time. At the start of each loop iteration, the timers phase runs every callback whose time has passed. Then the loop moves on to pending callbacks, poll, check and close. A timer that expires while the loop is busy elsewhere waits for the next pass.

A timer expires during a synchronous loop. Why does its callback not interrupt the loop?
  1. The timer resets whenever the loop iterates.
  2. The callback passed to setTimeout waits for the loop to return.
  3. The timer delay starts when the loop returns.
  4. The timer drops the callback when it misses its deadline.

Start the Track to answer and see the explanation.

  • Short Lessons

    About 9 min each: theory, code and diagrams, one Block at a time.

  • Quizzes

    65 questions to check yourself. Every answer comes with an explanation.

  • Mastery

    A level from 0 to 4 for every Topic. You earn it with answers.

  • Reviews

    A Topic comes back after 1, 3, 7, 16 and 35 days.

03Course syllabus

What the Track covers.

Open a Topic to see its Lessons. Any Lesson can be read without signing in.

  1. T01Call stack and execution contextsFollow a function call from entry to return.24 min
  2. T02Event loop phasesTrack a callback through one turn of the loop.34 min
  3. T03Microtasks and promise jobsPredict when queued callbacks run.28 min
  4. T04Timers and schedulingMeasure the gap between a timer’s scheduled and actual execution.30 min
  5. T05Async functions under the hoodTrace how an async function suspends and resumes.17 min
  6. T06Streams and backpressureControl the rate of data moving between streams.27 min
  7. T07Worker threadsMove CPU-bound work off the event loop.22 min
  8. T08Garbage collection in V8Connect allocation patterns to collection pauses.24 min
  9. T09Memory leaks and heap snapshotsFind the reference that keeps an object alive.20 min
  10. T10Hidden classes and inline cachesInspect how object shapes affect property access.19 min
  11. T11JIT tiers: Ignition to TurboFanFollow a hot function through the compiler tiers.

    No Lessons yet.

  12. T12Profiling in productionUse a CPU profile to explain a slow request.

    No Lessons yet.

04Start

Public Fork

Only the original Track can be forked.

Only the original Track can be forked.