Azure function trigger with queue storage performance

Cairn 41 Reputation points
2024-09-08T11:30:03.5433333+00:00

I have inherited a design /implementation in production for a real-time system in we have a queue for each client and associated Azure function for each queue, but a the number of clients is increasing I am concerned about the management of this in terms of queues and functions which are on a dedicated App service plan. In effect current we have a function instance per client which can easily cope with the demand of a less than 10 of messages per second.

To me, the answer would be to use a single queue, but I am then concerned about the time taken to response to all the messages with the SLA's.

How does the triggering on Azure functions work. Does it service a single message at a time in the queue, or spin up a function instance for each message in the queue scaling to meet the demand.

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

Accepted answer
  1. Pinaki Ghatak 4,295 Reputation points Microsoft Employee
    2024-09-09T18:05:50.0566667+00:00

    Hello @Cairn Azure Functions uses a component called the scale controller to monitor the rate of events and determine whether to scale out or scale in.

    The scale controller uses heuristics for each trigger type. For example, when you're using an Azure Queue storage trigger, it scales based on the queue length and the age of the oldest queue message.

    When there are multiple queue messages waiting, the queue trigger retrieves a batch of messages and invokes function instances concurrently to process them.

    By default, the batch size is 16. When the number being processed gets down to 8, the runtime gets another batch and starts processing those messages. So the maximum number of concurrent messages being processed per function on one virtual machine (VM) is 24.

    This limit applies separately to each queue-triggered function on each VM. If your function app scales out to multiple VMs, each VM will wait for triggers and attempt to run functions. In your case, if you have a single queue, the queue trigger will retrieve a batch of messages and invoke function instances concurrently to process them.

    This will help you to manage the queues and functions more efficiently. However, the time taken to respond to all the messages will depend on the number of messages in the queue and the processing time of each message.

    You can adjust the batch size and the threshold for getting a new batch in the host.json file to optimize the performance of your function app.


    I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts, but also assist other community members who may be looking for similar solutions.

    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.