Load Balancers: Algorithms & High Availability
The component that decides, per request, which of many backend servers actually handles it — and keeps working when some of them don't.
Beginner
| Capability | What it means in practice |
|---|---|
| Scalability | Adding a new backend server to the pool immediately gets it traffic — capacity grows without clients changing anything. |
| Availability | Requests are automatically routed away from servers that fail health checks, without any human intervention. |
| Performance | Requests can be sent to the least-loaded server, reducing tail latency versus a client hitting an already-overwhelmed server. |
| Algorithm | How it decides | Good fit |
|---|---|---|
| Round-robin | Cycles through servers in order. | Servers with roughly equal capacity and uniform request cost. |
| Weighted round-robin | Like round-robin, but stronger servers get proportionally more requests. | A mixed pool of server sizes. |
| Least connections | Routes to the server currently handling the fewest active connections. | Requests with widely varying processing time. |
| Least response time | Routes to the server with the best recent response time. | Latency-sensitive traffic. |
| IP hash / URL hash | Routes based on a hash of the client IP or requested URL, so the same client/resource consistently lands on the same server. | Stateful backends that benefit from a client sticking to one server (session affinity), or maximizing cache hit rate per server. |
| Service | Why it lives here |
|---|---|
| Health checking | A heartbeat/liveness check to each backend lets the load balancer stop routing to a failed instance within seconds. |
| TLS termination | Decrypting HTTPS once at the load balancer, rather than on every backend, offloads CPU work from the application servers. |
| Basic DDoS mitigation | A load balancer is a natural chokepoint for rate-limiting or blocking abusive traffic before it reaches application servers. |