Microsoft Certified: Azure Developer Associate (AZ-204)Develop for Azure storageMedium

A web application uses Azure Cosmos DB for its product catalog. The application frequently reads product data from various geographic regions. While strong consistency is preferred, the business can tolerate slightly stale data (a few seconds) to achieve higher throughput and lower latency for read operations, especially from remote regions. Which consistency level should you configure for the Cosmos DB account?

  1. AStrong
  2. BBounded Staleness
  3. CSession
  4. DEventual
Show answer & explanation

Correct answer: B. Bounded Staleness

Bounded Staleness provides a good balance between consistency and performance. It guarantees that reads are not 'too' stale by defining a maximum time or number of versions that a replica can lag behind the primary, satisfying the requirement for slightly stale data with improved throughput and latency.

Why the other options are wrong

  • A. Strong consistency offers the freshest data but comes with higher latency and lower throughput, not meeting the performance goals.
  • C. Session consistency guarantees monotonic reads and writes for a single client session but doesn't provide a global staleness bound across all clients.
  • D. Eventual consistency offers the lowest latency and highest throughput but allows for arbitrary staleness, which might be more than 'a few seconds' and is not 'controlled'.

Cosmos DB Bounded Staleness

A consistency level that guarantees that reads are not 'too' stale. Clients can define the maximum staleness allowed, either by time interval or by the number of versions.

  • Compromise between Strong and eventual consistency.
  • Configurable time or version lag.
  • Good for globally distributed applications needing performance with controlled consistency.

Memory trick: Bounded Staleness is like a 'time-bound' promise for fresh data.

More Develop for Azure storage questions