In this lesson · topic 1 of 7
Topic 1
Too much data, too many writes
4 min read
Copies do not add capacity
Every replica in the last two lessons holds the whole dataset, and under a leader every write passes through one machine. Add replicas and you add safety and read capacity. You do not add room, and you do not add write throughput.
When the data outgrows a disk, or the writes outgrow a machine, the answer is partitioning, also called sharding. Cut the data into pieces by key. Each piece lives on its own machine, usually replicated as in the last two lessons. A write for a key goes to the one partition that owns it.
The cut can go wrong
If the pieces take equal shares of the traffic, ten partitions handle ten times the load of one. If one piece takes most of the traffic, the cluster is only as fast as that piece. The extra machines sit idle. A partition with a disproportionate share is a hot partition.
Where a key lands depends on the rule used to cut. Two rules are common. Range partitioning gives each partition a stretch of the sorted key order. Hash partitioning sends each key to the partition its hash selects. They behave very differently under different traffic.
Predict first
In the lab’s simulation, the busiest partition took 8.00xmeasured its fair share of requests under that traffic. Eight machines behaved like one.
What the lab answers
Which rule suits the traffic you have, what each costs in hot partitions and in expensive queries, and how to relieve a hot range once it exists.