Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Courses/Reliability and Failure
Lesson 4 of 24

Health checks and failover

Detect failure quickly and correctly, then move traffic without making things worse.

15 min read

Liveness versus readiness

A liveness check asks whether the process should be restarted: is it deadlocked or wedged? A readiness check asks whether it should receive traffic right now: has it warmed its cache, connected to the database, finished starting up? Mixing them causes trouble. If liveness depends on the database, a database blip restarts every instance at once, turning a short dependency outage into a full cold start of your fleet.

Shallow and deep checks

A shallow check (return 200 if the process is up) misses gray failures. A deep check that calls every dependency is accurate but dangerous: if a shared dependency fails, every instance reports unhealthy and the load balancer removes them all, even though they could still serve cached or degraded responses. A good compromise checks local resources deeply (disk, thread pool, memory) and reports dependency health as a signal for degradation rather than for removal. Many load balancers fail open when every target is unhealthy, sending traffic anyway, precisely to avoid this trap.

Detection time is a trade-off

Detection time is roughly interval x failure threshold. Checking every 10 seconds with 3 failures required means up to 30 seconds of errors before an instance is removed. Faster checks and lower thresholds detect sooner but cause flapping: an instance under brief GC pressure is removed, its load moves to the others, they slow down and are removed too. Use a lower threshold for removal than for re-adding, and combine active checks with passive signals such as the error rate of real traffic (outlier detection).

Failover for stateful components

Stateless instances simply drop out of rotation. Stateful ones need a failover: promote a database replica, move a leader, repoint clients. Each step takes time, typically 10 to 60 seconds for a managed database, plus DNS or connection-pool refresh. During failover, writes fail, so callers need retries. In SystCode, the Feedback panel's failure tests kill one component at a time; a design passes only if traffic finds a healthy path within the scenario's recovery target.

Key takeaways

  • Separate liveness (restart me) from readiness (send me traffic)
  • Deep health checks on shared dependencies can remove every instance at once
  • Detection time equals check interval times failure threshold; tune it against flapping
  • Stateful failover takes tens of seconds, so callers must retry through it

Sign in to track lessons and earn badges.

A taxonomy of failure modesTimeouts and deadlines

Coming up

Course: 0/24 lessons · 0/10 challenges0%

Build it on the canvas, pass the review (70+) and mark it complete to count it toward the course badge.

  1. 1/10Design a Web CrawlerUse per-host timeouts, bounded retries and bulkheads so one slow or hostile site never stalls the whole crawl.Medium
  2. 2/10Design a Weather API ProxyCache provider responses and serve stale data behind a circuit breaker when the paid upstream API is down.
Easy
All 10 challenges →