I’m creating an application that will use Azure Functions combined with Azure Bus Service. The idea is to process the messages from the bus in Azure Functions.
I’m reading the documentation and I want to confirm one thing:
In the Consumption plan, do the instances automatically grow based on the triggers, with a limit of 100 instances? That is, if at any given time 50 messages arrive in my queue, will 50 functions be activated at the same time in parallel?
Thanks
2
Answers
Yes, in the Consumption plan, Azure Functions automatically scale based on demand. If 50 messages hit your Service Bus queue, up to 50 functions could run in parallel, depending on available resources. The plan can scale up to 200 concurrent instances. So, Azure will handle scaling for you, but keep an eye on your configuration to ensure optimal performance.
You are right in your understanding, however there are these considerations you should be aware of
By default, for Service Bus triggers, Azure Functions processes messages one at a time within a single instance. However, you can configure concurrent message processing using the maxConcurrentCalls setting in the host.json file.
The maximum number of instances that can be created is indeed 100 for most regions in the Consumption plan. However: a)This limit is per function app, not per individual function. b) Some regions have a lower limit of 60 instances. c) You can request a higher limit by contacting Azure support.
The scaling is not always instantaneous or on a 1:1 ratio with incoming messages. Azure uses an algorithm to determine when to scale out, considering factors like:
a) The rate of incoming messages, b) How long it takes to process each message
c) Available resources
prefetchCount: Determines how many messages the Functions runtime will retrieve in advance
maxConcurrentCalls: Sets the maximum number of messages that can be processed concurrently on a single instance.
maxAutoRenewDuration: Sets the maximum duration within which the message lock will be renewed automatically.