Module 10 · From Scratch · Sharded KV store · about 16 min to read
Continue where you left off ×
Load balancer, stage by stage
Concurrency · Open board
The HTTP server’s concurrency board. A load balancer is the next door out: the same server code, many copies of it, and one program in front deciding which copy gets each request.
The idea in 30 seconds
Round-robin sends each request to the next backend in turn, using a counter modulo the number of backends.
A passive health check reacts in one failed request, and an active check is the only way to bring a recovered backend back.
Least connections sends to the backend with the fewest requests in flight, which lowers the median wait when request costs differ.
Hash modulo moves 75% of keys when you go from 3 to 4 backends, and a hash ring moves only about 25%.
A cap of 1.25 times the average load stops one popular key from overloading one backend.
Connection draining sends no new requests to a backend and lets the in-flight ones finish.
Read the story
Lesson 72 of 117 in From Scratch
The rest of this lesson is part of a plan.
A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year .
See plans Already a member? Sign in
Or start free : a free account opens lessons 2 and 3 of every track.
In this lesson 2016 to 2017: Vimeo’s cache was busy on one machine and idle on another Stage 1. Round-robin: take turns Stage 2. Health checks: stop sending to a dead backend Stage 3. Least connections: send to the one with the least work Stage 4. Consistent hashing: the same key goes to the same backend Stage 5. Connection draining: remove a backend without cutting anyone off What the simulation leaves out The order matters Terms it explains: backend, round-robin, health check, passive, active, Least connections, consistent hashing, Connection draining, Stage 2, Stage 3, Stage 4, Stage 5.
Review From Scratch
Mark as read Saved in this browser, and to your account when you sign in.