Search code examples
azure-functionsazure-function-appazure-functions-runtime

Azure Function ignoring MaxConcurrentRequests setting


I have an Azure function running with this host.json config:

 {
  "version": "2.0",
  "extensions": {
    "http": {
      "routePrefix": "api",
      "maxOutstandingRequests": 200,
      "maxConcurrentRequests": 2,
      "dynamicThrottlesEnabled": false
    }
  }
}

However, when this function app runs, I can see many more than 2 requests running concurrently:

    private static int concurrency;

    [FunctionName(nameof(Page))]
    private async Task<IActionResult> Page(string arg)
    {
        var n = Interlocked.Increment(ref concurrency);
        try
        {
            this.log.Debug(n);

            // The code
        }
        finally
        {
            Interlocked.Decrement(ref n);
        }
    }

When I increase the rate of calls to the function, I have log entries for values of n over 20, when I would expect never to see more than 2, if this setting value is being respected, and if I've understood it correctly.


Solution

  • I believe this is known issue. https://github.com/Azure/azure-functions-host/issues/6548

    The Core team has already fixed the issue and they are expecting a release by end of December.