In a distributed database, multiple replicas hold copies of the same data. Network partitions, slow nodes, and concurrent writes mean those copies diverge — one replica gets an update that another misses.
The naive fix is a central coordinator that serializes every write. But centralization is a single point of failure, and it limits throughput to one machine. Real systems instead let replicas gossip: each node periodically picks a random peer and exchanges a summary of what it knows. Updates propagate like a rumor — exponentially fast, with no coordinator at all.
Gossiping alone doesn't guarantee which differences exist. That's where anti-entropy comes in. Each replica organizes its data into a Merkle tree — a binary tree of hashes where each parent covers the hash of its children. Two replicas compare Merkle roots: if the roots match, they're identical. If not, they walk the tree together, narrowing the mismatch to exactly the changed leaves in steps, then ship only those diffs. The result is eventual consistency: given enough rounds, all replicas converge to the same state.
This article is about a solved problem with a beautiful structure: gossip-based anti-entropy powers Apache Cassandra, DynamoDB, Riak, and the epidemic protocols studied by Alan Demers, Srinivasan Keshav, and their colleagues at Xerox PARC in 1987.
Comments
Loading comments...