Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

A chalk plan

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year.

See plansStart free instead

Module 07 · System Design · The stall, built · with code: Go · about 15 min to read

Watch: Load balancing: the chai stall that got famous
▶ VideoPlay it as a journeyTutor comes with a plan

The stall, built: copies and shards (replication and sharding in Go)

The Chai Stall That Got Famous
The Chai Stall That Got Famous · Open board

The famous stall, now a row of stalls behind one gate. Every stall in that picture still writes into one book. This lesson copies the book, then cuts it into three, in code.

Before you start. The stall, built: one counter in code (load balancing, health checks and caching in Go) built the stall as a Go program: a gate that sends each customer to the least busy of three stalls, a slate that remembers prices, and a rail of order slips, all with one book behind them. The copy clerks (database replication) gave that book copy clerks: the leader’s book takes every write, and each clerk copies it a moment later, so readers can use the copies, and a copy is always slightly behind. Splitting the ledger (sharding) cut the book itself: different customers in different books, with one field, the shard key, deciding which book a customer lives in. This lesson builds both and measures them.

Lesson 42 of 115 in System Design

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 plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 4 October 2010: Foursquare’s two books, and the one that filled first
  • Where the last build stopped: one book
  • The copy clerk, and how far behind it runs: replication lag
  • One stale read, on purpose
  • Cutting the book: by number, or by a hash
  • A fourth book, and three in four customers move
  • Every book with its own clerk

Terms it explains: replica, replication lag, stale read, shard, hash.

Lab

Sixteen customers, one wala. If the wala stops standing at each kettle, how much sooner is everyone served?

Switch to Juggle the kettles, drag Customers at once and Burners to 64, then watch Walas busy.

Open One wala, many kettles

Review System Design