Key-Value Store (Dynamo-style)
Requirements: put(key, value), get(key); highly available, partition-tolerant, horizontally scalable, tunable consistency.
client -> any node (coordinator)
| consistent hashing ring with virtual nodes
v
key k -> preference list [N1, N2, N3] (N = 3 replicas)
write: send to all 3, succeed after W = 2 acks
read : ask R = 2, return newest version, repair stale replicas
Deep dives
- Partitioning: consistent hashing + virtual nodes.
- Replication: N replicas on distinct nodes/AZs; quorum
R + W > Nfor overlap; sloppy quorum + hinted handoff to stay writable during failures. - Conflicts: vector clocks to detect concurrent writes; resolve via last-write-wins (timestamps) or return siblings to the client.
- Failure detection: gossip protocol; anti-entropy with Merkle trees to sync replicas cheaply.
- Storage engine: LSM-tree (memtable + WAL + SSTables + compaction), Bloom filters for reads.