What Are the Main Data Replication Strategies?
Learn synchronous, asynchronous, and semi-synchronous data replication strategies and their durability, latency and consistency trade-offs.
Expected Interview Answer
Data replication strategies fall into three broad approaches β synchronous, asynchronous, and semi-synchronous β which trade off consistency, latency, and durability differently depending on when a write is acknowledged relative to copying it to replicas.
Synchronous replication waits for one or more replicas to confirm they have durably written the data before acknowledging the client, guaranteeing zero data loss on primary failure but adding latency proportional to the slowest required replica. Asynchronous replication acknowledges the client immediately after the primary commits, then streams changes to replicas in the background, which keeps writes fast but risks losing the most recent writes if the primary crashes before replicating them. Semi-synchronous replication is a middle ground where the primary waits for acknowledgment from at least one replica (not all) before confirming the client, balancing durability and latency. Beyond timing, teams also choose a topology β single-leader, multi-leader, or leaderless β and a propagation mechanism such as statement-based, write-ahead log shipping, or logical/row-based replication, each with different trade-offs for conflict handling and replay correctness.
- Synchronous replication guarantees no data loss but adds write latency
- Asynchronous replication keeps writes fast at the risk of losing recent data on failure
- Semi-synchronous replication balances the two by requiring only one replica ack
- Choosing the right strategy lets teams tune the consistency/latency/durability trade-off per workload
AI Mentor Explanation
Data replication strategies are like how a scorer relays the ball-by-ball update to the broadcast truck. In synchronous mode, the scorer waits for the truck to confirm receipt of every ball before marking it official, so nothing is ever lost but every ball takes a beat longer to confirm. In asynchronous mode, the scorer marks the ball done immediately and radios it to the truck afterward, so scoring feels instant but a dropped signal right before a rain delay could lose the last few balls. Semi-synchronous is the scorer waiting for just one backup radio to confirm before moving on, a middle ground most broadcast crews actually use.
Step-by-Step Explanation
Step 1
Client sends a write
A write request arrives at the primary node holding the authoritative copy of the data.
Step 2
Primary commits locally
The primary applies the write to its own storage and write-ahead log first.
Step 3
Propagate per chosen strategy
Synchronous waits for replica ack(s); asynchronous streams changes in the background; semi-synchronous waits for just one replica.
Step 4
Acknowledge the client
The client receives success once the strategyβs durability condition is satisfied, not necessarily after every replica is updated.
What Interviewer Expects
- Distinguishes synchronous, asynchronous and semi-synchronous replication clearly
- Explains the latency vs durability trade-off for each strategy
- Mentions replication topology (single-leader, multi-leader, leaderless) as a related axis
- Connects the choice to real workload needs (e.g., financial writes vs social feed writes)
Common Mistakes
- Treating replication as a single monolithic concept with no trade-offs
- Assuming asynchronous replication always means data loss is likely
- Confusing replication strategy with sharding or partitioning
- Not mentioning semi-synchronous as a practical middle ground
Best Answer (HR Friendly)
βData replication is about copying data to backup machines so a single failure does not lose it. You can wait for the backup to confirm before telling the user it worked, which is safest but slower, or confirm immediately and copy in the background, which is faster but riskier. Most real systems pick a middle ground where at least one backup confirms before responding.β
Code Example
replication:
primary: db-primary-1
replicas:
- id: db-replica-a
mode: synchronous
region: us-east
- id: db-replica-b
mode: asynchronous
region: eu-west
ackPolicy: semi-synchronous
minSyncReplicas: 1
walShipping: enabledFollow-up Questions
- How does synchronous replication affect write latency across regions?
- What happens to in-flight writes if the primary fails during asynchronous replication?
- How does semi-synchronous replication choose which replica must acknowledge?
- How does replication interact with sharding when data is partitioned across many primaries?
MCQ Practice
1. Which replication mode guarantees zero data loss on primary failure but adds the most write latency?
Synchronous replication waits for replica confirmation before acknowledging the write, guaranteeing durability at the cost of latency.
2. What is the main risk of asynchronous replication?
Because acknowledgment happens before replicas catch up, a primary crash can lose the latest un-replicated writes.
3. What does semi-synchronous replication require before acknowledging a write?
Semi-synchronous replication only waits on one replica acknowledgment, balancing durability and latency.
Flash Cards
Synchronous replication? β Waits for replica(s) to confirm before acknowledging the client; safest but slowest.
Asynchronous replication? β Acknowledges immediately, replicates in the background; fastest but risks data loss.
Semi-synchronous replication? β Waits for just one replica to acknowledge, balancing durability and latency.
Why choose a replication strategy? β To tune the trade-off between write latency, durability, and consistency for a given workload.