Scaling & Load BalancingIntermediate15 min read2 questions

Load Balancing Algorithms and Health Checking

Which algorithm to pick and why it matters more than you think. Plus the operational half nobody prepares for: health checks, connection draining and retry amplification.

Covers: Round robin, least connections, weighted, power of two choices, hashing; health checks; draining; outlier ejection

Choosing a load-balancing algorithm looks like a trivia question. It is not: the wrong choice concentrates load on your slowest instance, and the classic least connections algorithm has a failure mode where a broken server that errors instantly attracts all the traffic.

Filter
0/2 mastered
Intermediateload balancingalgorithmsscalingAsked at Google, Netflix

30-second answer

Round robin is simple and fine when every server and every request is roughly identical. Least connections adapts to uneven request cost and is the usual default for heterogeneous workloads. Weighted variants handle servers of different sizes. Consistent hashing routes the same key to the same server, which matters for cache locality and sticky routing. In practice the best general-purpose choice is power of two choices: sample two backends at random and pick the less loaded one - nearly the quality of least connections with none of its coordination cost or herd behaviour.

Advancedretriescascading failurereliabilityAsked at Amazon, Google

30-second answer

Retry amplification. When a service slows, callers time out and retry, which multiplies the load on an already-struggling service. With three layers each retrying three times, one user request becomes 27 backend requests exactly when the backend can handle fewest. The service gets slower, more retries fire, and the system collapses. Fixes are retry budgets rather than fixed retry counts, exponential backoff with jitter, circuit breakers, load shedding at the server, and retrying at only one layer of the stack.

Showing 2 of 2 questions for load-balancing-algorithms.

Check your understanding

4 questions · no sign-up, nothing stored

0/4 answered
Question 1

1.A backend fails instantly with 500s, so it has near-zero open connections. Which algorithm sends it MORE traffic?

Question 2

2.Three layers each retry twice on failure. How many backend requests can one user request generate?

Question 3

3.Why must a readiness check avoid failing when a shared cache is down?

Question 4

4.Under overload, which server behaviour is best?

Hands-on challenge

Build it - this is what you talk about in a deep-dive round.

Make a call chain survive a slow dependency

Take a three-service chain and make it degrade gracefully instead of collapsing when the deepest service slows to 5-second responses.

Requirements

  • Assign a timeout to every hop such that deadlines shrink with depth, and justify each number.
  • Implement a retry budget and demonstrate it stops retrying during a broad outage.
  • Add a circuit breaker with defined open, half-open and closed transitions.
  • Add server-side load shedding and show fast 503s instead of slow timeouts under overload.
  • Load-test the chain with the dependency artificially slowed and plot amplification with and without your fixes.

Stretch goals

  • Add outlier ejection and show a fast-failing backend being removed automatically.
  • Propagate a deadline through all three hops and show the deepest call being abandoned early.