Try
↑ ↓ move↵ openesc close

Interview prep / Load balancing

Senior · Load balancing · System design interview question

Design the load balancing tier in front of a large service. What layers do you use, and how do you handle failures and scale?

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

A strong answer

A common shape has two layers. A network-level layer (layer 4) spreads connections across a fleet of application-level proxies (layer 7), and those proxies route individual requests to backends.

Points to cover:

  • Layer 4 is cheap per packet and can spread flows with consistent hashing, so the same connection keeps landing on the same proxy, and adding a proxy disturbs few flows.
  • Layer 7 proxies can inspect requests, terminate TLS, retry, and apply request-level strategies such as power of two choices.
  • Health checks, with both active probes and passive observation of errors, to remove sick backends quickly and bring them back gradually.
  • Draining for deploys, so in-flight requests finish.
  • Overload behaviour: limits, load shedding, and retry budgets so retries do not amplify an outage.
  • No single balancer is a single point of failure, so use redundancy and spreading by anycast or equivalent routing.

Before drawing boxes, pin down the traffic shape and the failure domains, and decide what you would measure to know the tier is healthy.

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