Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos DB State Store documentation should include a performance optimisation section #3698

Closed
KrylixZA opened this issue Aug 27, 2023 · 2 comments · Fixed by #3934
Closed
Labels
area/components content/incorrect-information Content in the docs is incorrect help wanted Extra attention is needed

Comments

@KrylixZA
Copy link
Contributor

Describe the issue
For those who are using Dapr as their only mechanism for interacting with Cosmos DB, unless they are specifically using the QueryStateAsync method (from the .NET SDK), or their language equivalent, they have no specific need to index the entire document in Cosmos DB. This process of indexing the document is an expensive operation, increases the amount of RU/s used and ultimately increases the latency of update (PUT) operations. The Dapr documentation should mention that for anyone looking to optimise the performance of their Cosmos installation, they can exclude property indexing from the indexing pattern. This is helped by the fact that the id and partitionKey fields are automatically indexed. This allows us to skip indexing the entire document with each update.

Further extending the above, the indexing mode can be changed from consistent to lazy with relative safety when using actors as the actor nature protects the system from any issues arising around the indexing mode.

For example, in Terraform, by default it reads as follows:

indexing_policy {
  indexing_mode = "consistent"

  included_path {
    "/*"
  }
}

URL of the docs
https://docs.dapr.io/reference/components-reference/supported-state-stores/setup-azure-cosmosdb/

Expected content
A specific section detailing techniques for performance optimisations should be added to the page guiding users on ways to improve performance. The above Terraform could read as follows:

indexing_policy {
  indexing_mode = "lazy"

  excluded_path {
    "/*"
  }
}

Screenshots
N/A

Additional context
It should be noted that the performance of queries, stored procedures, etc. will be slowed down by excluding all properties from indexing. If that is part of the users workflow, they should not make this change. They should only consider this if they are running into any performance issues with Cosmos DB latencies and are deliberately only using the Dapr state store interactions for GetStateAsync, SaveStateAsync, etc. (from .NET land).

@KrylixZA KrylixZA added the content/incorrect-information Content in the docs is incorrect label Aug 27, 2023
@msfussell
Copy link
Member

@KrylixZA - Would you be willing to create a PR for this and push this into the cosmosdb doc topic? You could create a new heading in this document and put the above with examples. Appreciate this

@msfussell msfussell added help wanted Extra attention is needed area/components labels Sep 13, 2023
@KrylixZA
Copy link
Contributor Author

@msfussell I would love to do so. Will try make some time to get to it this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/components content/incorrect-information Content in the docs is incorrect help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants