Database / Azure Cosmos DB interview questions
What are the five consistency levels in Azure Cosmos DB?
Consistency levels in Cosmos DB define the tradeoff between data freshness and system availability/latency when data is replicated across multiple regions or replicas. Azure Cosmos DB offers five levels, from strongest to weakest:
| Level | Guarantee | Latency Impact |
|---|---|---|
| Strong | Reads always return the most recent committed version. Linearizability guaranteed. | Highest — writes must be acknowledged by all replicas before returning |
| Bounded Staleness | Reads lag behind writes by at most K versions or T time interval (you configure both) | High — similar to Strong within a region; slower for cross-region reads |
| Session | Monotonic reads, monotonic writes, read-your-own-writes, and write-follows-reads — within a single client session | Low — the default and most practical level for most applications |
| Consistent Prefix | Reads never see out-of-order writes. If writes are A, B, C you will never read B without A. | Low — reads may be stale but always see a causally consistent prefix |
| Eventual | No ordering guarantees. Reads may return stale or out-of-order values temporarily. | Lowest — maximum throughput, minimum latency |
Session consistency is the default and the most widely used level. It gives strong consistency guarantees within a session token scope (a single user or client connection) while keeping cross-replica latency low. The session token is passed in request headers, and any replica that has caught up to that token can serve reads. This covers the most important correctness requirement for most apps: a user immediately sees their own writes.
Cosmos DB lets you relax consistency per request (weaken it, not strengthen it), so you can request eventual reads for a reporting query while keeping session consistency for writes.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
