Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Monotonic Reads#

Sumit Rawal answered on June 23, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


Monotonic Reads#

0

Suppose you follow the president of the United States (POTUS) on Twitter. POTUS posts two tweets in quick succession, the first one at timestamp T1 and the second one at T2. The writes go through the leader and then are in the process of getting replicated on followers F1 and F2. Luckily F1 almost immediately catches up to the leader and records both the tweets. However, F2 experiences a network partition for the time being and only replicates the first tweet.

Now, if you log into your Twitter account and navigate to POTUS Twitter timeline, your request may be routed to follower F1 which is in-sync with the leader and returns both tweets from POTUS. Say, now you refresh the browser and this time your request is routed to follower F2, which still has to copy the second POTUS tweet. Suddenly you see the POTUS Twitter timeline missing data that you had already seen the first time you navigated to that location.

In other words, you are reading older data after you already read newer data in the first query. Note that it would have served us just fine if the first query didn’t return any results as then the second query wouldn’t appear going backwards in time. The monotonic reads guarantee that one never observes stale data after already having observed the latest data. Without monotonic reads, one can observe the state/snapshot of the data at an earlier point in time after seeing state/snapshot of the data at a later time.

Two tweets t1 and t2 are made by a user.

widget

Leader forwards the tweets to the two replicas

widget

Follower#1 is successful in replicating all the tweets while follower#2 only replicates the first tweet

widget

A user fetching the Twitter timeline of POTUS, sees both the tweets since her request is served by a replica that is caught-up with the leader

widget

The next refresh request by the same user is served by a replica that is lagging behind. The user sees only the first tweet and not the second, which she had observed a moment ago.

widget

One possible solution is to direct all queries from a particular user to a given replica. In our example if all requests from our user account were directed to F2, we’d never see the Twitter timeline go backwards in time. Yes, we might not get all or the latest data but because of eventual consistency at some point in time we should receive all the updates. Monotonic reads is a weaker guarantee than strong consistency but stronger than eventual consistency.

Popularity 1/10 Helpfulness 1/10 Language whatever
Source: Grepper
Tags: whatever
Link to this answer
Share Copy Link
Contributed on Jun 23 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.