Load Balancing Algorithms & Health Checks
Round Robin, Weighted, Least Connections, and active/passive health checks.
In plain words
How does the host pick the next table? Either take turns (Round Robin), pick the waiter with the fewest active tables (Least Connections), or give bigger tables more guests (Weighted).
Think of it like…
Supermarket lines: "take turns" fails when one customer has 200 items; picking the shortest active line keeps everyone moving.
Theory & how it works
Why Least Connections beats Round Robin for real APIs
If request #1 is a heavy PDF export taking 5 seconds and request #2 is a 5 ms health ping, Round Robin blindly keeps sending every 3rd request to the busy server holding slow exports. Least Connections naturally routes around busy nodes.
Add Power of Two Choices (P2C): pick two random servers and send the request to whichever has fewer active connections. It is fast, decentralized, and avoids herd effects.
Key points & practical guide
Summary checklist
- Round Robin for identical fast requests
- Least Connections for mixed/long-running requests
- Active health checks (
/healthz) + graceful draining on shutdown
When to use it
- Any multi-node backend service pool
Watch out for
- Letting health checks query a heavy DB endpoint - keep
/healthzlightweight or use/readyzseparately