0

I am wondering about the parallel principle in Azure Function. If I have a batchSize of 32 and a threshold of 16. If the queue grow to large the Scale controller spins up a new function to withstand the pressure. I understand this bit. What I don't understand is: does a single instance work on the batch? That is, do I only have one function running pr batch, or does the runtime scale out and run multiple threads with the function?

Could I risk having two instances running, each with a 32 messages, and concurrently 32 threads running 32 functions pr once?

Imaging I have a function calling a webapi. This means that the api will get 64 calls at once which I don't want.

What I want is 2 functions working on 32 messages each making 1 call pr message pr function.

I hope you guys understand.

1 Answer 1

1

Yes. That is indeed how scaling works. The same is explained with a bit more details in the docs as well.

According to that, your function (one instance) could run up to 48 messages at a time (32 from a new batch + 16 from the existing batch) and could potentially scale to multiple instances depending on the queue length.

To achieve the scenario you've mentioned, you would have to

  1. Set the batchSize to 1 to avoid parallel processing per instance
  2. Set the WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT app setting to 2 to limit scale out to a max of 2 instances

Note that all 32 messages won't be loaded by either instance but will work through the queue nonetheless.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.