Skip to content

Commit 08a83d9

Browse files
Merge pull request #106864 from SnehaGunda/PrivateLinks
Replacing baseball example with musical notes
2 parents faa142e + e5ee41a commit 08a83d9

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

articles/cosmos-db/consistency-levels.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,37 @@ The semantics of the five consistency levels are described here:
3535

3636
- **Strong**: Strong consistency offers a linearizability guarantee. Linearizability refers to serving requests concurrently. The reads are guaranteed to return the most recent committed version of an item. A client never sees an uncommitted or partial write. Users are always guaranteed to read the latest committed write.
3737

38-
- **Bounded staleness**: The reads are guaranteed to honor the consistent-prefix guarantee. The reads might lag behind writes by at most *"K"* versions (i.e., "updates") of an item or by *"T"* time interval. In other words, when you choose bounded staleness, the "staleness" can be configured in two ways:
38+
The following graphic illustrates the strong consistency with musical notes. After the data is written to the "East US" region, when you read the data from other regions, you get the most recent value:
39+
40+
![video](media/consistency-levels/strong-consistency.gif)
41+
42+
- **Bounded staleness**: The reads are guaranteed to honor the consistent-prefix guarantee. The reads might lag behind writes by at most *"K"* versions (that is, "updates") of an item or by *"T"* time interval. In other words, when you choose bounded staleness, the "staleness" can be configured in two ways:
3943

4044
* The number of versions (*K*) of the item
4145
* The time interval (*T*) by which the reads might lag behind the writes
4246

4347
Bounded staleness offers total global order except within the "staleness window." The monotonic read guarantees exist within a region both inside and outside the staleness window. Strong consistency has the same semantics as the one offered by bounded staleness. The staleness window is equal to zero. Bounded staleness is also referred to as time-delayed linearizability. When a client performs read operations within a region that accepts writes, the guarantees provided by bounded staleness consistency are identical to those guarantees by the strong consistency.
4448

45-
- **Session**: Within a single client session reads are guaranteed to honor the consistent-prefix (assuming a single “writer” session), monotonic reads, monotonic writes, read-your-writes, and write-follows-reads guarantees. Clients outside of the session performing writes will see eventual consistency.
49+
Bounded staleness is frequently chosen by globally distributed applications that expect low write latencies but require total global order guarantee. Bounded staleness is great for applications featuring group collaboration and sharing, stock ticker, publish-subscribe/queueing etc. The following graphic illustrates the bounded staleness consistency with musical notes. After the data is written to the "East US" region, the "West US" and "Australia East" regions read the written value based on the configured maximum lag time or the maximum operations:
50+
51+
![video](media/consistency-levels/bounded-staleness-consistency.gif)
52+
53+
- **Session**: Within a single client session reads are guaranteed to honor the consistent-prefix (assuming a single "writer" session), monotonic reads, monotonic writes, read-your-writes, and write-follows-reads guarantees. Clients outside of the session performing writes will see eventual consistency.
4654

47-
- **Consistent prefix**: Updates that are returned contain some prefix of all the updates, with no gaps. Consistent prefix consistency level guarantees that reads never see out-of-order writes.
55+
Session consistency is the widely used consistency level for both single region as well as globally distributed applications. It provides write latencies, availability, and read throughput comparable to that of eventual consistency but also provides the consistency guarantees that suit the needs of applications written to operate in the context of a user. The following graphic illustrates the session consistency with musical notes. The "West US" region and the "East US" regions are using the same session (Session A) so they both read the data at the same time. Whereas the "Australia East" region is using "Session B" so, it receives data a later but in the same order as the writes.
4856

49-
- **Eventual**: There's no ordering guarantee for reads. In the absence of any further writes, the replicas eventually converge.
57+
![video](media/consistency-levels/session-consistency.gif)
5058

51-
## Consistency levels explained through baseball
59+
- **Consistent prefix**: Updates that are returned contain some prefix of all the updates, with no gaps. Consistent prefix consistency level guarantees that read never see out-of-order writes.
5260

53-
Let's take a baseball game scenario as an example. Imagine a sequence of writes that represent the score from a baseball game. The inning-by-inning line score is described in the [Replicated data consistency through baseball](https://www.microsoft.com/en-us/research/wp-content/uploads/2011/10/ConsistencyAndBaseballReport.pdf) paper. This hypothetical baseball game is currently in the middle of the seventh inning. It's the seventh-inning stretch. The visitors are behind with a score of 2 to 5 as shown below:
61+
If writes were performed in the order `A, B, C`, then a client sees either `A`, `A,B`, or `A,B,C`, but never out of order like `A,C` or `B,A,C`. Consistent Prefix provides write latencies, availability, and read throughput comparable to that of eventual consistency, but also provides the order guarantees that suit the needs of scenarios where order is important. The following graphic illustrates the consistency prefix consistency with musical notes. In all the regions, the reads never see out of order writes:
5462

55-
| | **1** | **2** | **3** | **4** | **5** | **6** | **7** | **8** | **9** | **Runs** |
56-
| - | - | - | - | - | - | - | - | - | - | - |
57-
| **Visitors** | 0 | 0 | 1 | 0 | 1 | 0 | 0 | | | 2 |
58-
| **Home** | 1 | 0 | 1 | 1 | 0 | 2 | | | | 5 |
63+
![video](media/consistency-levels/consistent-prefix.gif)
5964

60-
An Azure Cosmos container holds the run totals for the visitors and home teams. While the game is in progress, different read guarantees might result in clients reading different scores. The following table lists the complete set of scores that might be returned by reading the visitors' and home scores with each of the five consistency guarantees. The visitors' score is listed first. Different possible return values are separated by commas.
65+
- **Eventual**: There's no ordering guarantee for reads. In the absence of any further writes, the replicas eventually converge.
66+
Eventual consistency is the weakest form of consistency because a client may read the values that are older than the ones it had read before. Eventual consistency is ideal where the application does not require any ordering guarantees. Examples include count of Retweets, Likes, or non-threaded comments. The following graphic illustrates the eventual consistency with musical notes.
6167

62-
| **Consistency level** | **Scores (Visitors, Home)** |
63-
| - | - |
64-
| **Strong** | 2-5 |
65-
| **Bounded staleness** | Scores that are at most one inning out of date: 2-3, 2-4, 2-5 |
66-
| **Session** | <ul><li>For the writer: 2-5</li><li> For anyone other than the writer: 0-0, 0-1, 0-2, 0-3, 0-4, 0-5, 1-0, 1-1, 1-2, 1-3, 1-4, 1-5, 2-0, 2-1, 2-2, 2-3, 2-4, 2-5</li><li>After reading 1-3: 1-3, 1-4, 1-5, 2-3, 2-4, 2-5</li> |
67-
| **Consistent prefix** | 0-0, 0-1, 1-1, 1-2, 1-3, 2-3, 2-4, 2-5 |
68-
| **Eventual** | 0-0, 0-1, 0-2, 0-3, 0-4, 0-5, 1-0, 1-1, 1-2, 1-3, 1-4, 1-5, 2-0, 2-1, 2-2, 2-3, 2-4, 2-5 |
68+
![video](media/consistency-levels/eventual-consistency.gif)
6969

7070
## Additional reading
7171

76.5 KB
Loading
74.5 KB
Loading
60.3 KB
Loading
76 KB
Loading
71.6 KB
Loading

0 commit comments

Comments
 (0)