Chapter Three · Building Blocks

Partitioning Data

When one machine can no longer hold the data or take the writes, the data is split across many. Five lessons cover what an interviewer asks about it: when to split and into how many parts, the ways a key finds its partition, consistent hashing, the partition that runs hot, and the partition key itself.

5 lessons

Chapter 2 scaled reads by making copies: more servers, a cache tier, read replicas. Copies do nothing for writes, because every copy has to take every write, and nothing for a data set larger than one machine's disk. Partitioning answers those two limits, and its price is that some queries now have to ask more than one machine.

The chapter starts with the arithmetic that says whether to partition at all, then places keys: by range, by hash, through a directory, and on a ring. It ends where partitioned designs most often go wrong in an interview, with the key that takes more traffic than one partition can, and with a partition key read off the entity diagram instead of the queries.

The partitioning decisions, in the order an interview reaches them
Whether to splitthe estimate decides
→
Where a key goesrange, hash, ring
→
What runs hotkeys, ranges, time
→
Which keythe queries decide

Lessons in This Chapter