Partitioning & Load

Lesson, slides, and applied problem sets.

View Slides

Lesson

Partitioning & Load

Why partitioning matters

Partitioning lets you scale writes and reads horizontally by splitting data across nodes. But the split must be stable (small movement when nodes change) and balanced (avoid hotspots).


Consistent hashing

Keys and nodes map onto the same ring. A key is owned by the next token clockwise. When a node joins or leaves, only a fraction of keys move.


Virtual nodes

Each physical node owns multiple tokens. This smooths out uneven key distribution and makes rebalancing easier.


What you will build

  • Lookup the owner of a key on a consistent hash ring
  • Select a replica set by walking the ring and skipping duplicate nodes
  • Rebalance shards based on load and shard sizes

Module Items