Chapter Ten · Problem Four

Key-Value Store

A store that has to lose machines without a pause, worked through the 45 minutes of a round.

4 lessons · 45 minutes
The Question

"Design a distributed key-value store with put and get that keeps answering when machines fail."

The words that matter come last: keeps answering. Without them this is a hash table behind a network call. With them, a pause while a failover runs counts as failing, and any one machine that everything needs is a machine the question has already told you will die. Every choice in these four lessons serves those two words, and a box you cannot tie back to them does not belong on the board.

This is Chapter 4 under pressure. Leaders, Followers and Everyone, Quorums, Consistency Models That Come Up, CAP and PACELC, Precisely, and Concurrent Writes and Conflicts all get used here, on one store with one set of numbers, so a sentence that sounded fine in the abstract now has to survive the next question. Chapter 3's Consistent Hashing and Hot Partitions place the keys and move them. From Chapter 5, Why Agreement Is Hard and Clocks and Ordering say what a timeout and a timestamp are worth, and Leader Election and Consensus is the road not taken.

The round is pitched at senior, and conflicts and operations are where a staff candidate shows. Three decisions do the work: choosing the consistency point, which means the replica count, the quorum sizes and what each one buys; membership and failure detection with no master, along with handing data off while a machine is down; and concurrent writes to one key, which bring versions and the question of who resolves the conflict.

Give yourself the full 45 minutes on a timer and put your own store on paper before the first lesson, with the numbers you would defend. Scope covers minutes 0 to 10, First Design 10 to 20, Scaling It 20 to 30, and Deep Dives and Curveballs 30 to 45. Reading against your own sketch shows you which question you never asked.

The 45 minutes of this problem, lesson by lesson
Scopeminutes 0-10
→
First Designminutes 10-20
→
Scaling Itminutes 20-30
→
Deep Divesminutes 30-45

Lessons in This Chapter