Level 3 · Advanced Under the Hood¶
Goal: understand why Node behaves the way it does under load, and use that knowledge to build services that stay fast and safe. Level 2 gave you a working API; this level explains what's happening beneath it — the exact order of the event loop, how data flows through streams without exhausting memory, what a Buffer really is — and then uses those mechanics to add capabilities: CPU work off the main thread, all cores in use, a shared cache, real-time connections, and file uploads.
Many lessons here include measurements taken while writing them (timings, memory, event loop delay). Your numbers will differ by machine; the shape of the results is what matters, and re-running the experiments yourself is part of the lesson.
Modules¶
- The Event Loop in Depth — phases, nextTick vs microtasks (and why ESM differs), starvation, measuring loop delay
- Streams & Backpressure —
write()returning false,pipeline, and streaming vs loading everything, measured - Buffers & Binary Data — bytes vs characters, shared slices, and a length-prefixed protocol parser
- Worker Threads & Child Processes — keeping CPU work off the loop, pools, and safely running other programs
- Clustering & Using Every Core —
node:cluster, how connections are handed to workers, and when containers replace it - Caching with Redis — cache-aside, invalidation, stampede protection, and key design
- WebSockets — the upgrade handshake, a
wsserver, heartbeats, auth, and scaling out - File Uploads — multipart parsing, limits, content sniffing, and direct-to-storage uploads
- Security for Node Services — OWASP risks in Node terms, ReDoS, prototype pollution, SSRF, and the supply chain
- Project — A Real-Time Chat App — authenticated WebSocket rooms with history, rate limits, and tests
What you need before starting¶
- Levels 1 and 2. Lessons refer back to the tasks API and its middleware.
- Comfort reading short C-like pseudocode: a few "How It Actually Works" sections sketch libuv internals.
- Optional: a local Redis server for lesson 06 and the project's scale-out exercise. Every runnable example in this level works without one; where Redis is required, the lesson says so explicitly.