diff --git a/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md b/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md index 22a8e8293..b1e349f3a 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md +++ b/daprdocs/content/en/developing-applications/building-blocks/state-management/state-store-ttl.md @@ -1,7 +1,7 @@ --- type: docs -title: "State Time-to-Live (TTL)" -linkTitle: "State TTL" +title: "How-To: Set state Time-to-Live (TTL)" +linkTitle: "How-To: Set state TTL" weight: 500 description: "Manage state with time-to-live." --- diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/cosmosdb.md b/daprdocs/content/en/reference/components-reference/supported-bindings/cosmosdb.md index 163fe8d3d..57d71e8b9 100644 --- a/daprdocs/content/en/reference/components-reference/supported-bindings/cosmosdb.md +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/cosmosdb.md @@ -46,7 +46,7 @@ The above example uses secrets as plain strings. It is recommended to use a secr | masterKey | Y | Output | The CosmosDB account master key | `"master-key"` | | database | Y | Output | The name of the CosmosDB database | `"OrderDb"` | | collection | Y | Output | The name of the container inside the database. | `"Orders"` | -| partitionKey | Y | Output | The name of the partitionKey to extract from the payload and is used in the container | `"OrderId"`, `"message"` | +| partitionKey | Y | Output | The name of the key to extract from the payload (document to be created) that is used as the partition key. This name must match the partition key specified upon creation of the Cosmos DB container. | `"OrderId"`, `"message"` | For more information see [Azure Cosmos DB resource model](https://docs.microsoft.com/azure/cosmos-db/account-databases-containers-items). @@ -56,6 +56,31 @@ This component supports **output binding** with the following operations: - `create` +## Best Practices for Production Use + +Azure Cosmos DB shares a strict metadata request rate limit across all databases in a single Azure Cosmos DB account. New connections to Azure Cosmos DB assume a large percentage of the allowable request rate limit. (See the [CosmosDB documentation](https://docs.microsoft.com/azure/cosmos-db/sql/troubleshoot-request-rate-too-large#recommended-solution-3)) + +Therefore several strategies must be applied to avoid simultaneous new connections to Azure Cosmos DB: + +- Ensure sidecars of applications only load the Azure Cosmos DB component when they require it to avoid unnecessary database connections. This can be done by [scoping your components to specific applications]({{< ref component-scopes.md >}}#application-access-to-components-with-scopes). +- Choose deployment strategies that sequentially deploy or start your applications to minimize bursts in new connections to your Azure Cosmos DB accounts. +- Avoid reusing the same Azure Cosmos DB account for unrelated databases or systems (even outside of Dapr). Distinct Azure Cosmos DB accounts have distinct rate limits. +- Increase the `initTimeout` value to allow the component to retry connecting to Azure Cosmos DB during side car initialization for up to 5 minutes. The default value is `5s` and should be increased. When using Kubernetes, increasing this value may also require an update to your [Readiness and Liveness probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/). + +```yaml +spec: + type: bindings.azure.cosmosdb + version: v1 + initTimeout: 5m + metadata: +``` + +## Data format + +The **output binding** `create` operation requires the following keys to exist in the payload of every document to be created: +- `id`: a unique ID for the document to be created +- ``: the name of the partition key specified via the `spec.partitionKey` in the component definition. This must also match the partition key specified upon creation of the Cosmos DB container. + ## Related links - [Basic schema for a Dapr component]({{< ref component-schema >}}) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-azure-cosmosdb.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-azure-cosmosdb.md index db53ee78b..f1d3c3450 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-azure-cosmosdb.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-azure-cosmosdb.md @@ -64,6 +64,25 @@ In order to setup CosmosDB as a state store, you need the following properties: - **Database**: The name of the database - **Collection**: The name of the collection +## Best Practices for Production Use + +Azure Cosmos DB shares a strict metadata request rate limit across all databases in a single Azure Cosmos DB account. New connections to Azure Cosmos DB assume a large percentage of the allowable request rate limit. (See the [CosmosDB documentation](https://docs.microsoft.com/azure/cosmos-db/sql/troubleshoot-request-rate-too-large#recommended-solution-3)) + +Therefore several strategies must be applied to avoid simultaneous new connections to Azure Cosmos DB: + +- Ensure sidecars of applications only load the Azure Cosmos DB component when they require it to avoid unnecessary database connections. This can be done by [scoping your components to specific applications]({{< ref component-scopes.md >}}#application-access-to-components-with-scopes). +- Choose deployment strategies that sequentially deploy or start your applications to minimize bursts in new connections to your Azure Cosmos DB accounts. +- Avoid reusing the same Azure Cosmos DB account for unrelated databases or systems (even outside of Dapr). Distinct Azure Cosmos DB accounts have distinct rate limits. +- Increase the `initTimeout` value to allow the component to retry connecting to Azure Cosmos DB during side car initialization for up to 5 minutes. The default value is `5s` and should be increased. When using Kubernetes, increasing this value may also require an update to your [Readiness and Liveness probes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/). + +```yaml +spec: + type: state.azure.cosmosdb + version: v1 + initTimeout: 5m + metadata: +``` + ## Data format To use the CosmosDB state store, your data must be sent to Dapr in JSON-serialized. Having it just JSON *serializable* will not work. diff --git a/daprdocs/layouts/partials/navbar.html b/daprdocs/layouts/partials/navbar.html index e1dc682d4..5a2bc8fd6 100644 --- a/daprdocs/layouts/partials/navbar.html +++ b/daprdocs/layouts/partials/navbar.html @@ -14,7 +14,7 @@ {{ end }} {{ $url := urls.Parse .URL }} {{ $baseurl := urls.Parse $.Site.Params.Baseurl }} - {{ .Name }} + {{ .Name }} {{ end }} {{ if .Site.Params.versions }} diff --git a/daprdocs/layouts/partials/page-meta-links.html b/daprdocs/layouts/partials/page-meta-links.html index bd55efdf3..6bf0d95a1 100644 --- a/daprdocs/layouts/partials/page-meta-links.html +++ b/daprdocs/layouts/partials/page-meta-links.html @@ -21,8 +21,8 @@ {{ $newPageQS := querify "value" $newPageStub.Content "filename" "change-me.md" | safeURL }} {{ $newPageURL := printf "%s/new/%s?%s" $gh_repo $gh_repo_path $newPageQS }} - {{ T "post_edit_this" }} - {{ T "post_create_issue" }} + {{ T "post_edit_this" }} + {{ T "post_create_issue" }} {{ end }} {{ end }} diff --git a/daprdocs/layouts/partials/version-banner.html b/daprdocs/layouts/partials/version-banner.html index 0436da130..09b705b07 100644 --- a/daprdocs/layouts/partials/version-banner.html +++ b/daprdocs/layouts/partials/version-banner.html @@ -8,7 +8,7 @@ {{ with $current_version }}

The documentation you are viewing is for Dapr {{ . | markdownify }} which is an older version of Dapr. {{ with $latest_version }}For up-to-date documentation, see the - latest version.

+ latest version.

{{ end }} {{ end }}