How-To: Control concurrency and rate limit applications

    A common scenario in distributed computing is to only allow for a given number of requests to execute concurrently. Using Dapr, you can control how many requests and events will invoke your application simultaneously.

    Note that this rate limiting is guaranteed for every event that’s coming from Dapr, meaning Pub/Sub events, direct invocation from other services, bindings events etc. Dapr can’t enforce the concurrency policy on requests that are coming to your app externally.

    Watch this video on how to control concurrency and rate limiting “.

    Without using Dapr, a developer would need to create some sort of a semaphore in the application and take care of acquiring and releasing it. Using Dapr, there are no code changes needed to an app.

    Setting app-max-concurrency using the Dapr CLI

    To set app-max-concurrency with the Dapr CLI for running on your local dev machine, add the flag:

      The above examples will effectively turn your app into a single concurrent service.