What is the difference between synchronous and asynchronous replication?
Synchronous replication makes the leader wait for replicas to confirm before acknowledging a write, so no acknowledged write is lost but writes are slower. Asynchronous replies immediately and replicates later, which is faster but can lose recent writes.
Explain it simply
Compare two ways of sending a courier parcel. Synchronous: you wait at the counter until the receiver confirms it arrived, then leave. Asynchronous: you hand it to the courier and walk away, trusting it will arrive.
Synchronous:
- Leader waits for at least one replica to confirm the write is durable.
- If the leader dies, the replica has every acknowledged write.
- Write latency includes the network round trip, and if the replica is down the write can stall.
Asynchronous:
- Leader acknowledges immediately, replicas catch up behind.
- Low latency, leader keeps working even if replicas are slow.
- If the leader crashes before shipping, the latest writes are lost, and replicas serve stale reads.
A common compromise is semi-synchronous: wait for one replica, replicate to the rest asynchronously. That bounds data loss while not blocking on every node.
Cross-region replication is usually asynchronous because a synchronous write across continents would add hundreds of milliseconds.
Example
Leader in Mumbai, replica in Singapore (60 ms away).
Sync : write time = local work + 60 ms round trip, about 65 ms
Async: write time = local work only, about 5 ms
Leader crashes at once: sync keeps the write, async may lose itWhat to say in the interview
"Synchronous replication trades write latency and availability for durability; asynchronous trades possible loss and stale reads for speed. Semi-synchronous, one confirmed replica plus async for the rest, is the usual middle path, and cross-region links are normally async."