Partition data without creating hotspots
Choose partition keys and recognize skew, fan-out, and rebalancing costs.
- Compare range and hash partitioning and identify a hot partition.
Partitioning divides data across nodes so storage and work can grow horizontally. Range partitioning keeps nearby keys together and can support ordered scans, but writes to the newest range may concentrate on one node. Hash partitioning spreads keys more evenly, but makes range scans harder. A popular key can still overload one partition. Consistent hashing can reduce the amount of data moved when membership changes, but it does not remove skew by itself.
Possible responses to skew include choosing a better key, salting very hot keys, splitting a tenant, or adding a specialized serving path; each affects query patterns and operations.
Practice: choose a partition key
Try it
Up to 15 XPPartition an orders table
Try each key, and look at both the writes and the reads.
- Which key spreads new writes most evenly?
- Turn on the huge customer. Which key suffers?
- What does the most even key cost you when you read one customer’s orders?
The last panel shows how many keys move when you add a shard.
- Shard 10%
- Shard 20%
- Shard 30%
- Shard 4100%
- To read one customer’s orders
- ask 4 shards
- To read one week’s orders
- ask 1 shard
Adding a shard: 4 to 5
- hash % shard count
- 80% of keys move
- Consistent hashing
- 24% of keys move
Try it
Up to 15 XPFind the hot shard
You’re looking at a cluster’s metrics. Click the line that needs attention.
Which shard is hot?
Key takeaways
Choose a partition key based on access patterns and key distribution.
Range and hash partitioning trade locality against spread.
Consistent hashing helps rebalance membership changes, not workload skew.
Lesson quiz
5 questions · pass with 4 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…