Distributed databases maintain data consistency by coordinating updates across multiple nodes according to a chosen consistency model. They use mechanisms such as replication, consensus protocols, distributed transactions, quorum operations, and conflict resolution.
A distributed database stores related data across multiple networked computers. Replication creates copies of data on several nodes, improving availability and fault tolerance, but every update must be managed so that replicas do not permanently disagree.
The database may require strong consistency, meaning every read returns the most recent successful write. A coordinating node can send an update to replicas and acknowledge success only after enough nodes confirm it. Consensus protocols allow nodes to agree on the accepted order and value of updates, even if some nodes fail.
For replicated data, a quorum specifies how many replicas must participate in an operation. If there are replicas, a read quorum and write quorum can overlap when . For example, with , choosing and helps ensure that a read contacts at least one replica containing the latest successful write.
| Mechanism | Contribution to consistency |
|---|---|
| Replication | Maintains multiple copies of the same data. |
| Consensus | Makes nodes agree on update values or ordering. |
| Distributed transactions | Apply atomicity, so an operation completes on all required nodes or is rolled back. |
| Versioning and timestamps | Identify newer updates and detect conflicting versions. |
| Conflict resolution | Selects or merges versions when concurrent updates occur. |
Some systems instead provide eventual consistency: replicas may temporarily differ, but they converge if no further updates occur. Under the CAP theorem, during a network partition, a distributed system cannot guarantee both full consistency and availability.
A common misconception is that replication automatically guarantees consistency. Replication creates copies; coordination determines whether those copies agree.
In an IB response, define the consistency model, explain one coordination mechanism, and link it to the trade-off between consistency, availability, and partition tolerance in A3.4.