0
votes

I have an API in Azure API Management with multiple operations. One specific of those operations should have an limit execution concurrency of 1. I tried to limit the parallel execution with the following backend policie, like in the Microsoft Docs explained.

<backend>
    <limit-concurrency key="general" max-count="1">
        <forward-request timeout="120" />
    </limit-concurrency>
</backend>

https://docs.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#LimitConcurrency

Unfortunatly the behaviour of this limit is that I can execute the operation twice at the same time. The third parallel execution results in an 429 status code.

Someone has any glue why a max-count of 1 results in a max-count of 2?

1
you must implement it using DB or a Queue. - Thiago Custodio

1 Answers

0
votes

Use concurrency control we can guarantee that the backend system don’t have more than 2 concurrent calls and all calls after are queued up to a maximum limit, and processed right away as one of the 2 concurrent calls are finished. Making sure to not waste resources in retry and idle time. Using the Concurrency control is simple here is the policy:

<limit-concurrency key="general" max-count="1" timeout="120" max-queue-length="100">
    <forward-request timeout="120" />
</limit-concurrency>

For more details, you can refer to this article.