
Becoming a Node.js Backend Engineer: From the Event Loop to Scale
- كاتب موثّق
محتويات المقال
The common misconception
worker_threads for CPU-heavy JavaScript, cluster or a process manager to run several processes across cores, and child_process for other programs. "No matter what you do" is wrong: there's a lot you can do, and learning it is the job.
What a Node.js backend engineer really does
The stages from zero to senior
Stage 1: JavaScript and the event loop Learn: JavaScript (closures, objects, promises, async/await, errors), then Node.js itself: ES modules, npm andpackage.json,fs,http,events, environment variables, and how the event loop runs callbacks and microtasks. Learn the difference between blocking and non-blocking calls early. Postpone: frameworks, TypeScript and Docker. Build: a CLI that reads a large log file as a stream and prints statistics, then a small JSON server onnode:http. Ready when: you can explain why anawaitin one request doesn't stop other requests but a longwhileloop does. About 3–5 months.Stage 2: TypeScript and HTTP APIs Learn: TypeScript in strict mode, running it with Node's type stripping and checking it with tsc --noEmit, then Express 5 or Fastify: routing, middleware, error handling, runtime validation, REST conventions and status codes, logging, and tests with the built-innode:test. Postpone: NestJS and microservices. Build: a tasks API with validation, central error handling and tests for every endpoint. Ready when: no request reaches your logic without validation, and CI runs the type check and tests. About 2–3 months.Stage 3: Databases with SQL and an ORM Learn: SQL in PostgreSQL (joins, indexes, constraints and transactions), raw queries through the pgdriver with , then an ORM such as Prisma, Drizzle or TypeORM with migrations. Add connection pooling, pagination, the N+1 problem and Redis for caching. Postpone: choosing a NoSQL store just to avoid learning SQL. Build: move the tasks API to PostgreSQL with raw SQL, then rewrite one module with an ORM and compare the queries it sends. Ready when: you can readEXPLAINfor a slow query and wrap a multi-step write in a transaction. About 3–5 months.Stage 4: NestJS, auth and async work Learn: NestJS modules, providers and dependency injection, controllers, pipes for validation, guards for authorization and interceptors; sessions or tokens; a Redis-backed job queue for slow work; and streams with for uploads and exports. Postpone: CQRS and event-sourcing libraries. Build: rebuild the API in NestJS with login, a queued email job and a CSV export that streams instead of loading everything into memory. Ready when: you can explain what Nest's dependency injection does that you wired by hand in stage 2, and a large export keeps memory flat. About 3–4 months. Stage 5: Scale and senior skills Learn: measuring event loop delay with perf_hooks, CPU profiles and heap snapshots, memory leaks, a pool of long-lived worker threads for CPU work, several processes or containers behind a load balancer, graceful shutdown, timeouts, retries and idempotency, tracing with OpenTelemetry, and rate limiting. Postpone: nothing now; go deep where your team hurts. Build: load-test your API, find a blocking function in a CPU profile, move it to a worker pool, run several instances and add tracing. Ready when: you can explain an incident from metrics and profiles and fix its cause, not just add servers. Expect 6–12 months.
Books for each stage
Common mistakes
Calling synchronous APIs such as readFileSyncinside request handlers.Starting a new worker thread for every task instead of keeping a pool of long-lived workers, as the Node.js docs advise. Using an ORM without understanding the SQL it sends. Adding servers to fix slowness before finding the code that blocks the event loop. Reading whole files or query results into memory when a stream would do.
How to show your work
docker compose file that starts it with PostgreSQL and Redis, and CI that runs the type check and tests. Include a load-test script and a short write-up of one blocking function you found in a profile, with event loop delay before and after the fix. It shows more than a list of frameworks.
Next on ReadIn
Stage 1: the event loop, tasks and microtasks and promises are not threads, from the JavaScript Under the Hood path. Stage 2: the backend fundamentals roadmap. Stage 3: the SQL Performance path and offset vs keyset pagination. Stage 4: rate limiting against credential stuffing and the Secure by Default path. Stage 5: average latency hides slow requests, retries can make outages worse and the full-stack TypeScript roadmap if you want the frontend too.
Key takeaways
Node.js runs your JavaScript on one thread per process, but I/O happens in the kernel and a worker pool, which is why it serves many clients with few threads. CPU-heavy work does block the event loop; move it to worker threads, separate processes or a job queue. Learn JavaScript and the event loop first, SQL before an ORM, and Express before NestJS. Measure event loop delay and profile before you add servers or plan a rewrite.
التعليقات (0)