Health checks and failover
How the balancer notices a dead server and stops sending it traffic.
Servers fail: a process crashes, a disk fills, a deploy goes wrong, a whole machine disappears. A load balancer that keeps sending requests to a dead server turns a small problem into user-visible errors for roughly one in N requests. So balancers run health checks: regular probes that decide which servers are fit to receive traffic.
Active health checks send a probe on a schedule, for example GET /health every 5 seconds with a 2-second timeout. After a number of consecutive failures (say 3) the server is marked unhealthy and removed from rotation; after a number of consecutive successes it comes back. Passive checks watch real traffic instead: if a server returns errors or times out repeatedly, it is ejected. Using both is common: active probes find dead servers quickly when traffic is low, passive ones react to real failures.
Timeline of a failure
Step 1 of 4
T+0 s: server 2 crashes
The next requests sent to it fail. 1 in 3 users see errors.
Failover is the wider idea: when something fails, traffic moves to a standby or to the survivors. For stateless servers it is automatic. For the balancer itself you run a pair or a managed multi-node service. For retries to be safe, requests that may be repeated (like placing an order) should be idempotent, which means a duplicate has the same effect as the original, usually enforced with an idempotency key. Also use connection draining on deploys: stop sending new requests to a server and let in-flight ones finish before stopping it.
Your turn
Design a /health endpoint for an order service that depends on a database and a cache. What does it check, and what does it do if the cache is down?
Stuck? Avoid removing every server because of a shared dependency.
What to remember
Health checks let the balancer stop routing to failed servers; active probes and passive error tracking complement each other.
Detection takes interval × failure threshold, so some requests may fail before removal.
Survivors need spare capacity to absorb a failed server's share.
Use idempotent requests, careful health endpoints and connection draining.