A global e-commerce platform uses Azure Cosmos DB for its product catalog. The platform experiences high read volumes from users located worldwide. The development team needs to ensure that read operations are routed to the closest replica of the Cosmos DB account to minimize latency, while write operations are consistently directed to a single primary region.
- AConfigure the Cosmos DB account with a single write region and multiple read regions, using a `ConnectionPolicy` with `PreferredLocations` based on client location.
- BUse a single-region Cosmos DB account and deploy Azure Front Door to route traffic to the region.
- CImplement client-side caching to reduce the number of read operations to Cosmos DB.
- DConfigure the Cosmos DB account with multiple write regions and enable multi-master capabilities.
Show answer & explanationAnswer & explanation
Correct answer: A. Configure the Cosmos DB account with a single write region and multiple read regions, using a `ConnectionPolicy` with `PreferredLocations` based on client location.
To achieve low-latency reads from the closest replica while maintaining a single write region, Cosmos DB should be configured with global distribution, specifying one write region and multiple read regions. The `.NET SDK`'s `ConnectionPolicy.PreferredLocations` property allows the client application to list preferred regions, ensuring that read requests are automatically routed to the closest available replica, while writes correctly go to the designated write region.
Why the other options are wrong
- B. A single-region account would not provide low-latency reads for global users, and Azure Front Door routes HTTP/S traffic, but Cosmos DB SDK handles direct connections.
- C. Client-side caching can reduce reads but doesn't guarantee low-latency reads from the closest replica for cache misses or initial loads across global users.
- D. Multiple write regions (multi-master) would allow writes from any region, which contradicts the requirement for writes to be consistently directed to a single primary region.
Cosmos DB Global Distribution (Reads/Writes)
Azure Cosmos DB global distribution allows data to be replicated across multiple Azure regions. By configuring a single write region and multiple read regions, applications can achieve low-latency reads from the closest replica while ensuring strong consistency for writes in the primary region.
- Distribute data globally for high availability and low latency.
- Can configure single-region writes or multi-master writes.
- Client SDKs use `PreferredLocations` to route reads to nearest replica.
Memory trick: Reads follow proximity, Writes follow the primary.