Synchronous Replication Explained
What you'll learn: How synchronous replication guarantees data consistency across replicas by waiting for confirmation before completing writes.
What is Synchronous Replication?
Synchronous replication is a database replication strategy where the primary database waits for at least one replica to acknowledge that data has been written before confirming the write operation to the client. Think of it like sending a certified letter — you don't consider it delivered until you receive a signed receipt.
How It Works
When a client writes data to the primary database:
- The primary receives the write request
- The primary sends the data to one or more replicas
- The primary waits for the replica(s) to write the data and send back an acknowledgment
- Only after receiving confirmation does the primary tell the client "write successful"
This waiting mechanism ensures all synchronized replicas have identical, up-to-date data at the moment the write completes.
The Core Tradeoff
Advantage: Strong consistency — if the primary fails immediately after a write, the replica has the exact same data. No data loss.
Disadvantage: Higher latency — every write operation must wait for network round-trips and replica disk writes. If a replica is slow or unavailable, writes become slow or fail entirely.
Real-World Analogy
Imagine saving a document to cloud storage that also saves to a backup drive. With synchronous replication, you see the "saved successfully" message only after both the cloud and backup drive confirm they have your file. It's slower, but you're guaranteed both copies match.
Key Takeaway: Synchronous replication prioritizes data consistency and zero data loss over write speed, making every write wait for replica acknowledgment before completion.