Cosmos db 1RU point read latency never below 20 ms

Erik Eriksson 0 Reputation points
2024-12-09T15:51:44.4766667+00:00

Hi,

so we have several asp net core apis .7 or 8 (app services) where we are seeing average latencies for 1 RU point reads are between 20-25 ms on average in the last 30 days. The lowest registered was 10 ms.
Looking at the SLA we should almost never see this.

We have located the cosmos account in the same region as the app service and we are using direct connection.
The cosmos hosting is serverless (but that should not matter according to the SLA), and the app service plan is P1mv3. The requests vary from less than 1/s to 3/s.

Any thoughts on what we could be missing?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,704 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,710 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sai Raghunadh M 1,605 Reputation points Microsoft Vendor
    2024-12-09T20:27:12.6133333+00:00

    Hi @erik eriksson

    Thanks for the question and using MS Q&A platform.

    It appears that you are experiencing higher-than-expected latencies for 1 RU point reads in your Azure Cosmos DB setup. Considering that your app services and Cosmos DB are in the same region and you are using direct connection mode, there are several factors that could explain this behavior and steps you can take to diagnose or mitigate the issue:

    Request throttling is the most common reason for slow requests. Azure Cosmos DB throttles requests if they exceed the allocated request units for the database or container. The SDK has built-in logic to retry these requests. The request rate too large troubleshooting article explains how to check if the requests are being throttled. The article also discusses how to scale your account to avoid these problems in the future.

    If the workload varies, even with a low rate (1-3 requests per second), the serverless tier might occasionally experience delays due to unexpected concurrent loads. This could explain the latency spikes you are observing, particularly if Cosmos DB needs to dynamically scale to handle more requests.

    Please go through this documentation that might help you: Application design

    https://learn.microsoft.com/en-us/azure/cosmos-db/monitor-server-side-latency
    https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/performance-tips-query-sdk?tabs=v3&pivots=programming-language-csharp

    https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/troubleshoot-dotnet-sdk-slow-request?tabs=cpu-new

    please refer to this similar thread: https://learn.microsoft.com/en-us/answers/questions/2115745/how-to-fix-cosmos-db-latency-in-non-primary-region.

    Hope this helps. Do let us know if you 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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.