ARCHIVED from builddistributedsystem.com on 2026-04-28 — URL: https://builddistributedsystem.com/projects/mini-dynamo/tasks/dynamo-t1-s2-node-leave
DS

Compute Key Migration on Node Departure

Mini-Dynamo / Node Membership Changes
intermediate

Concept

Graceful Departure and Hinted Handoff

In production, a node leaving the ring should hand off its data to its successor before going offline. This prevents data loss and avoids forcing the successor to recover data from replicas.

The Handoff Protocol

  1. Identify the departing node's successor on the ring.
  2. Stream all keys in the departing node's range to the successor.
  3. Remove the departing node from the membership.
  4. Acknowledge departure to the cluster coordinator.

What Happens to the Ring?

After departure, the predecessor of the departed node now has a larger ownership range — it stretches all the way to the next surviving node. No other node is affected.

Before:  n1@200 --- n2@400 --- n3@700
After n2 leaves:
         n1@200 -------- n3@700
         n1 still owns (700,200]; n3 now owns (200,700]

Contrast with Failure

A graceful departure allows data handoff before removal. A sudden failure (crash, network partition) does not — the successor must reconstruct the data from replicas. This is why Dynamo maintains N=3 replicas: even if the primary fails without a handoff, two other copies survive.

main.py
python

Sign in to run and submit code.