Introduction
Keeping several copies of database records can improve resilience and distribute read traffic. However, those copies must exchange updates, and communication takes time or can fail.
Replication therefore raises questions about what clients can observe and when requests should succeed. Consistency models, CAP, and PACELC help describe these decisions and their consequences.
What Is Replication?
Replication maintains copies of data on multiple nodes.
Depending on the system, replicas can support:
Continued service when a node fails.
Read traffic across multiple nodes.
Access from different geographic locations.
Recovery and operational maintenance.
Replication differs from sharding. Sharding divides ownership of data; replication creates additional copies. A system can use both by replicating each shard.
Replication also does not replace backups. Accidental changes can propagate to replicas, while a retained backup can preserve an earlier state.
Synchronous and Asynchronous Replication
In a common leader-based design, one node accepts writes and sends changes to followers.
Approach | When a write is acknowledged | Main trade-off |
|---|---|---|
Synchronous | After designated replicas meet the required acknowledgment condition | More coordination can increase latency or reduce availability during failures |
Asynchronous | Before all followers have received or applied the change | Followers can lag; failover may lose recently acknowledged writes |
“Synchronous” does not necessarily mean every replica participates. Acknowledgment rules also differ: receiving a log record, persisting it, and applying it are different milestones.
Some systems accept writes through multiple leaders or use leaderless designs. Their conflict handling and coordination rules differ.
What Can a Client Read?
Suppose an account balance changes from 100 to 80.
The leader may already show 80 while a lagging follower still shows 100. A client reading that follower can receive a stale read.
Different consistency guarantees describe what is permitted:
Guarantee | Meaning |
|---|---|
Linearizability | Operations appear to occur atomically in an order that respects real-time completion |
Eventual consistency | If updates stop and communication continues, replicas eventually converge |
Read-your-writes | A client can observe its own successful updates in subsequent reads |
Eventual consistency does not mean replicas are permanently inconsistent. However, the guarantee alone does not provide a fixed convergence deadline.
Read-your-writes is narrower than linearizability: one client seeing its own update does not establish a single real-time order for every client.
Replication and a stale read
CAP: What Happens During a Partition?
A network partition occurs when groups of nodes cannot communicate reliably with one another.
CAP concerns three properties:
Consistency: Linearizability, a single coherent view respecting real-time operations.
Availability: Every request received by a non-failing node eventually completes with a valid response.
Partition tolerance: The system must handle communication being interrupted between groups of nodes.
During a partition, a distributed system cannot guarantee both CAP consistency and CAP availability for all operations.
This is more precise than saying “choose any two.” A network partition is a failure condition the system may encounter, rather than a feature it can simply decline.
CAP availability is also a formal property, not an uptime percentage.
The Trade-Off in Practice
Assume two groups hold copies of the same account balance but cannot communicate.
One group receives a request to change the balance.
A system prioritizing consistency may reject or delay requests that cannot be coordinated safely. This sacrifices availability for those requests.
A system prioritizing availability allows the isolated groups to continue responding, but cannot guarantee a single linearizable history for all operations. Their states may diverge and require reconciliation.
The decision can vary by operation. An application might accept stale product descriptions while requiring coordinated checks before approving a payment.
Also, CAP consistency is different from the “C” in ACID. ACID consistency concerns preserving application and database invariants.
PACELC: What Happens Without a Partition?
CAP focuses on network partitions. PACELC also considers ordinary operation:
Condition | Trade-off |
|---|---|
P: A partition occurs | Availability versus Consistency |
E: Else, during normal operation | Latency versus Consistency |
Even when the network works, coordinating across replicas takes time.
For example, a local replica can often answer quickly. Confirming a globally coordinated result may require communication with distant nodes.
PACELC highlights this latency–consistency tension. It does not mean every increase in consistency causes the same delay, or that systems have only two possible configurations.
Replica placement, protocols, and the operation being performed all affect the result.
CAP/PACELC decision diagram
Quorums Do Not Automatically Solve Everything
Some replicated systems use overlapping groups of replicas for reads and writes, called quorums.
With N replicas, a design may require W acknowledgments for writes and contact R replicas for reads. A condition such as R + W > N provides overlap under the assumed membership model.
However, overlap alone does not guarantee linearizability. Version handling, concurrent writes, failure behavior, and the coordination protocol also matter.
A quorum setting should therefore be understood as part of a complete consistency design, not a universal shortcut to strong guarantees.
Choosing Guarantees for the Application
Start with the consequences of stale or conflicting information.
Ask:
Can a user safely receive an older value?
Must a successful update be immediately visible to that user?
Can conflicting updates be reconciled?
Should a request fail when safe coordination is impossible?
How much cross-region latency is acceptable?
These questions are more useful than labeling an entire database “consistent” or “available” without considering its configuration and operations.
Summary
Replication maintains additional copies of data, but the replication method and consistency model determine what clients can safely observe. Fast acknowledgments, fresh reads, and failure handling require explicit design choices.
CAP explains the consistency–availability trade-off during partitions. PACELC adds the latency–consistency trade-off during normal operation, helping connect distributed guarantees to application needs.
Be the first to add a comment.