MolteNolte
MolteNolte

Reputation: 183

CosmosDB: Can I reduce the consumption of RUs when I split the document (in case of updating)?

I have a question regarding CosmosDB and how to deal with the costs and RUs. Lets say I have JSON document which is around 100KB big. Now when I want to update a property and use an upsert the cosmos will do a replace which is essentially a delete and create which will result in relatively high consumption of RU right?

  1. My first question is, can I reduce the amount of RUs for updating when I split the file into smaller parts? Let's say 10x 10KB documents. Because then a smaller document has to be replaced and it needs less CPU etc.

So this would be the case for upserts. But now there is a game changer for ComsosDB called partial update.

  1. How would it be in this case? Would smaller files lead to a decrease in RU consumption? Because in the background cosmos has to parse the file and insert the new property. Bigger file more to parse more consumption of RU?

  2. My last question is: Will the split into more files lead to higher consumption of RUs because I have to do 10 requests instead of one?

Upvotes: 2

Views: 1285

Answers (1)

Mark Brown
Mark Brown

Reputation: 8763

I'm going to preface my answer with the comment that anything performance related is something that users need to test themselves because the benefits or trade-offs can vary widely. There is however some general guidance around this.

In scenarios where you have very large documents with frequent updates on a small number of properties, it is often better to shred that document with one document that has the frequently updated properties and another that has the static properties. Smaller documents consume less RU/s to update and also reduce the load on the client and network payload.

Partial updates provides zero benefit over Update or Upsert for RU/s regardless of whether you shred the document or not. The service still needs to patch and merge the entire document. It will only reduce CPU consumption and network payload due to the smaller amount of data.

Upvotes: 4

Related Questions