Search DistillSys

Find a concept

Type at least two characters to search lessons, designs, papers, and interview prep.

Partitioningadvanced6 min read

Rebalancing

Move ownership safely as data, traffic, and cluster membership change.

2–5 minute refresher
Mental model

Copy → catch up → switch authority → remove old copy

30second
refresher
Rebalancing transfers partitions when nodes join, leave, fill up, or become unevenly loaded. A safe move preserves reads and writes while ownership changes under live traffic.

What problem does it solve?

Static placement decays as datasets grow and workloads shift. Simply changing the owner can lose recent writes, produce two authorities, or overwhelm the network.

How it works

  1. Choose a target using capacity, fault-domain, and load constraints.
  2. Snapshot and copy the partition to the target.
  3. Stream changes that occurred during the copy.
  4. Fence the old owner and atomically publish new routing metadata.
  5. Verify the target, retain a rollback window, then delete the old replica.
Decision guide

Key trade-offs

ChoiceWhat you gainWhat it costs
Fast movementCorrect skew quicklyNetwork and disk interference
Slow movementProtect foreground latencyLong exposure to imbalance
Automatic balancingContinuous correctionRisk of oscillation without damping
What happens if?

The source fails halfway through a move

The control plane must know which copy is authoritative and whether the target has a complete checkpoint. Resume from durable progress or restart from another replica; never infer authority from who has more bytes.

Where it appears

  • Cassandra streaming
  • Kafka partition reassignment
  • CockroachDB replica queues
  • Elasticsearch shard relocation
Senior interview modeHow do you prevent a rebalancer from causing an outage?Show answer
Use bounded concurrency and bandwidth, health-aware admission, stable placement constraints, progress checkpoints, rollback, and automatic pause conditions tied to foreground latency and saturation.
#rebalancing#migration#ownership#capacity