Tunable DB Consistency Simulator
Simulate tunable read/write consistency levels (One, Quorum, All) in a Dynamo-style replicated database ring. Slice network connections to create partitions, execute operations
Continue with the guided workspace
Use the paired workspace to connect this guide's mental model with live component state, visible signals, and the outcome each step or scenario is meant to prove.
A Dynamo-style masterless database lets writes succeed on any subset of replicas, trading immediate consistency for high write availability. Tunable consistency comes from three knobs β replication factor , write quorum , and read quorum β and the core mental model is quorum intersection: when , every read overlaps a previous write on at least one replica, so the latest value is always retrievable.
Mental Model
A Dynamo-style masterless database scales write availability by allowing writes to succeed on any subset of nodes. It achieves tunable consistency through three parameters: Replication Factor (), Write Quorum (), and Read Quorum (). The core mental model is quorum intersection: if , the read quorum and write quorum are mathematically guaranteed to overlap on at least one replica node. This overlap ensures that a read will always retrieve the latest write. If , the database is eventually consistent, meaning reads might return stale data.
Components and Why They Exist
Client App
This component exists to trigger reads and writes with tunable consistency levels and verify outcome metrics. It directs requests to a coordinator replica in the ring, monitoring timeouts and eventual consistency states. In the demo, observe message packets traveling to the coordinator and read results returned.
Coordinator Node
This component exists to manage distributed request lifetimes, compile quorum lists, and merge versions. It receives client requests, delegates commands to target replicas, aggregates acknowledgments, and performs read repairs. In the demo, observe coordinator highlight (ring outline) and outgoing query packets (blue for write, green for read) to replicas.
Replicas (N1 to N5)
This component exists to store data partitions redundantly, execute operations, and maintain logical vector clocks. They process read/write commands, increment node-specific counters, and respond to queries from coordinator hosts. In the demo, watch node detail cards showing local key values and vector clock counters (e.g., [N1:2]).
Gossip Protocol (Anti-Entropy)
This component exists to heal partition differences and keep replicas up to date without continuous client polling. It exchanges database key signatures between node pairs asynchronously to detect and repair version drift. In the demo, observe background synchronization logs and node values converging.
Edge Cases and Misconceptions
- LWW (Last-Write-Wins) timestamp issues: Many databases use wall-clock timestamps to resolve version conflicts. If server clocks drift, a write that occurred later in real time might be discarded because its timestamp is lower than a stale nodeβs clock, causing permanent data loss.
- Quorum does not prevent conflict: If two clients write concurrently to different partitioned nodes with a write quorum of 1 (W = 1), both writes succeed, creating diverging histories. Vector clocks identify this concurrency, forcing the application or database to merge the values.
- ALL consistency availability penalty: Setting the write quorum to ALL (W = ALL) ensures absolute read freshness, but if even a single replica node is partitioned or restarts, all writes fail, destroying the systemβs write availability.
Common Questions
Why is a coordinator node used in a masterless database?
In a masterless (Dynamo-style) database, any node can receive client requests. The contacted node acts as the coordinator for that specific request, querying the correct replicas based on consistency parameters, resolving version conflicts, and responding to the client.
What is the difference between Vector Clocks and wall-clock timestamps?
Wall-clock timestamps rely on server clocks, which drift and can cause newer writes to be overwritten (Last-Write-Wins anomalies). Vector clocks track logical causality (happened-before relationships) by incrementing node-specific counters, allowing nodes to detect concurrent writes and conflicts accurately.
How does Read Repair resolve staleness?
When a client reads with a consistency level R > 1, the coordinator fetches data from R replicas. If it detects a replica with an older vector clock, it returns the newest value to the client and immediately sends an asynchronous write to update the stale replica.
What is Gossip Sync (Anti-Entropy) and why is it needed?
Read Repair only updates stale replicas when a key is actively read. Gossip Sync is a background anti-entropy process where nodes periodically exchange vector clock metadata to discover and synchronize stale keys across the network.
What happens when $R + W \le N$?
The quorums might not overlap. For example, in a cluster with N=3, W=1, and R=1, a write might update only Node A, while a subsequent read queries only Node B, returning stale data (or no data) until background gossip sync completes.
How does a vector clock determine if a version is newer?
A vector clock V_A is newer than (dominates) V_B if every counter in V_A is greater than or equal to the corresponding counter in V_B, and at least one counter is strictly greater. If some counters in V_A are larger while others in V_B are larger, the versions are concurrent (in conflict).
Why do Dynamo-style databases prefer local quorums?
In multi-region clusters, waiting for replica acknowledgments across WAN links is extremely slow. Using local quorums (e.g., Local Quorum) allows quorums to be met within the local datacenter, delivering low latency while relying on async replication to remote datacenters.