@Chaitanya Singh
Thank you for the question and for using Microsoft Q&A platform.
It sounds like you’re experiencing higher latency in the West US (WUS) region compared to the East US (EUS) region for your Azure Cosmos DB. Here are a few suggestions to help reduce the latency:
- Ensure Preferred Region Is Set Correctly in Client SDK
- Even with multi-region writes, your application in WUS should still prioritize the local WUS region for optimal latency.
- Double-check that the
preferredRegions
setting in theazure-spring-data-cosmos
library is configured to use WUS for your WUS-based service. This ensures that read requests and multi-region writes in WUS go to the nearest replica. If this setting isn’t correctly applied, requests may still be routed to EUS, leading to unnecessary latency.
https://video2.skills-academy.com/en-us/azure/developer/java/spring-framework/configuration-properties-azure-cosmos-db
- Check Connection Mode and Protocol
- Since you’re observing
rntbd://
in diagnostic logs, this means the SDK is using direct (TCP) mode. - While direct mode is usually faster, if network or routing issues are affecting latency, try switching to gateway (HTTPS) mode for the WUS service to see if it reduces latency. This change can sometimes alleviate latency issues caused by direct TCP connections in complex network environments.
- Adjust Consistency Level for WUS Service
- With multi-region writes, using a less stringent consistency level can reduce latency further.
- Try using session or consistent prefix consistency for WUS to strike a balance between consistency and latency.
- This approach is especially helpful when there’s high read latency but consistent reads from the same region are required.
- Monitor Replication Latency in Azure Monitor
- Multi-region setups can sometimes have replication lag between regions. Azure Monitor can show if there’s any delay in data replication from EUS to WUS.
- In the Azure Portal, navigate to Metrics under your Cosmos DB account and look for Replication Latency for each region.
- If WUS is experiencing significant replication latency, this may cause stale data reads or increased read latency.
- Analyze Diagnostic Logs and Azure Insights
- Diagnostic logs from the
azure-spring-data-cosmos
library and Application Insights can help pinpoint specific calls that have higher latency. - Look at metrics like Request Latency by Region to see if specific requests (e.g., queries, inserts, etc.) are more prone to latency in WUS.
For more information, please refer to these links:
https://video2.skills-academy.com/en-us/java/api/overview/azure/spring-data-cosmos-readme?view=azure-java-stable
https://video2.skills-academy.com/en-us/azure/cosmos-db/consistency-levels
https://video2.skills-academy.com/en-us/azure/cosmos-db/nosql/how-to-manage-consistency?tabs=portal%2Cdotnetv2%2Capi-async
https://video2.skills-academy.com/en-us/azure/cosmos-db/nosql/sdk-connection-modes
https://video2.skills-academy.com/en-us/azure/cosmos-db/consistency-levels#write-latency-and-strong-consistency
https://video2.skills-academy.com/en-us/azure/cosmos-db/monitor-server-side-latency
https://video2.skills-academy.com/en-us/java/api/com.azure.cosmos.cosmosclientbuilder?view=azure-java-stable
If the above steps do not help for resolving the issue, if you have a support plan could you please file a support ticket for deeper investigation and do share the SR# with us? In case if you don't have a support plan please let us know here.
Hope this helps. Do let us know if you have any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.