A company is developing an Azure Cosmos DB API for NoSQL solution that replicates data across East US and West US. The Cosmos DB account is configured with Session consistency as the default. You deploy two distinct instances of a web client, AppClient1 and AppClient2. AppClient1 writes a document update to the database. AppClient2 must immediately read the updated document, but it does not have access to AppClient1's session token. Which of the following describes the consistency behavior AppClient2 will experience when reading the updated document?
- AAppClient2 is guaranteed to read the updated data immediately because Session consistency scope automatically covers all client sessions targeting the same database container.
- BAppClient2 is guaranteed to read the updated data immediately if the developer configures the container to use a single partition key value for all documents to force them into the same physical partition.
- AppClient2 is not guaranteed to read the updated data immediately because Session consistency only guarantees read-your-writes for reads that occur within the same client session, unless the session token is explicitly passed.Answer
- DAppClient2 will experience Eventual consistency with no ordering guarantees because Session consistency falls back to Eventual consistency for all reads that occur outside the writer's active session.
Answer
AppClient2 is not guaranteed to read the updated data immediately because Session consistency only guarantees read-your-writes for reads that occur within the same client session, unless the session token is explicitly passed.
The correct answer is that AppClient2 is not guaranteed to read the updated data immediately. In Azure Cosmos DB, Session consistency is the default and provides read-your-writes, monotonic reads, and monotonic writes guarantees inside a single client session. Because AppClient2 is a separate instance and does not receive the session token of AppClient1's write, it reads data under Consistent Prefix consistency, which means it may observe a delay in replication between East US and West US.
Step-by-Step Solution
Key Concept
Session consistency scope and token passing across separate clients in Azure Cosmos DB
Estimated Time:1m 30s