Skip to content

Partitioning and consistent hashing

Choose a shard key, estimate key movement when a ring grows, and explain why balanced storage does not eliminate hot-key load.

26 min8 steps

By the end you can
  • Choose range or hash partitioning and calculate an indivisible hot key's load floor
  • Estimate moved keys when an equal node joins an ideally balanced ring
  • Route a key to its clockwise owner and explain virtual-node trade-offs
  • Order a migration that preserves reads and writes during ownership changes

A shard key chooses where work lands

Partitioning splits data; replication copies it. The shard key sets routing, locality and cross-shard work. Start from queries, not hash functions.

Tenant ID

  • Tenant queries stay local
  • Huge tenant dominates a shard

Random row ID

  • Writes spread evenly
  • Range queries hit every shard

Constant key

  • All work on one shard

Most queries fetch all recent events for one tenant, and tenants are reasonably sized. Which initial key keeps those queries local?

Answer this step to continue.