Single-Leader Replication for Strong Consistency
What you'll learn: How synchronous replication to followers before acknowledging writes creates strong consistency guarantees in distributed systems.
The Core Problem
In previous lessons, you learned about consensus algorithms and the high cost of strong consistency. One practical way to achieve strong consistency is through single-leader replication with synchronous writes. This means: one node accepts all writes, and it waits for follower nodes to confirm they've received the data before telling the client "success."
How It Works
Think of it like a teacher taking attendance. The teacher (leader) doesn't mark a student as "present" in the official record until they've confirmed with their assistant (follower) that the name was written in the backup logbook. Only after both records match does the teacher say "confirmed."
In a database:
- Client sends a write to the leader
- Leader writes to its own storage
- Leader synchronously sends the write to one or more followers
- Leader waits for follower acknowledgments
- Only after confirmation does the leader respond to the client
The Strong Consistency Guarantee
Because followers confirm the write before the client receives success, any subsequent read—from the leader or a synchronous follower—will see that write. You've achieved linearizability: operations appear to happen in real-time order, even across nodes.
The Trade-off
This approach sacrifices some availability and adds latency. If a follower is slow or unreachable, writes block or fail. You're choosing consistency over speed—the classic CP choice from CAP Theorem.
Key Takeaway: Single-leader replication with synchronous followers achieves strong consistency by blocking write acknowledgments until replicas confirm receipt, guaranteeing all readers see the latest data at the cost of higher latency and reduced availability.