pa-06 — Analysis

What the code must get right

  1. Minimal movement: removing 1 of N nodes moves ~1/N keys on the ring; mod-N moves ~all.
  2. Balance: enough vnodes keep per-node load near the ideal.
  3. Quorum overlap: R+W>N ⇒ a (worst-case) read sees the latest write; R+W≤N ⇒ it may be stale.

Design decisions

  • Vnodes per physical node. One position per node gives lumpy arcs and dumps a departed node's load on one neighbor; many positions even the load and spread departures. The test uses 200.
  • Clockwise-next ownership + binary search. Standard consistent- hashing lookup; deterministic and O(log positions).
  • Worst-case read for the quorum demo. Reading the replicas least likely to hold the write makes the overlap guarantee unambiguous: if even that read is fresh, R+W>N held.
  • Versions, not values. Consistency is about recency; a monotonic version is the minimal model that demonstrates staleness.

Tradeoffs worth flagging

  • Range vs hash vs consistent. Range enables scans but hotspots; hash spreads but reshards catastrophically; consistent hashing is elastic but loses range scans. Choose by access pattern + elasticity.
  • Consistency vs latency/availability. R+W>N costs a quorum round-trip (latency, PACELC) and fails under partition (availability, CAP). Tune per dataset; don't default to strong everywhere.
  • Quorums ≠ convergence. Quorums make a read fresh; stale replicas still need read-repair/anti-entropy/hinted-handoff to converge.
  • Vnode count is a knob. Too few = imbalance; too many = metadata + lookup cost. Sweep to find the knee (exercise).

What production adds beyond this lab

  • Replication placement (preference lists), read-repair, anti-entropy (Merkle trees), hinted handoff (the Dynamo toolkit).
  • Conflict resolution (vector clocks/LWW/CRDTs) for concurrent writes.
  • Bounded staleness / session guarantees; coordination with consensus (db-17) for the strong-consistency datasets.