Efthymios Kalyviotis
Efthymios Kalyviotis

Reputation: 969

Azure CosmosDB Consistency guaranty

Microsoft in their documentation they state for the Consistent prefix consistency the following:

In consistent prefix option, 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.

Two paragraphs bellow that, they state:

Below are the consistency guarantees for Consistent Prefix:

  • Consistency for clients in same region for an account with single write region = Consistent Prefix

  • Consistency for clients in different regions for an account with single write region = Consistent Prefix

  • Consistency for clients writing to a single region for an account with multiple write region = Consistent Prefix

  • Consistency for clients writing to multiple regions for an account with multiple write region = Eventual

I really don't understand how clients writing to multiple regions for an account with multiple write region can have Eventual consistency guaranty. Since the Consistent prefix consistency guarantees that reads never see out-of-order writes then the statement bellow (multiple writes) should be wrong as it guarantees Eventual consistency.

Can someone help me figure out what I am missing please?

Upvotes: 2

Views: 280

Answers (1)

Mark Brown
Mark Brown

Reputation: 8763

Typically, consistency guarantees are written under the assumption it is single-region write, (single master). Because Cosmos DB provides multi-region writes (multi-master) capabilities, the consistency guarantees need further explanation to detail the behavior of the service given different numbers of readers and writers, including multi-region writes (multi-master).

When you have multiple writers and using multi-region write, data written locally within regions configured in the account are committed locally then replicated over the WAN and merged in the primary region. Once the data is merged in the primary region, it is replicated back out as fully committed to every other region in the account.

Because this happens over a WAN there is no way to guarantee that data written in multiple secondary regions will be replicated and merged in the primary region precisely in the order in which it was committed locally. Data does not always replicate at the same rate and speed in a WAN. This is both because regions are different distances apart and also because WANs can be somewhat flaky at times.

For this reason, when using multi-region writes with multiple writers, readers can only get eventual consistency guarantees.

Upvotes: 2

Related Questions