FREE STUDY NOTES · AI-200

Azure Cosmos DB consistency levels explained: strong to eventual

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 ConsistencyLevel override can only relax consistency. To strengthen it, change the account default. (The newer ReadConsistencyStrategy, 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.

Get the whole book

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.

Amazon.co.ukKindle: coming soonPaperback: coming soon
Amazon.comKindle: coming soonPaperback: coming soon

Publishing soon on Amazon in Kindle and paperback editions.

About the book · AI-200 terms in the glossary · All AI-200 study notes

More AI-200 study notes