How does load balancer failover work?
Load balancer failover is the process by which a load balancer detects that a backend instance has become unhealthy and automatically removes it from the pool of eligible targets, redirecting traffic to healthy instances without manual intervention.
**Health checks** are the detection mechanism. Active health checks: the load balancer proactively sends periodic probe requests (HTTP GET to `/health`, TCP connect, or ICMP ping) to each backend. If a backend fails to respond within a timeout or returns a non-2xx status for N consecutive checks, it is marked unhealthy and removed from rotation. Passive health checks: the load balancer monitors real request responses—if a backend returns 5xx errors or times out above a threshold, it is marked unhealthy. Passive checks have lower overhead but detect failures only when real traffic is affected.
**Failover sequence**: (1) Health check detects failure. (2) Load balancer marks instance unhealthy, stops routing new requests to it. (3) In-flight requests to the failed instance may be retried (if the method is idempotent and the load balancer is configured for retries) or returned as errors to the client. (4) Traffic redistributes across remaining healthy instances. (5) If all instances fail, the load balancer returns 503 Service Unavailable.
**Session persistence (sticky sessions)** complicates failover: if sessions are pinned to a specific backend via cookie or IP hash, a backend failure breaks all sessions on that node. Mitigation: store session state externally (Redis, database) so any backend can serve any session.
**Connection draining (deregistration delay)**: before removing an instance (for scale-in or deployment), the load balancer stops routing new requests but allows in-flight requests to complete, up to a configurable timeout. This prevents 5xx spikes during rolling deploys.
**Active-passive vs. active-active**: In active-passive, the secondary load balancer is idle until the primary fails (detected via heartbeat/VRRP). In active-active, multiple load balancers share traffic via DNS round-robin or anycast. Active-active has no cold-start failover penalty but requires all nodes to handle full load.
The practical tuning levers are health check interval, consecutive failure threshold, and connection drain timeout—too sensitive causes flapping; too lenient delays failover during real outages.
Explains active vs. passive health checks, the failover sequence, and connection draining with one concrete trade-off.
Covers all of the above plus sticky session complications, active-passive vs. active-active architectures, and discusses health check tuning to prevent flapping.
Reading the answer is step one. Explaining it unprompted — under interview pressure — is what actually matters. Get AI-graded feedback on your answer with follow-up probes on your weak points.
Get Graded — Free Assessment