Semi-Synchronous Replication Trade-offs
What you'll learn: How waiting for at least one replica acknowledgment balances data safety against write latency.
The Challenge
You've seen synchronous replication (wait for all replicas, very safe but slow) and asynchronous replication (don't wait, fast but risky). Semi-synchronous replication sits in the middle: the primary database waits for at least one replica to confirm the write before declaring success to the client.
How It Works
When a write happens:
- Primary writes to its own log
- Sends the write to all replicas
- Waits for ONE replica to acknowledge
- Returns success to the client
- Other replicas catch up asynchronously
Think of it like sending an important package: instead of requiring everyone to sign for delivery (fully synchronous) or just dropping it and hoping (asynchronous), you wait for one person to confirm receipt before relaxing.
The Trade-off
What you gain:
- Durability: At least two copies exist (primary + one replica) before success
- Reduced replication lag risk: At least one replica is guaranteed up-to-date
- Safer failover: You have a known-good replica for promotion
What you sacrifice:
- Write latency: Slower than async (must wait for network + replica write)
- Complexity: Need to handle scenarios where no replica acknowledges in time
- Not complete safety: Still vulnerable if both primary and that one replica fail simultaneously
When to Use It
Semi-synchronous is ideal when you need stronger guarantees than async but can't afford the latency penalty of full synchronous replication. Common in financial systems, e-commerce checkouts, and critical user data updates.
Key Takeaway: Semi-synchronous replication reduces replication lag and data loss risk by waiting for one replica acknowledgment, accepting moderate write latency as the cost of improved durability.