The five Cosmos DB consistency levels, their RU and latency trade-offs, and when to choose each.
From Ultra Transcenders AI-200 by Tony Rough (publishing soon)
Cosmos DB offers five consistency levels between strong and eventual, set as a default on the account and optionally relaxed per client or request. The choice trades read freshness against latency, availability, read RU cost and RPO.
| Level | Guarantee | Read quorum | Write quorum | Typical use |
|---|---|---|---|---|
| Strong | Linearisable: reads return the latest committed write | Local minority (2 of 4 replicas) | Global majority (every region) | Data that must never be stale; single write region only |
| Bounded staleness | Reads lag writes by at most K versions or T time | Local minority | Local majority | Near-strong across regions with a single write region |
| Session (default) | Read-your-writes and write-follows-reads within a session | Single replica, using the session token | Local majority | Most user-centric apps |
| Consistent prefix | Writes within a transaction are seen together and in order | Single replica | Local majority | Ordering matters, staleness doesn’t |
| Eventual | No ordering guarantee; reads may go backwards | Single replica | Local majority | Counters such as likes or retweets |
Key facts:
In Python, a client-level override is passed when the client is created:
client = CosmosClient(endpoint, credential=credential, consistency_level="Eventual")Common trap: Using a client or request override to get stronger consistency than the account default - the traditional
ConsistencyLeveloverride can only relax consistency. To strengthen it, change the account default. (The newerReadConsistencyStrategy, which can strengthen per read, is a preview feature of the .NET and Java SDKs in direct mode only.)
Bounded staleness checks staleness only across regions; in a single-region account it gives the same write guarantees as session or eventual consistency while still doubling read RU cost.
This note is one section of Ultra Transcenders AI-200: Developing AI Cloud Solutions on Azure, an independent study guide that explains every topic the exam covers by technology, with comparison tables, diagrams and the common traps, plus a glossary linked to Microsoft Learn.
Publishing soon on Amazon in Kindle and paperback editions.
About the book · AI-200 terms in the glossary · All AI-200 study notes
How to tell commands, discrete events and telemetry streams apart and pick the right Azure messaging service.
How to define KEDA scalers for queues, topics and other event sources in Container Apps.
What creates a new revision, and how single and multiple revision modes change deployments.
Exact search versus approximate IVFFlat, HNSW and DiskANN indexes, and how to tune each for recall and latency.
The main Redis caching patterns, how to expire and invalidate entries, and the trade-offs of each.
How the Functions hosting plans differ in scaling, networking and cold start, and which to choose.
Control plane versus data plane, Azure RBAC versus vault access policies, and the roles apps need.