Microsoft Certified: Azure Developer Associate (AZ-204)Develop for Azure storageHard
A global e-commerce platform uses Azure Cosmos DB for its product catalog. The platform is deployed in multiple Azure regions (e.g., East US, West US, Europe North). Product data is updated in a primary region (East US) but read frequently by users worldwide. To ensure that users always see the most up-to-date product information, even if there's a slight delay in replication, and to handle potential primary region outages gracefully, which consistency level should be configured for the Cosmos DB account?
- AStrong
- BSession
- CConsistent Prefix
- DEventual
Show answer & explanationAnswer & explanation
Correct answer: A. Strong
Strong consistency guarantees that reads always return the most recently written data, regardless of the region. While it incurs higher latency and cost due to synchronous replication, it explicitly meets the requirement of users always seeing the most up-to-date product information and handling potential primary region outages by ensuring all replicas are consistent before acknowledging a write.
Why the other options are wrong
- B. Session consistency ensures that a client session always reads its own writes, but other clients might see older data, which doesn't meet the 'users always see most up-to-date' requirement globally.
- C. Consistent Prefix guarantees that updates are returned in order, but may still return an older version of data if the latest write hasn't propagated.
- D. Eventual consistency allows for stale reads and does not guarantee the latest data, failing the primary requirement.
Cosmos DB Strong Consistency
The highest consistency level in Azure Cosmos DB, guaranteeing that reads always return the most recent committed version of an item.
- All replicas are consistent before a write is acknowledged.
- Global order of operations is maintained.
- Highest latency for writes, potentially higher cost, but no stale reads.
Memory trick: Consistency levels are a spectrum, from 'eventually agrees' to 'always agrees'.