how to limit parallel instances and multi-thread in Azure functions

Joe White 116 Reputation points
2021-11-22T05:35:34.343+00:00

I have an azure function with a time trigger.

That time trigger grabs a batch of data and loop through it processing each record against an external API.

this API interacts with a very slow and sensitive system.

I've added this to host.json to limit parallelism

"extensions": {
"durableTask": {
"maxConcurrentActivityFunctions": 1,
"maxConcurrentOrchestratorFunctions": 1

},

How can I confirm it is working? is there a place in metrics that will display it is not popping parallel instances?

Regarding threads, the timer trigger invokes a normal foreach loop (not Parallel.ForEach). Would that be enough to guarantee each loop process one request at time?

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

Accepted answer
  1. Pramod Valavala 20,656 Reputation points Microsoft Employee Moderator
    2021-11-23T04:28:02.38+00:00

    @Joe White If you are using a normal for each loop, then it shouldn't be a problem since you are not fanning out and have only one orchestration running. You will have to check the frequency of the timer trigger though depending on your use case.

    If you need only one orchestration (that the timer trigger starts) running at any time, then you might want to leverage the Singleton Orchestration Pattern. If you need to ensure an orchestration runs for each schedule, they might have to queue them up as well.

    The settings that you have ensure that only one of each run at a time but your function app may scale out to multiple instances if each orchestration takes longer than the schedule between triggers.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.