Try
↑ ↓ move↵ openesc close

Interview prep / Replication and lag

Mid · Replication and lag · System design interview question

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

Learn it by running it

The replication and lag lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms