Loading
0x60Lesson 7 of 9

Partition data without creating hotspots

Choose partition keys and recognize skew, fan-out, and rebalancing costs.

14 min 5-question quiz
By the end of this lesson you can
  • 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 XP

Partition an orders table

Try each key, and look at both the writes and the reads.

  1. Which key spreads new writes most evenly?
  2. Turn on the huge customer. Which key suffers?
  3. 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.

Partition key
  • 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 XP

Find the hot shard

You’re looking at a cluster’s metrics. Click the line that needs attention.

Round 1 of 1: One busy shardScore 0/0

Which shard is hot?

$ cluster-stats --by-shard

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…