Partitioning keys lab
Spread keys over partitions by key range or by hash, under uniform, skewed and sequential traffic. See hot partitions, the cost of a range scan, and what splitting a hot range does.
Skewed (Zipf) keysbusiest ÷ mean = 6.42Range partitioning, loads counted since the last split
Range partitioning · 8 partitions
- busiest vs mean
- 6.42x
- busiest share
- 80%
- partitions per scan
- 1.2
Even would be 12.5% each.
| Series | Latest | Lowest | Highest |
|---|---|---|---|
| Range partitioning | 6.4 | 6.4 | 6.6 |
| Strategy | Partitions | Share of requests per partition | Busiest ÷ mean | Partitions per scan |
|---|---|---|---|---|
| Range partitioning | 8 | 80% 6% 4% 3% 2% 2% 2% 1% | 6.42 | 1.2 |
What to try
Each one sets up a starting point. Then make the change it describes.
Uniform traffic, either way works
Pick Compare all partitionings with uniform keys.
Look for. Both layouts spread requests evenly. When traffic is uniform, the choice is about scans and splits, not balance.
Timestamps pile onto one partition
Pick sequential keys and compare both layouts. Watch which range partition takes the load.
Look for. Every new key is larger than all existing ones, so range partitioning sends all of it to the last partition. Hashing scatters the same keys evenly.
Hash is not a cure for a hot key
Compare both layouts with skewed traffic, then raise the skew from 1.0 to 1.4.
Look for. Hashing spreads the popular keys over many partitions, but the single most popular key still lands on one of them, so that partition stays hot. Higher skew makes it worse.
What hashing costs: range scans
Compare both layouts with uniform keys and 300 keys per scan, then raise the scan to 2000 keys.
Look for. A range scan reads neighbouring keys. Range partitioning keeps them together, so a scan touches one or two partitions. Hashing scatters them, so nearly every partition is involved.
Split the hot range
Use range partitioning with skewed traffic and press Split the busiest range partition several times, pausing between presses.
Look for. Each split moves half the hot partition load to a new partition and the busiest share falls. Splits stop helping once the hottest partition is one key. With sequential keys, splitting does not help at all, because the next keys still arrive at the end.
New to the idea? Read the lesson first. Every number here comes from a seeded simulator, so the same seed gives the same run.
Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms