System Design · core

Load Balancing

L4/L7, consistent hashing, health checks.

system-designscalability

Mental model

A load balancer is the seam between "one address" and "many servers". L4 routes by IP/port (fast, dumb); L7 routes by request content (slower, smart). Health checks and the balancing algorithm (round-robin, least-connections, consistent hashing) decide who gets each request.

How to study Load Balancing

Begin by restating the mental model in your own words, then connect it to a concrete system you have built or operated. Name the mechanism, the constraint it addresses, and the trade-off it introduces. Use System Design Primer, Site Reliability Engineering (Google) — chapter 19: Load Balancing at the Frontend, Google SRE Book — Load Balancing in the Datacenter to check details, but close the source before writing your explanation. Retrieval is the learning step; rereading is only preparation.

Next, compare Load Balancing with Consistent Hashing. Ask what changes in correctness, latency, resource use, operability, and failure recovery. Complete L7 load balancer and preserve the command, input, output, and one failed attempt as evidence. Finish by explaining the idea without jargon to someone who has not studied the track.

Proof of understanding

  • Explain the mechanism from first principles and identify the state it reads or changes.
  • Give one situation where the concept is the right choice and one where it is not.
  • Predict a realistic failure mode before running the drill, then compare the prediction with evidence.
  • Connect the result to a roadmap or build artifact instead of treating the concept as isolated trivia.

Common mistakes

  • Treating the load balancer as a single point of failure with no redundancy
  • Round-robin to stateful servers that need sticky sessions
  • No health checks, so traffic keeps hitting a dead instance

Learn from primary sources

Practice and explain it back

L7 load balancer

Design an L7 load balancer in front of N application servers. Pick a routing algorithm (round-robin, least-connections, hashing), explain health checks, and how you drain a node.

Expected evidence: Routing decision tree + health-check loop + a graceful-drain sequence.

Open the interactive drill →

Review prompts

  • Round-robin is distributing requests evenly but tail latency is bad. What is the likely cause and the fix?

Build evidence

Use a roadmap capstone to turn this concept into working evidence.

Prerequisites

None assigned yet.

Related concepts

Learning paths