Concurrency settings for activity functions in a durable function on Flex Consumption Plan

David Meltzer 0 Reputation points
2025-01-10T02:36:17.2533333+00:00

I have an Azure Functions Durable Function, written in Python, that I have migrated from a Consumption Plan to a Flex Consumption Plan. I am trying to understand the available concurrency settings.

On the Consumption Plan, you could set FUNCTIONS_WORKER_PROCESS_COUNT and PYTHON_THREADPOOL_THREAD_COUNT to determine the per-worker configuration. On the Flex Consumption Plan, FUNCTIONS_WORKER_PROCESS_COUNT is no longer available.

Is the implication of this that the Flex Consumption Plan will always use 1 worker process per instance, and the durableTask/maxConcurrentActivityFunctions should always be limited to thePYTHON_THREADPOOL_THREAD_COUNT ?

Or can I set durable as a --trigger-type and set perInstanceConcurrency with az functionapp scale config set?

Or something else?

Source material:

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,590 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Pinaki Ghatak 5,575 Reputation points Microsoft Employee
    2025-01-10T14:17:03.9066667+00:00

    Hello @David Meltzer

    On the Flex Consumption Plan, the FUNCTIONS_WORKER_PROCESS_COUNT setting is not available, so the implication is that the plan will always use one worker process per instance.

    Therefore, the durableTask/maxConcurrentActivityFunctions should be limited to the PYTHON_THREADPOOL_THREAD_COUNT.

    You can set the durable trigger type and set perInstanceConcurrency with az functionapp scale config set to configure the concurrency limits for the Durable Functions.

    Alternatively, you can also configure the concurrency limits for activity, orchestrator, and entity functions in the host.json file using the durableTask/maxConcurrentActivityFunctions and durableTask/maxConcurrentOrchestratorFunctions settings.

    These settings control the maximum number of orchestrator, entity, or activity functions that are loaded into memory on a single worker. Please note that the language runtime you select may impose strict concurrency restrictions on your functions. For example, Durable Function apps written in Python or PowerShell may only support running a single function at a time on a single VM. If the language runtime you are using places a restriction on concurrency, you should update the Durable Functions concurrency settings to match the concurrency settings of your language runtime.


    This should get you started.

    0 comments No comments

  2. Thiago Almeida 11 Reputation points Microsoft Employee
    2025-02-07T16:44:03.79+00:00

    Is the implication of this that the Flex Consumption Plan will always use 1 worker process per instance, and the durableTask/maxConcurrentActivityFunctions should always be limited to thePYTHON_THREADPOOL_THREAD_COUNT ?

    Yes, the Flex Consumption plan will always use 1 worker process per instance. PYTHON_THREADPOOL_THREAD_COUNT currently defaults to 1000 but it will smartly reuse threads.

    Or can I set durable as a --trigger-type and set perInstanceConcurrency with az functionapp scale config set?

    The only trigger type supported for this perInstanceConcurrency setting is http. For Durable the concurrency is set in host.json as pe what you found. As per the doc, the relevant settings are durableTask/maxConcurrentActivityFunctions for activity functions and durableTask/maxConcurrentOrchestratorFunctions for both orchestrator and entity functions. In Flex Consumption these settings control the maximum number of orchestrator, entity, or activity functions that are loaded per instance of the app, and therefore tell the app how to scale (i.e., if there's 10 activities created at the same time but the activity concurrency is set to 1, you should see the app scale to ~10 instances).

    0 comments No comments

  3. Manu WINDELS 0 Reputation points
    2025-03-24T14:56:20.9133333+00:00

    Please note that the language runtime you select may impose strict concurrency restrictions on your functions. For example, Durable Function apps written in Python or PowerShell may only support running a single function at a time on a single VM. If the language runtime you are using places a restriction on concurrency, you should update the Durable Functions concurrency settings to match the concurrency settings of your language runtime.

    Where can I find the concurrency restrictions for the language runtime (Python in my case) ?

    "...may only support a single function.." is a bit vague and ambiguous.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.