Build a load balancer (HAProxy / NGINX style)

No scenes authored for this problem yet.

About Build a load balancer (HAProxy / NGINX style)

The first hop every request takes — and the single piece of infra most likely to break a deploy. Build a load balancer from L4 (TCP) through L7 (HTTP) — connection pooling, health checks, sticky sessions, slow start, drain, the thundering-herd retry storm. Feel why 'just round-robin it' is the wrong default.

Difficulty
intermediate
Time
about 80 minutes
Stages
9
Topic
Caching, Proxies & the Edge

How this problem is worked

Nine stages, from what the thing is for to how it compares with the real implementations. Each asks one question, and the simulator runs the architecture you draw against the requirements you wrote.

  1. 01Purpose & invariantsWhat is this for, and what must always be true of it?
  2. 02Workload characterizationWho writes, who reads, and in what shapes?
  3. 03Data model & on-disk formatWhat does the data look like at rest?
  4. 04Core algorithmsHow do the write path and the read path actually work?
  5. 05Distribution & replicationHow does this scale out and survive losing a machine?
  6. 06Consistency & correctnessUnder concurrency and failure, what is guaranteed?
  7. 07Failure modes & recoveryWhat actually happens when each part fails?
  8. 08Operational characteristicsCan a human run this at three in the morning?
  9. 09Trade-offs & comparisonWhere does this sit against the alternatives?

Primary sources for this problem

  • HAProxy documentation — Configuration manual + architecture
  • NGINX docs — Load balancing, upstream module, slow_start
  • Marc Brooker — Timeouts, retries and backoff with jitter (AWS Builders' Library)
  • Maglev — A Fast and Reliable Software Network Load Balancer (NSDI 2016)
  • Mittal et al. — Revisiting Network Support for RDMA (SIGCOMM 2018) — for context on DSR
  • Cloudflare engineering blog — Unimog, L4 load balancer at the edge
  • Vladimir Rusinov — The power of two random choices in load balancing

More in Caching, Proxies & the Edge

Everything between the client and the origin: in-memory caches, CDNs, load balancers and service proxies — and the three ways a cache betrays you.

Browse the full problem catalog, or see what the simulator does and does not model.