A user submits a form and the next page, served by a follower, does not show it. Explain what happened and how you would fix it.
Sketch your own answer first, then compare it with the one below.
A strong answer
The write went to the leader and the read went to a follower that had not applied it yet. The user has lost read-your-writes, which says that a client sees its own earlier writes.
There are several fixes. Route reads to the leader for a short time after a user writes, or for data the user is likely to have changed, such as their own profile. Or give the client a token, for example the log position of its last write, and let a follower serve the read only if it has applied at least that position, otherwise wait briefly or send the read to the leader. Or read from a follower only if its measured lag is below a threshold.
All of these cost something. More reads land on the leader, so the followers help less. With several data centres, the token has to travel with a client that moves between them. And none of it makes the data fresh for everybody: it only keeps one user's view consistent with their own actions.
Sources
- Douglas Terry, Alan Demers, Karin Petersen, Mike Spreitzer, Marvin Theimer, Brent Welch (1994). Session Guarantees for Weakly Consistent Replicated Data.
- Martin Kleppmann (2017). Designing Data-Intensive Applications.