Highlights

Contents

Part VI
06

Health checks and failover

We turn observations into routing and ownership changes without mistaking suspicion for proof. A reachable process may be unable to serve useful requests. We will distinguish readiness from liveness, trace failover delay, fence old writers, and reopen traffic safely.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1Availability and SPOFs2Redundancy,active-active, passive3Graceful degradation andfault tolerance4Retries, exponentialbackoff, and jitter5Timeouts, circuitbreakers, bulkheads6Health checks andfailover7Disaster recovery, RTO,and RPO8Case study: one incident

#Section 21Health checks measure a chosen capability

Heron’s application answers a process ping but has no usable database connections. A health check is a probe of a specified capability. Its result is evidence about that capability at that moment, not a complete certificate that all user requests will succeed.

A liveness check asks whether restarting a process may help it make progress. A readiness check asks whether it should receive new work now. A startup check can give initialization time before either policy applies. An expensive readiness probe that exercises every dependency on every interval can itself increase overload.

FOUR PROBES, FOUR ACTIONS: WAIT, RESTART, ROUTE, MEASUREFOUR PROBES, FOUR ACTIONS: WAIT, RESTART, ROUTE, MEASUREstartupinitialized?start other checkslivenessstill progressing?restartreadinesstake new work now?route or drainuser probedoes the operation work?measure the promise
Figure 11.25Probe purposes. A process ping alone cannot establish end-to-end success.

Include representative user-path measurements separately. If an optional recommendations service fails, readiness should not necessarily remove a score-serving replica. Conversely, an application unable to perform required writes must not advertise write readiness. Match the probe and route to the operation.

#Section 22Detection thresholds and draining

One missed probe can be a scheduling pause rather than a dead host. Several consecutive failures reduce sensitivity to a transient blip, at the cost of slower removal. An illustrative policy probes every 5 seconds and requires 3 failures. From the first relevant probe position, the modeled detection interval is 15 seconds.

Real detection depends on phase, probe timeout, and scheduling. State those assumptions rather than claiming an exact universal bound. After removing a replica from new routing, allow admitted work to finish within its deadlines. This draining phase differs from immediately terminating the process.

PROBE EVERY 5 S, REMOVE AFTER 3 FAILURES: ABOUT 15 S TO STOP NEW WORKPROBE EVERY 5 S, REMOVE AFTER 3 FAILURES: ABOUT 15 S TO STOP NEW WORK0369121518 sremove from routingdrain admitted workphase and timeout change the real number
Figure 11.26Illustrative interval model. Probe phase and timeout can change real detection timing.

Load-induced failed probes can remove useful capacity and start a cascade. Keep probes cheap enough to run under stress, but measure actual operation success elsewhere. Use recovery thresholds and gradual reintroduction to avoid route flapping. The failure test should include partial slowness, not just a process that stops instantly.

#Section 23Failover is a multi-stage operation

The active score writer disappears. Failover transfers serving or write ownership to another usable instance. Detection is only its first stage. The candidate may need to recover state, prove ownership, and receive traffic before users can complete new operations.

An illustrative trace assigns 15 seconds to detection, 10 to safe promotion, and 5 to routing. Its total is 30 seconds. A promise shorter than this needs a different mechanism, smaller measured stage costs, or a useful degraded mode during the transition.

DETECT 15 S + PROMOTE 10 S + ROUTE 5 S = 30 S OF FAILOVERDETECT 15 S + PROMOTE 10 S + ROUTE 5 S = 30 S OF FAILOVERdetect 15promote 10route 5051015202530 sa promise shorter than 30 s needs a different mechanism or a degraded mode
Figure 11.27Illustrative stages, not product timings. Parallel stages require a different critical-path calculation.
THE CANDIDATE RECOVERS STATE AND TAKES A FENCED TOKEN BEFORE ITS FIRST WRITETHE CANDIDATE RECOVERS STATE AND TAKES A FENCED TOKEN BEFORE ITS FIRST WRITE1router stopsold route2recoverauthoritative state3acquirefenced authority4ready forwrites5new commandsbeing chosen is not the same as being safe to write
Figure 11.28Ownership trace. Being selected does not itself make the candidate a safe writer.

A replica can answer reads before it is eligible for writes, if the read contract permits its state. Describe these stages explicitly in a design. That often gives a more useful recovery plan than forcing the whole service to wait for the slowest capability.

#Section 24Fencing prevents two surviving writers

The old writer is unreachable from the controller but still reachable from some clients. Promoting another writer without revoking the old one’s authority can create split brain, meaning incompatible owners act as if each has sole authority. A failure detector only suspects a peer; it cannot prove the peer stopped.

A fencing token is an increasing authority value that the protected resource checks with each operation. The new owner receives a newer token. The resource rejects writes carrying an older token even if an old process later resumes. The rejection must happen where the effect is committed.

THE STATE STORE ACCEPTS TOKEN 34 AND REJECTS THE OLD OWNER'S 33THE STATE STORE ACCEPTS TOKEN 34 AND REJECTS THE OLD OWNER'S 33old owner (33)new owner (34)highest 3433token values are illustrative; the resource must do the check
Figure 11.29Fencing concept. Token ordering must come from the ownership protocol and the protected resource must enforce it.

A lease without resource-side enforcement can leave a paused process acting on expired beliefs. A distributed lock that every caller merely promises to respect has the same risk. The coordination unit supplies the algorithm; this unit insists that failover test include a delayed old writer returning after promotion.