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

A financial application uses Azure Cosmos DB for its transaction history. The application requires that all reads reflect the most recent write, regardless of the user's geographical location. Data consistency is paramount, even if it means slightly higher latency for read operations. Which Cosmos DB consistency model should be configured?

  1. ASession
  2. BConsistent Prefix
  3. CEventual
  4. DStrong
Show answer & explanation

Correct answer: D. Strong

Strong consistency guarantees that all reads reflect the most recent write across all regions. While it can introduce higher latency, it ensures data is always up-to-date, meeting the requirement for 'all reads reflect the most recent write' and 'data consistency is paramount'.

Why the other options are wrong

  • A. Session consistency guarantees ordered reads and writes within a single client session, but not across different sessions or global reads.
  • B. Consistent Prefix ensures reads return a prefix of all writes, but not necessarily the absolute latest write globally.
  • C. Eventual consistency offers the lowest latency but provides no ordering guarantee for reads, not suitable for 'most recent write' requirement.

Cosmos DB Strong Consistency

Strong consistency in Azure Cosmos DB guarantees that all reads return the most recent committed version of an item. This provides the highest level of data consistency across all replicas, at the cost of potentially higher latency and lower throughput compared to weaker models.

  • Reads always see the latest committed write.
  • Global consistency across all regions.
  • Highest data consistency guarantee.
  • Can result in higher latency for reads and writes.
  • Suitable for scenarios where data integrity is paramount.

Memory trick: Strong, Bounded, Session, Prefix, Eventual: The consistency spectrum.

More Develop for Azure storage questions