首页 > 解决方案 > Azure 函数忽略 MaxConcurrentRequests 设置

问题描述

我有一个使用此 host.json 配置运行的 Azure 函数:

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

但是,当这个函数应用程序运行时,我可以看到有超过 2 个请求同时运行:

    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);
        }
    }

当我提高对函数的调用率时,我会记录 n 值超过 20 的日志条目,当我希望永远不会看到超过 2 时,如果这个设置值得到尊重,并且我已经正确理解了它。

标签: azure-functionsazure-function-appazure-functions-runtime

解决方案


我相信这是已知问题。https://github.com/Azure/azure-functions-host/issues/6548

核心团队已经解决了这个问题,他们预计在 12 月底发布。


推荐阅读