azure-cosmosdbazure-cosmosdb-emulator

Azure Cosmos DB Emulator slow (100 ms / request)


I am trying to set up the Azure Cosmos DB Emulator to work locally with integration tests but I found that it is very slow.

I am reading a ~1KB JSON document with the container.ReadItemAsync<T> method, and awaiting the answer. I am calling this method in a loop, for 100 times.

The execution time is consistently around 9.5-10 seconds, so one request takes around 100 milliseconds which is very slow compared to the fact that this service is running locally.

Why is this so slow and how can I make it faster?
I expect at most 1 ms / request considering it is all disk I/O.

I tried the following but they didn't work:

Further information:


Solution

  • Creating your CosmosClientOptions with the AllowBulkExecution = true setting can cause this.

    the SDK will construct batches and group operations, when the batch is full, it will get dispatched, but if the batch doesn’t fill up, there is a timer that will dispatch it to make sure they complete. This timer currently is 100 milliseconds. So if the batch does not get filled up (for example, you are just sending 50 concurrent operations), then the overall latency might be affected.

    Source: Introducing Bulk support in the .NET SDK