Node.js Production Engineering 21 — Reliability và Overload Control
Giữ service ổn định khi dependency chậm hoặc traffic tăng: deadline, cancellation, concurrency budget, load shedding, retry, circuit breaker và graceful shutdown.
Filter/Tag
42 entries
Giữ service ổn định khi dependency chậm hoặc traffic tăng: deadline, cancellation, concurrency budget, load shedding, retry, circuit breaker và graceful shutdown.
Xử lý upload, export và transform dữ liệu lớn với memory hữu hạn: stream.pipeline, highWaterMark, abort, size limit, integrity, cleanup và observability.
Điều tra Node.js bằng evidence: event-loop delay, CPU profile, heap snapshot, RSS/native memory, diagnostic report, trace correlation và controlled experiment.
Cô lập tenant xuyên HTTP, PostgreSQL RLS, cache, queue và object storage; kiểm soát authorization, noisy neighbor, migration, audit và incident response.
Ghép toàn series thành Order Platform thực tế: invariant, API, PostgreSQL, payment webhook, outbox, stream export, overload, observability, rollout và incident drills.
Xử lý webhook đáng tin cậy: raw-body signature, replay defense, inbox, duplicate/out-of-order event, payment state machine, reconciliation và audit.
Hiểu NestJS giải quyết bài toán gì, dựng TaskFlow API bằng NestJS 11 và TypeScript strict, rồi lần theo một request từ bootstrap tới controller.
Workflow Node/package manager trong terminal: node/npm/pnpm version, corepack, npm run, pnpm exec/dlx, npm ci, frozen lockfile, env vars, npm ls và pnpm why.
Hiểu runtime module trước compiler: NodeNext vs Bundler, package type/exports, import type, file extension, dual-package hazard và cách debug resolution.
Thiết kế background jobs có thể vận hành: BullMQ, delivery semantics, idempotency, transactional outbox, retry có jitter, dead-letter workflow, backpressure và graceful shutdown.
Thiết kế GraphQL như một API contract: schema, resolver lifecycle, nullability, DataLoader, cursor pagination, authorization, query-cost control, schema evolution và observability.
Chọn polling, SSE hay WebSocket từ product contract; triển khai delivery, reconnect, authentication, presence, backpressure, scale-out và graceful draining với Node.js.
Tách service có kiểm soát: bounded context, data ownership, gRPC/Protobuf, deadline propagation, retry budget, outbox, saga, mTLS, observability và chiến lược migration.
Xây observability từ user journey: SLI/SLO, error budget, structured logs, metrics cardinality, distributed traces, sampling, Collector topology và incident workflow.
What Yarn v1 fixed about 2016-era npm: deterministic installs, the yarn.lock format, parallel fetching and offline cache — and why it is now frozen in maintenance mode.
The default package manager, demystified: package-lock.json anatomy, hoisting and phantom dependencies, npm ci vs npm install, lifecycle scripts, npx, .npmrc and scoped registries.
What a package manager actually does under npm install — resolve, fetch, link — plus package.json, semver ranges, the registry, and why the lockfile is the most important file in your repo.
Dùng Redis 8 có chủ đích: cache consistency, stampede control, Pub/Sub và Streams, rate limit atomic, distributed lock với fencing, session, BullMQ và vận hành production.
Thiết kế NestJS 11 như một runtime kiến trúc: module boundary, DI scope, request lifecycle, validation, policy guard, interceptor, error contract, Prisma 7, testing và graceful shutdown.
Thiết kế identity cho Node.js production: threat model, JWT validation, access/refresh token, atomic token-family rotation đa thiết bị, cookie/BFF, OIDC Authorization Code với state, nonce, PKCE và authorization theo resource.
Hiểu đường đi của một tác vụ qua V8, libuv và event loop; từ đó kiểm soát concurrency, stream, worker thread, bộ nhớ và độ trễ production.
Thiết kế Express 5 như một request pipeline có thứ tự, validation boundary, error contract, proxy trust và graceful shutdown kiểm chứng được.
Theo một HTTP request từ wire tới Node.js handler, rồi thiết kế API contract có giới hạn, timeout, cache, streaming, CORS và graceful shutdown rõ ràng.
Thiết kế data layer đúng khi có concurrency: query shape, index, pool, transaction, pagination, repository, MongoDB và cache contract cho API.
Thiết kế ranh giới module, dependency injection, transaction, cache, queue và resilience để codebase Node.js tiếp tục thay đổi an toàn khi sản phẩm và đội ngũ cùng lớn lên.
Thiết kế authentication và API security theo threat model: password hashing, session/JWT, cookie, OAuth/OIDC, authorization và defense-in-depth.
Xây quy trình tối ưu Node.js dựa trên SLO, workload, percentile, profiling, event-loop health, query plan, worker pool, cache, memory và capacity thay vì phỏng đoán.
Thiết kế test portfolio theo rủi ro cho domain, HTTP, database, contract, dependency failure, concurrency và migration; đồng thời kiểm soát coverage, flakiness và thời gian phản hồi CI.
Biến source code thành một service vận hành được: image bất biến, config và secret, probe, graceful shutdown, migration, rollout, rollback, CI/CD và quan sát deployment.
Thiết kế modular monolith theo bounded context, giữ dependency rule bằng fitness function, ghi ADR và chỉ dùng outbox, saga, CQRS hay microservice khi constraint đòi hỏi.
Prisma ORM 7 từ cấu hình ESM, generated client và driver adapter tới migration an toàn, query có kiểm soát, transaction giữ invariant, pooling, observability và test production.
Thiết kế PostgreSQL 18 cho production: invariant trong schema, index theo workload, đọc EXPLAIN, transaction đúng khi đồng thời, keyset pagination, pooling, MVCC và vận hành từ Node.js.
Capstone: treat the network as unreliable — socket error codes, mandatory error handlers, timeouts at every layer, retries with backoff & jitter, reconnecting clients, and a layered debugging toolkit with Node.js + TypeScript.
How Node handles thousands of connections on one thread, scaling with cluster and worker_threads, load balancers, timeouts, keep-alive, graceful shutdown, and client pooling — bilingual with TypeScript examples.
TCP is a byte stream with no message boundaries — learn delimiter vs length-prefix framing, stateful decoders, and backpressure with socket.write() and drain in Node.js + TypeScript, bilingual.
Why plaintext HTTP is unsafe, how TLS encrypts and authenticates, the handshake, certificates, self-signed dev certs, node:tls and node:https servers — bilingual with runnable TypeScript examples.
WebSockets for real-time push: HTTP limits, the upgrade handshake, ws server + client in Node.js + TypeScript, heartbeats, and when to use SSE/polling instead — bilingual with exercises.
HTTP is text over TCP: raw request/response anatomy, a minimal socket responder, node:http createServer, reading bodies, Content-Length vs chunked, keep-alive — bilingual with runnable TypeScript examples.
How DNS turns hostnames into IP addresses, the resolution chain from your app to authoritative servers, Node.js dns.lookup vs dns.resolve, record types, TTL caching, and dual-stack IPv4/IPv6 — bilingual, with runnable TypeScript examples.
UDP for Node.js + TypeScript: connectionless datagrams with node:dgram, when UDP beats TCP, the 65507-byte limit, no backpressure, and beginner pitfalls — bilingual, with runnable examples.
Open real TCP sockets in Node.js: the three-way handshake, echo server + client with createServer/createConnection, socket events, graceful close, and common pitfalls — bilingual with exercises.
The mental model every network programmer needs: the TCP/IP layers, IP addresses & ports, packets, and the client/server model — with a tiny Node.js + TypeScript demo, bilingual, plus exercises.