Read-After-Write Consistency Problem
What you'll learn: Why users sometimes can't see data they just created when using read replicas.
The Problem in Plain English
When you use database replication with read replicas, you split responsibilities: writes go to the primary, reads come from replicas. But because replication is often asynchronous (as you learned earlier), there's a delay — replication lag — before data reaches replicas.
This creates a frustrating scenario: a user submits a form, the write succeeds on the primary, then their next page load reads from a replica that hasn't received the update yet. They see stale data. Their own action appears to have failed!
The User Experience Impact
Imagine posting a comment on a social media site:
- You click "Post Comment" → write goes to primary database
- Server redirects you to view the thread → read comes from a replica
- The replica is 200ms behind (replication lag)
- Your comment isn't visible! You panic and click "Post" again, creating duplicates
This breaks user trust. Users expect to always see their own writes immediately, even if eventual consistency is acceptable for seeing other users' data.
Why This Matters
Read-after-write consistency (also called "read-your-writes" consistency) is a minimum expectation for good UX. Without it:
- Users think features are broken
- They retry operations, creating duplicate data
- Customer support tickets increase
- User satisfaction drops
The challenge is balancing read scalability (many replicas) with consistency guarantees for the writing user specifically.
Key Takeaway:
Read-after-write consistency ensures users can immediately see their own changes, but replication lag makes this difficult when reads come from replicas that haven't caught up yet.