Node.js Guide: Event Loop, Streams, Servers and Production

Node.js is simple until the event loop, streams and errors show up in production. This guide follows the Node.js From Zero series from how Node runs your code to how you ship and run it safely.

Every example was run on Node 22 and the real output is shown, including the memory and timing numbers.

Who it is for: Back-end and full-stack developers using Node.js, and candidates preparing for Node.js interviews.

12 lessons · Published by Jainik · Last updated

1. How Node runs your code

  1. 1. Node.js From Zero · 12 min
    What Node.js Is and How It Runs Your Code

    V8, libuv and the runtime, the single thread and what it means, modules (ESM and CommonJS), npm, and running your first script.

  2. 2. Node.js From Zero · 16 min
    The Event Loop: Timers, Promises and the Poll Phase

    The loop phases, microtasks versus macrotasks, process.nextTick, setImmediate, and how a blocked loop freezes everything. Traced and run.

2. Files, streams and servers

  1. 3. Node.js From Zero · 13 min
    Files, Paths and Buffers

    fs and fs/promises, paths, buffers and encodings, reading and writing safely, and watching files.

  2. 4. Node.js From Zero · 16 min
    Streams and Backpressure

    Readable, writable and transform streams, pipeline, backpressure shown with real memory numbers, and when streams beat reading whole files.

  3. 5. Node.js From Zero · 14 min
    An HTTP Server From Scratch

    The node:http module, routing by hand, reading bodies, headers and status codes, then why a framework helps.

3. Frameworks and reliability

  1. 6. Node.js From Zero · 15 min
    Express and Fastify: Middleware, Routing and Validation

    The middleware idea, Express 5 and Fastify side by side, error handling middleware, validation with schemas.

  2. 7. Node.js From Zero · 15 min
    Errors, Logging and Graceful Shutdown

    Operational versus programmer errors, uncaught exceptions, structured logs, health checks, and shutting down without dropping requests.

  3. 8. Security for Developers · 15 min
    APIs and Servers: SSRF, File Uploads, Rate Limits and Misconfiguration

    Server-side request forgery, unsafe file uploads, missing rate limits, verbose errors, CORS mistakes and the OWASP API Top 10, each with a small example and a fix.

4. Scaling, testing and production

  1. 9. Node.js From Zero · 16 min
    Concurrency: Promises, Worker Threads, Clusters and Child Processes

    Promise.all and limits, CPU work in worker_threads, cluster and why containers often replace it, and a timed comparison.

  2. 10. Node.js From Zero · 15 min
    Testing, Performance and Production Habits

    node:test, profiling with --cpu-prof, memory leaks, configuration, Docker basics, and a production checklist.

  3. 11. Backend in Depth · 15 min
    Validation at the Edge: Schemas, DTOs and Trusting Nothing

    Check input where it enters the API, share schemas with the frontend, and keep validation errors apart from business-rule errors.

5. Interview practice

  1. 12. Node.js From Zero · 16 min
    Node.js Interview Questions With Model Answers

    Event loop, streams, errors, scaling and security questions with model answers.

More reading orders are on the guides page, and every series is listed on the home page.