Host Settings Azure Functions control throughput

Marti Kevin 31 Reputation points
2021-01-19T10:21:20.973+00:00

Hello there dear azure community

I have a question to azure functions in the python environment 3.7.* We have a function app with different queue storage triggered functions. Now we want to set for each function a maximum of executions it can perform (3. party connection restrictions). We know of Batch size, worker count, etc. but we have some struggle to get a comprehensive picture. lets say we want to regulate the throughput of 3 queue trigger functions in one function app to always only take one message from the individual queue. How do we achieve that, such that the throughput for every function is 0 or at maximum 1? The queue trigger functions should also not interfere with each other.

Help would be much appreciated, thanks for any value doc or advice. Thanks

Best regards

Kevin Marti

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

2 answers

Sort by: Most helpful
  1. Marti Kevin 31 Reputation points
    2021-01-20T14:13:25.49+00:00

    In the Docu it says:

    If you want to minimize parallel execution for queue-triggered functions in a function app, you can set the batch size to 1. This setting eliminates concurrency only so long as your function app runs on a single virtual machine (VM).

    Now my question: if we set batchSize to 1 (we did) and disallow automatic vm scaleout (we did). Does each of the three queue trigger functions work concurrent if they have messages in their queues or does the function app only allow one message and one queue trigger function to be processed? Our lead engineer thinks it does the second one. We want only one messgage per queue trigger function but all three functions can work concurrently. And we dont want one queue to do three messages at once.

    I am asking this question because to our knowledge the docu is not clear on this. It would really help if you worked on your docu on vm, function app, worker, and azure function and the settings let us better understand the inner workings and configuration to our needs.

    Thank you very much

    Kevin Marti


  2. JayaC-MSFT 5,606 Reputation points
    2021-01-20T10:22:57.08+00:00

    @Marti Kevin You may consider to configure the batch size in the host file.

    If you want to avoid parallel execution for messages received on one queue, you can set batchSize to 1. However, this setting eliminates concurrency only so long as your function app runs on a single virtual machine (VM). If the function app scales out to multiple VMs, each VM could run one instance of each queue-triggered function.

    In order to control that , please look into : https://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings#website_max_dynamic_application_scale_out

    For your reference, https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue-trigger?tabs=csharp#concurrency

    -------------------------

    Update:

    In this scenario, I believe, you want to force a lock onto the message so that no receiver can pick it up until it is processed. ( correct me if I am wrong here). For that I would suggest you to explore the https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue-trigger?tabs=csharp#message-metadata and see if “NextVisibleTime” could be of any use and “Visibility Time out” https://learn.microsoft.com/en-us/connectors/azurequeues/#when-there-are-messages-in-a-queue
    https://learn.microsoft.com/en-us/azure/storage/queues/storage-dotnet-how-to-use-queues?tabs=dotnet#change-the-contents-of-a-queued-message

    I would also like to suggest the service bus option, if possible, in this case : https://learn.microsoft.com/en-us/rest/api/servicebus/peek-lock-message-non-destructive-read

    You had mentioned timeout issue as well. In case of timeouts there are certain things we can consider. If you are in dynamic i.e. consumption plan then the timeout value has a limitation. You may opt for better plans which will offer you better compute resources and you can maximize the time out value as well.

    If this is a python function, then you must remember single threaded architecture of Python. SO you can either increase the number of worker processes by maximizing the or you may look into async calls.

    In this kind of scenarios, it is also important whether you are processing the data efficiently. If there is there are any connections to any other application which are not being closed properly or if there are any blocking HTTP sync calls or IO bound calls which will block the entire event loop ( use async to avoid this).

    Please let me know if this helps.

    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.