Engineering Note

Establishing correlation IDs, structured JSON telemetry, health probes, and meaningful alerting thresholds for high-availability systems.

Correlation IDs Across Request Boundaries

When debugging a production incident across microservices or asynchronous queues, individual log lines are useless without context. Attach a unique x-request-id or correlation ID at the edge gateway and propagate it across all downstream database calls, message queues, and external requests.

Format all production logs as structured JSON containing timestamp, correlationId, level, event, and relevant domain identifiers (tenantId, userId), enabling fast grep, aggregation, and filtering in centralized log aggregators.

Liveness vs. Readiness Probes

Distinguish between liveness checks (is the Node.js process alive and event loop unblocked?) and readiness checks (can the service successfully communicate with PostgreSQL and Redis?).

Failing a readiness probe removes the instance from the load balancer routing pool to protect users, while failing a liveness probe triggers an automated container restart.

Related Engineering Notes

/production-ready-apis

Designing Production-Ready APIs

A comprehensive guide to designing resilient REST APIs: deterministic contracts, idempotency keys, RFC 7807 problem details, and defense-in-depth rate limiting.

/avoiding-n-plus-one

Avoiding N+1 Database Queries

Techniques for eliminating silent database query amplification in ORMs through query planning, batching, and join projection.

← Back to engineering notes