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 04 · System Design · The parts, properly · about 16 min to read

Watch: Caching: the slate next to the stove
▶ VideoPlay it as a journeyTutor comes with a plan

Counting the crowd without a register (HyperLogLog, count-min, top-k)

The Slate Next to the Stove
The Slate Next to the Stove · Open board

The slate by the stove, and its second curse: the slate is small. This lesson asks it a question it has no room to answer by writing names down. The lab at the end of the story runs the counter.

Before you start. You need the stall from The chai stall that got famous (load balancing), which got famous and became ten stalls, and the slate from The slate next to the stove (caching): a small board by the stove that holds a few lines and then runs out of room. From Hashing you need one idea: a fixed recipe that stirs any input into a jumble of digits, the same jumble every time for the same input. The second read also uses a heap from Trees (BST, balancing, heaps, tries), a pile that hands you its smallest item first.

Lesson 22 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

  • 1 April 2014: Redis learns to count what it does not remember
  • The stall’s question: how many different customers?
  • Coin flips from a phone number: the hash
  • One lucky customer: registers, and HyperLogLog
  • Ten stalls, one board: merging registers
  • Which regulars come most: the count-min sketch
  • The loyalty list: top-k
  • When to keep the book

Terms it explains: hash, register, HyperLogLog, count-min sketch, top-k.

Lab

Most orders are for three favourites. How big does the slate need to be before a bigger one stops helping?

Tap scenarios 1, 2 and 3 below to grow the slate, then drag Asks that go to the 3 favourites and watch the mean wait.

Open The slate next to the stove

A hundred thousand different customers, and a tally board of 12 KB. How far off is its count?

Step Tallies from 16 up to 16,384, then drag Different customers, and watch Typical miss against Memory.

Open Counting the crowd

Related papers

Review System Design