azureazure-cosmosdbconsistency

What is the meaning of K and T in CosmosDB's single region database/account with a Bounded Staleness consistency?


As stated in the title, I'm confused as to why a distributed database like cosmosdb requires a "staleness" setting for single region accounts. According to documentation:

For a single region account, the minimum value of K and T is 10 write operations or 5 seconds. For multi-region accounts the minimum value of K and T is 100,000 write operations or 300 seconds.

...

Consistency for clients in the same region for an account with single write region = Strong

I understand that for a multi-region database, reads in another region will lag behind by K operations or T seconds, but what does it mean for a single region account? And why does K and T have different minimum values for multi-region and single region databases/accounts?

From my understanding, a single region database with Bounded Staleness consistency is exactly equivalent to a single region database with Strong consistency. What is the need for K and T variables in a single region environment when the very concept of K and T is based on multi-region?


Solution

  • K&T for a single region applies to the replica set for your data within that single region.

    When data is written to Cosmos DB it commits to a primary and two secondaries for a quorum commit. If data is not committed to the fourth replica within K or T we start returning BoundedStalenessExceeded for the writes and will start applying back pressure to writes until we are within the staleness window.