-
Notifications
You must be signed in to change notification settings - Fork 524
[INTERNAL] LocalQuorum: Adds documentation for LocalQuorum #3993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
microsoft-github-policy-service
merged 8 commits into
master
from
users/kirankk/local_quorum
Jul 19, 2023
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ed0e223
Draft of local-quorum documentation
kirankumarkolli d2d6db7
Adding experimental to header
kirankumarkolli 31ca8a9
Adding cross-region read guarantees
kirankumarkolli 60d4273
Reads Bounded clarification
kirankumarkolli af136e5
Adding account consistency step also
kirankumarkolli c1d9868
Non-Prod usage note at top
kirankumarkolli 69fae5e
Addressing review comments
kirankumarkolli eadd695
Some more refinement
kirankumarkolli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| > # NOT SUPPORTED FOR PRODUCTION USAGE | ||
| > # ONLY INTERNAL, DEVELOPMENT OR EXPERIMENTAL USAGE ONLY | ||
|
|
||
|
|
||
| ## Context | ||
| Distributed databases that rely on replication for high availability, low latency, or both, must make a fundamental tradeoff between the read consistency, availability, latency, and throughput. | ||
|
|
||
| The linearizability of the strong consistency model is the gold standard of data programmability. But it adds a steep price from higher write latencies due to data having to replicate and commit across large distances. Strong consistency may also suffer from reduced availability (during failures) because data can't replicate and commit in every region. Eventual consistency offers higher availability and better performance, but it's more difficult to program applications because data may not be consistent across all regions | ||
|
|
||
|
|
||
| Please refer to [public documentation](https://learn.microsoft.com/en-us/azure/cosmos-db/consistency-levels) for more details. | ||
|
|
||
|
|
||
| Many applications can benefit from having a read-write model like below | ||
|
|
||
| | Operation | Write-Region | Replicated-Regions | | ||
| |---|---|---| | ||
| |Write | Guaranteed write completion in write region | Asynchronous non-blocking replication | | ||
kirankumarkolli marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| |Read | Quorum read (read my writes) <br> Monotonic reads in the region | Quorum read (eventual reads) <br> Monotonic reads in the region | | ||
|
|
||
| > ### NOTE: cross-region reads will violate the monotonic reads guarantee | ||
|
|
||
|
|
||
| ## How-TO | ||
| It involves three stages | ||
|
|
||
| #### Create CosmosDB account with Eventual/ConsistentPrefix/Session consistency | ||
|
|
||
| #### Enabling/opt-in ability to upgrade consistency level | ||
| SDK version: MA [3.35.1](https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/changelog.md#-3351---2023-06-27) or [minimum recommended version](https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/changelog.md#-recommended-version) | ||
|
|
||
| ```C# | ||
| CosmosClientOptions clientOptions = new CosmosClientOptions(); | ||
| var upgradeConsistencyProperty = clientOptions.GetType().GetProperty("EnableUpgradeConsistencyToLocalQuorum", BindingFlags.NonPublic | BindingFlags.Instance); | ||
| upgradeConsistencyProperty.SetValue(clientOptions, true); | ||
|
|
||
| CosmosClient cosmosClient = new CosmosClient(..., clientOptions); | ||
| ``` | ||
|
|
||
| #### Per request upgrade consistency to Bounded | ||
| > ###### Please note that Bounded here is only used as HINT for SDK to do quorum reads | ||
| > ###### It will not impact CosmosDB account or write consistency levels | ||
|
|
||
| ```C# | ||
| ItemRequestOptions requestOption = new ItemRequestOptions(); | ||
| requestOption.ConsistencyLevel = ConsistencyLevel.Bounded; | ||
|
|
||
| T item = await container.ReadItemAsync<T>(docId, new PartitionKey(docPartitionKey), requestOption); | ||
| ``` | ||
|
|
||
| ```C# | ||
| QueryRequestOptions requestOption = new QueryRequestOptions(); | ||
| requestOption.ConsistencyLevel = ConsistencyLevel.Bounded; | ||
|
|
||
| await container.GetItemQueryIterator<T>(queryText, continuationToken, requestOption); | ||
| ``` | ||
|
|
||
| > #### Please use Bounded only for per request options as pattern | ||
| > #### Single master account possibly Strong == Bounded (**TBD**) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.