Try
↑ ↓ move↵ openesc close
In this lesson · topic 1 of 7
  1. 1. Too much data, too many writes
  2. 2. Range, hash, and splitting
  3. 3. Split a hot range and compare layouts
  4. 4. When one key outruns every partition
  5. 5. Adding a node, and how requests find their partition
  6. 6. Looking up by the column you did not partition on
  7. 7. Check the partitioning rules

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

A table is keyed by the time of the event, so each new row has a larger key than all the earlier ones. It is range partitioned over eight machines. All the traffic is inserts. How is the load spread?

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.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms