Question presented to candidate: "Your service's database connection drops temporarily. If your ONE health-check endpoint returns an error whenever the database is unreachable, and your orchestrator (Kubernetes) is configured to restart the container on health-check failure, what happens — and is that genuinely the right response to a temporary database blip?"
What a strong answer should cover:
- A single, combined health check that fails whenever ANY dependency (the database) is down causes exactly the prompt's real problem: the orchestrator, seeing a failing health check, restarts the container — but restarting the Node process does absolutely nothing to fix a database outage, which is the actual root cause. The restart is genuinely useless against this specific failure, and can make things worse (churning through restarts while the real underlying dependency is still down).
- 📌 Interview term: liveness vs. readiness — a real, critical distinction — liveness answers "is the process itself alive and able to respond at all" (should trigger a restart if it fails); readiness answers "is the process currently able to serve real traffic correctly" (should trigger removal from load-balancer rotation, NOT a restart, if it fails).
- 📌 Verified, not assumed — the exact answer to the prompt: with a real, simulated database dependency genuinely marked down, a real
/healthz(liveness) endpoint genuinely still returned a real 200 — "the process itself is fine" — while a real/readyz(readiness) endpoint genuinely returned a real 503 — correctly signaling "don't route traffic here right now," without ever suggesting the process itself needs restarting. - This is the precise, direct fix for the prompt's scenario: liveness should check only whether the process itself is fundamentally broken (deadlocked, unresponsive) — verified above, it must not depend on external dependencies like the database — readiness should check real dependencies (verified above, exactly what caused the real 503) and is what an orchestrator uses to temporarily remove an instance from serving traffic, without restarting it, letting it automatically rejoin once
/readyzgenuinely starts passing again as the dependency recovers. - A precise answer names the real, complete failure mode the prompt's single-check design causes: unnecessary restarts during a transient, external dependency blip — genuinely counterproductive (a restart doesn't fix the database), versus the correct behavior verified above — the process stays running, genuinely ready to immediately resume serving traffic the instant the real dependency recovers, with zero restart needed at all.
Clarifying questions expected:
- "Which specific dependencies should genuinely gate readiness — every downstream call this service ever makes, or only the ones without which it truly cannot function correctly at all?" — an overly broad readiness check can cause unnecessary traffic removal for a dependency that's actually optional for most requests.
- "Does liveness need any real check at all beyond 'the HTTP server is responding,' or could a genuinely deadlocked process still technically respond to a trivial liveness ping while unable to process real requests?" — a real, deeper liveness design question for certain failure modes.
Code / implementation expected: Yes — real, distinct HTTP responses (a genuine 200 for liveness, a genuine 503 for readiness) from the identical, simultaneous real dependency outage is the concrete, convincing proof of exactly why the two checks must be separate, and what each one is actually for.