1
votes

How to see difference between maxConcurrentRequests vs FUNCTIONS_WORKER_PROCESS_COUNT in terms of concurrency and limits for Azure Functions.

We can find some definitions at https://docs.microsoft.com/en-us/azure/azure-functions/functions-best-practices that I have pasted below:

Use multiple worker processes

By default, any host instance for Functions uses a single worker process. To improve performance, especially with single-threaded runtimes like Python, use the FUNCTIONS_WORKER_PROCESS_COUNT to increase the number of worker processes per host (up to 10). Azure Functions then tries to evenly distribute simultaneous function invocations across these workers.

The FUNCTIONS_WORKER_PROCESS_COUNT applies to each host that Functions creates when scaling out your application to meet demand.

Configure host behaviors to better handle concurrency

The host.json file in the function app allows for configuration of host runtime and trigger behaviors. In addition to batching behaviors, you can manage concurrency for a number of triggers. Often adjusting the values in these options can help each instance scale appropriately for the demands of the invoked functions.

Settings in the host.json file apply across all functions within the app, within a single instance of the function. For example, if you had a function app with two HTTP functions and maxConcurrentRequests requests set to 25, a request to either HTTP trigger would count towards the shared 25 concurrent requests. When that function app is scaled to 10 instances, the ten functions effectively allow 250 concurrent requests (10 instances * 25 concurrent requests per instance).

Other host configuration options are found in the host.json configuration article https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json.

{
    "extensions": {
        "http": {
            "routePrefix": "api",
            "maxOutstandingRequests": 200,
            "maxConcurrentRequests": 100,
            "dynamicThrottlesEnabled": true,
            "hsts": {
                "isEnabled": true,
                "maxAge": "10"
            },
            "customHeaders": {
                "X-Content-Type-Options": "nosniff"
            }
        }
    }
}

EDIT:

Its not related to question, but its good to know that to>

From https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-http-webhook-trigger?tabs=csharp#limits

Limits

The HTTP request length is limited to 100 MB (104,857,600 bytes), and the URL length is limited to 4 KB (4,096 bytes). These limits are specified by the httpRuntime element of the runtime's Web.config file.

If a function that uses the HTTP trigger doesn't complete within 230 seconds, the Azure Load Balancer will time out and return an HTTP 502 error. The function will continue running but will be unable to return an HTTP response. For long-running functions, we recommend that you follow async patterns and return a location where you can ping the status of the request. For information about how long a function can run, see Scale and hosting - Consumption plan.

2
What's the question here? Yes maxConcurrentRequests and FUNCTIONS_WORKER_PROCESS_COUNT are different things.Kashyap
How to see that difference. Lets say I have Function App with FUNCTIONS_WORKER_PROCESS_COUNT=10 and maxConcurrentRequests=100. Then what will happen? My app will take up to 100 requests but 90 will be queued and 10 will be worked on. Or is this FUNCTIONS_WORKER_PROCESS_COUNT for number of async jobs that can happen in parallel for one request of 100.Jon Grey
When I was trying to trigger 30 times the function app that create Resource Group and some resources - some requests were queued, and in the end not all Resource Gropus were created, due to 10min timeout.Jon Grey
In addition to all the details in my answer below, specifically about the timeout: Don't forget the 230 second limit on HTTP TriggerKashyap

2 Answers

2
votes

How to see difference between maxConcurrentRequests vs FUNCTIONS_WORKER_PROCESS_COUNT in terms of concurrency and limits for Azure Functions.

  • Both parameters work independently.
  • Both work at host level. Not per function, not per function app, but per host.

I.e. maxConcurrentRequests is enforced across all function executions within a host irrespective of FUNCTIONS_WORKER_PROCESS_COUNT.

Few things in case it's not clear:

  • If Azure decides that your App needs to scale and creates a new host, and say there are two hosts, then values of these params are applied per host not across host.
  • If your App has multiple Functions then maxConcurrentRequests applies to-all/across Functions within this host, not per Function.
  • Default and allowed value vary by plan/language-runtime:
    • maxConcurrentRequests: The default for a Consumption plan is 100. The default for a Dedicated plan is unbounded (-1).
    • FUNCTIONS_WORKER_PROCESS_COUNT: ...default value of 1. The maximum value allowed is 10. ... This setting applies to all non-.NET languages.

Can it have more than one function app on a single host? -- Despicable me

Not sure of relation between App and Host, I think it's one-to-one.

maxConcurrentRequests = 100 does this really means that all 100 requests will be processed in parallel by a single host (Consumption plan , 1 core ,1.5GB Host )? -- Despicable me

Read this description of how scaling works. So if average CPU & Memory usage of your Function instance per request is low then it might execute them "in parallel" (of course I don't think Hosts have 100 cores, so some scheduling will happen at that level). But if the avg resource consumption / request is high then it'll automatically scale out, new hosts would be spawned with your app and after the usual cold start things, your app would be able to process more requests in parallel.

-1
votes

According to the description, it seems the two are similar but not exactly the same. Here is another document which describe the feature of FUNCTIONS_WORKER_PROCESS_COUNT in application settings for your reference.

enter image description here

If you want to know more details of the two properties, you can create an azure support request on azure portal to ask azure support team about this question. They can give you the most authoritative explanation.