Blog 18 — Amazon: Dynamo — Highly Available Key-Value Store
C
Qubits of DPK
March 21, 2026
Core Case Studies
Core Concept: Consistent hashing, Vector clocks, Sloppy quorum + hinted handoff, Eventual consistency, Merkle trees
Why SDE-2 Critical: The most foundational paper in distributed systems — Cassandra, DynamoDB, Riak all built on these ideas
Status: Draft notes ready
Quick Revision
- Problem: Keep a key-value system available even through failures and partitions.
- Core pattern: Consistent hashing, quorum reads/writes, and anti-entropy repair.
- Interview one-liner: Dynamo trades perfect freshness for availability that the business can rely on.
️ The Core Problem Amazon Solved
javascript
QUBITS OF DPK
Core Concepts
Consistent Hashing
javascript
QUBITS OF DPK
Replication (N, R, W)
javascript
QUBITS OF DPK
Sloppy Quorum + Hinted Handoff
javascript
QUBITS OF DPK
Vector Clocks (Conflict Detection)
javascript
QUBITS OF DPK
Merkle Trees (Anti-Entropy)
javascript
QUBITS OF DPK
Impact of This Paper
5 Interview Questions This Blog Unlocks
Q1. How does DynamoDB/Cassandra work under the hood?
Answer: Consistent hashing assigns key ranges to nodes. N replicas store each key. Writes sent to N nodes, return success after W confirmations. Reads from R nodes, return latest version. Eventual consistency — replicas sync via hinted handoff and Merkle tree anti-entropy. Vector clocks detect conflicts.
Q2. What is consistent hashing and why is it better than modulo hashing?
Answer: Consistent hashing places nodes on a ring. Keys map to the next clockwise node. Adding/removing a node only remaps ~1/N keys. Modulo hashing remaps ALL keys when N changes, causing massive data movement. At scale, consistent hashing enables live node additions with minimal disruption.
Q3. What is eventual consistency and when is it acceptable?
Answer: Data may be temporarily inconsistent across replicas but will converge to same state eventually. Acceptable for: shopping carts, social feeds, user preferences, analytics. Not acceptable for: financial transactions, inventory counts, authentication. Dynamo chose eventual consistency to maximize availability for Amazon's shopping cart.
Q4. What is the difference between N, R, W in Dynamo-style systems?
Answer: N = replication factor (copies). R = replicas to read from. W = replicas to write to. When R+W > N, there's guaranteed overlap between read and write sets — reads always see the latest write. Lower R or W → higher availability, weaker consistency. Tune based on whether you need read-heavy or write-heavy consistency.
Q5. How do Cassandra nodes detect and fix data divergence between replicas?
Answer: Merkle trees. Each replica builds a Merkle tree of its data (hash tree). Compare root hashes with peer nodes. If different, recursively find divergent subtrees. Only sync the differing portion — O(log N) comparisons instead of comparing all keys. This is called anti-entropy repair.