Ch. 6 · Node.js

Node.js Health Checks and Service Readiness

Node.js Health Checks and Service Readiness. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readadvancedupdated Oct 3, 2026

Liveness asks whether the process should restart; readiness asks whether it should receive work. Dependency health may affect readiness without implying a dead process.

Before you start

You should know JavaScript promises, asynchronous errors and the distinction between a process and a request. When following a server example, identify the resource owner and the point where work completes. Try experiments locally with bounded input instead of assuming production traffic behaves like a single request.

The practical goal is to reason through this situation: A temporary database outage can make a service unready while it remains alive. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.

Step-by-step walkthrough

Step 1: Define each question

Liveness asks whether restart is useful; readiness asks whether the instance should currently receive traffic.

Step 2: Model dependency failure

A temporary shared database outage may prevent serving without making every process irrecoverably dead.

Step 3: Include lifecycle state

Startup and shutdown should affect readiness. Keep liveness narrow enough to avoid restart storms.

Worked scenario

A temporary database outage can make a service unready while it remains alive.

During a database outage, instances remain alive but become unready under a serving policy requiring the database. Restarting all of them adds reconnect traffic without restoring the dependency. When shutdown starts, readiness becomes false before in-flight work drains, so new traffic can be routed elsewhere.

Common mistake

Restarting every instance during a shared dependency outage can amplify disruption.

Verify the behavior

Test startup, dependency failure, recovery and shutdown. Verify probe responses reflect serving ability without unnecessary mass restarts.

Interview exercise

Design separate probes.

Answer and reasoning

Keep liveness narrow and readiness aligned with actual serving ability, including startup and shutdown states.

Continue learning

Compare the scenario with the Node.js interview questions and test your understanding with the Node.js MCQs. For terminology and implementation details, consult the reference material.

More in Node.js

read ✓Node.js · hard

Node.js Clustering Across CPU Cores

Use cluster to run several workers on all cores, restart crashed workers, and understand shared-port and shared-state limits.

~2 min readread →
read ✓Node.js · hard

Node.js Password Hashing with scrypt

Store passwords as salted hashes with a slow key-derivation function, and compare candidates in constant time.

~2 min readread →
esc