Health Checks and Circuit Breaking
Active vs passive health checks, HTTP 200 probes, TCP checks, intervals and thresholds, and circuit breaker patterns.
Overview
Overview Health checks are the mechanism by which a load balancer determines whether a backend is capable of serving traffic. Without them, requests are sent to dead or degraded backends, resulting in timeouts and errors that the client experiences directly.
Active health checks are periodic requests the load balancer sends to each backend independently of real traffic. A typical HTTP active check sends a GET to /health every 10 seconds. If the backend returns 200 within a timeout window, it is considered healthy. After a configurable number of consecutive failures (the unhealthy threshold — typically 2 or 3), the backend is removed from the rotation. After a number of consecutive successes (the healthy threshold — typically 2), it is reinstated. TCP active checks simply test that the port accepts a connection, which is faster but verifies less.
Passive health checks (circuit breakers) infer health from real traffic. The load balancer or proxy watches response codes and latency on production requests. If a backend returns 5xx errors above a threshold, it is ejected. Envoy's outlier detection is the canonical implementation: if a host returns 5 consecutive 5xx responses, it is ejected for a base ejection time (e.g., 30 seconds), exponentially backing off on repeated ejections.
The circuit breaker pattern has three states: Closed (normal, requests flow through), Open (backend is unhealthy, requests are short-circuited with an error), and Half-Open (a probe request is allowed through to test recovery). Failing fast with a circuit-breaker error is better than letting requests queue up against a dead backend, exhausting thread pools and propagating the failure upstream.
Combining active and passive checks is best practice: active checks catch total failures quickly; passive outlier detection catches partial degradation on a subset of requests.
Key concepts
- Active Health Check
- Passive Health Check (Outlier Detection)
- Unhealthy / Healthy Threshold
- Circuit Breaker States
- Liveness vs Readiness (Kubernetes)
Interview questions
- How do you configure health checks on an AWS ALB target group, and what makes a good /health endpoint?
- Explain the circuit breaker pattern and how Envoy implements outlier detection.
Sign up free to read the full topic
More Networking topics
Start free on Cariara · Coding problems · System design studio