What Are Health Checks?
You'll learn: How load balancers continuously verify backend servers are alive and ready to serve traffic.
The Core Problem
When you have multiple backend servers behind a load balancer, some servers might crash, freeze, or become overloaded. Without a mechanism to detect this, the load balancer would keep sending requests to failed servers, causing errors for your users.
What Health Checks Do
Health checks are periodic tests that load balancers perform to verify each backend server is operational and ready to handle traffic. Think of them like a doctor taking your pulse at regular intervals—the load balancer "pings" each server to confirm it's alive and responsive.
How They Work
The load balancer sends a simple request to each backend server at regular intervals (e.g., every 5-30 seconds). This might be:
- A ping to a specific endpoint like
/health - A TCP connection attempt
- An HTTP GET request expecting a
200 OKresponse
If a server responds successfully, it stays in the healthy pool. If it fails multiple consecutive checks (e.g., 3 failures), the load balancer marks it as unhealthy and stops routing traffic to it.
Real-World Analogy
Imagine a taxi dispatcher who calls each driver every few minutes. If a driver doesn't answer three calls in a row, the dispatcher assumes that taxi is unavailable and stops sending passengers to it. When the driver starts answering again, they're back in rotation.
Why This Matters
Without health checks, your Round Robin or Least Connections algorithms would blindly route requests to dead servers. Health checks ensure traffic only goes to servers that can actually process it, improving your system's availability and reliability.
Key Takeaway: Health checks are the load balancer's way of continuously monitoring which backend servers are operational, ensuring traffic only reaches healthy servers.