core practice · coding problem
Read-your-writes under lag
Write to primary, read replica 200ms later, lag 500ms. User sees stale read. Two fixes?
The mechanism
Replication keeps copies of data on multiple nodes for durability and read scaling. Single-leader is simple but the leader is a write bottleneck; multi-leader and leaderless trade simplicity for availability. The core tension is replication lag — followers are always slightly behind.
Expected evidence
Read-after-write from primary; session stickiness; sync quorum for critical reads.
Try this drill in the practice workspace →
Hints when you need them
- Async replication = eventual consistency.
- Route recent keys to leader.
Watch for these mistakes
- Reading from a follower and seeing stale data ("read your own writes" violation)
- Assuming failover is instant and lossless
- Ignoring replication lag in capacity and correctness planning