docs/daprdocs/content/en/developing-applications/middleware/middleware-rate-limit.md

1.1 KiB

type title linkTitle weight description type
docs How-To: Rate limiting Rate limiting 1000 Use Dapr rate limit middleware to limit requests per second docs

The Dapr Rate limit [HTTP middleware]({{< ref middleware-concept.md >}}) allows restricting the maximum number of allowed HTTP requests per second.

Middleware component definition

In the following definition, the maximum requests per second are set to 10:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: ratelimit
spec:
  type: middleware.http.ratelimit
  metadata:
  - name: maxRequestsPerSecond
    value: 10

Once the limit is reached, the request will return HTTP Status code 429: Too Many Requests.

Referencing the rate limit middleware

To be applied, the middleware must be referenced in a [Dapr Configuration]({{< ref configuration-concept.md >}}). See [Middleware pipelines]({{< ref "middleware-concept.md#customize-processing-pipeline">}}).

  • [Middleware concept]({{< ref middleware-concept.md >}})
  • [Dapr configuration]({{< ref configuration-concept.md >}})