title | description | services | author | ms.service | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|
Azure API Management policy reference - limit-concurrency | Microsoft Docs |
Reference for the limit-concurrency policy available for use in Azure API Management. Provides policy usage, settings, and examples. |
api-management |
dlepow |
azure-api-management |
reference |
07/23/2024 |
danlep |
[!INCLUDE api-management-availability-all-tiers]
The limit-concurrency
policy prevents enclosed policies from executing by more than the specified number of requests at any time. When that number is exceeded, new requests will fail immediately with the 429
Too Many Requests status code.
[!INCLUDE api-management-rate-limit-accuracy]
[!INCLUDE api-management-policy-generic-alert]
<limit-concurrency key="expression" max-count="number">
<!— nested policy statements -->
</limit-concurrency>
Attribute | Description | Required | Default |
---|---|---|---|
key | A string. Specifies the concurrency scope. Can be shared by multiple policies. Policy expressions are allowed. | Yes | N/A |
max-count | An integer. Specifies a maximum number of requests that are allowed to enter the policy. Policy expressions aren't allowed. | Yes | N/A |
- Policy sections: inbound, outbound, backend, on-error
- Policy scopes: global, workspace, product, API, operation
- Gateways: classic, v2, consumption, self-hosted, workspace
- The maximum number of requests enforced by API Management is lower when multiple capacity units are deployed in a region.
The following example demonstrates how to limit number of requests forwarded to a backend based on the value of a context variable.
<policies>
<inbound>…</inbound>
<backend>
<limit-concurrency key="@((string)context.Variables["connectionId"])" max-count="3">
<forward-request timeout="120"/>
</limit-concurrency>
</backend>
<outbound>…</outbound>
</policies>
[!INCLUDE api-management-policy-ref-next-steps]