A globally distributed web application uses an Azure Cosmos DB API for NoSQL account with Session consistency. The account has a write region in East US and a read region in West US. Users report that when they update their profile on a mobile app and immediately view it on a web browser, the updates are not visible. You need to resolve this issue in the most cost-effective manner while maintaining low latency. Which of the following actions should you perform?
- Extract the session token from the write response on the mobile app and pass it to the read request on the web browser client.Answer
- BRely on the default Session consistency configuration without changes, because Session consistency natively guarantees read-your-writes consistency across different client sessions and devices.
- CRecreate the Cosmos DB container using a new partition key that has lower cardinality to ensure that data replicates faster between regions.
- DChange the default consistency level of the Azure Cosmos DB account to Strong consistency.
Answer
Extract the session token from the write response on the mobile app and pass it to the read request on the web browser client.
Extracting the session token from the write response and passing it to the read request allows the session context to be shared across distinct client instances. This satisfies the read-your-writes requirement for different devices while preserving the low latency and low cost of Session consistency.
Step-by-Step Solution
Key Concept
Session consistency token passing in Azure Cosmos DB