Try
↑ ↓ move↵ openesc close

Interview prep / Load balancing

Mid · Load balancing · System design interview question

Your backends are not identical. Some machines are faster than others. How do you balance load across them?

Sketch your own answer first, then compare it with the one below.

A strong answer

Start by naming the problem with even splitting. Round robin and random give each server the same share, so a slower server receives more than it can finish and its queue grows.

Options:

  • Weighted round robin or weighted random. Give each server a share proportional to its capacity. This is simple and works when capacity is known and stable.
  • Queue-aware strategies such as least connections or power of two choices. A slow server's queue is longer, so it loses comparisons and gets fewer requests without anyone configuring a weight.
  • Latency-aware routing, where the balancer prefers backends that have been answering quickly.

Static weights go stale when machines are shared or throttled. Adaptive schemes handle change but need a trustworthy signal. Heterogeneity is also one source of the tail latency variation that large services have to design around.

Sources

Learn it by running it

The load balancing lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms