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:
- Turning Rate Limiting on/off
- creating the database/collection with various provisioning settings, it has zero effect on performance (even 100k RU)
- creating the db and collection manually vs with the client SDK
- "Reset Data" menu in the emulator tray menu
Further information:
- The emulator version is
2.14.6.0 (68d4ca59)
- I start the emulator from the start menu, but starting it from the command line doesn't change anything
- I am using the
Microsoft.Azure.Cosmos
nuget package, version3.22.1
- my CPU is i7-8565U, but it isn't even fully used while the test is running
- my system has 16 GB RAM
- my system is running on a fast enough SSD: "NVMe SK hynix BC501 H", but while running the test the SSD usage is between 0 and 2%.
- the performance is the same if I increase the document size to 100 KB or even 1 MB.
Creating your
CosmosClientOptions
with theAllowBulkExecution = true
setting can cause this.Source: Introducing Bulk support in the .NET SDK