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. Node.js From Zero · 12 minWhat 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. Node.js From Zero · 16 minThe 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
- 3. Node.js From Zero · 13 minFiles, Paths and Buffers
fs and fs/promises, paths, buffers and encodings, reading and writing safely, and watching files.
- 4. Node.js From Zero · 16 minStreams and Backpressure
Readable, writable and transform streams, pipeline, backpressure shown with real memory numbers, and when streams beat reading whole files.
- 5. Node.js From Zero · 14 minAn 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
- 6. Node.js From Zero · 15 minExpress and Fastify: Middleware, Routing and Validation
The middleware idea, Express 5 and Fastify side by side, error handling middleware, validation with schemas.
- 7. Node.js From Zero · 15 minErrors, Logging and Graceful Shutdown
Operational versus programmer errors, uncaught exceptions, structured logs, health checks, and shutting down without dropping requests.
- 8. Security for Developers · 15 minAPIs 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
- 9. Node.js From Zero · 16 minConcurrency: 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.
- 10. Node.js From Zero · 15 minTesting, Performance and Production Habits
node:test, profiling with --cpu-prof, memory leaks, configuration, Docker basics, and a production checklist.
- 11. Backend in Depth · 15 minValidation 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
- 12. Node.js From Zero · 16 minNode.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.