Azure Functions functionAppScaleLimit of 1 isn't working as expected to limit concurrency on Queue Trigger

ddx1 171 Reputation points
2020-10-26T08:22:50.11+00:00

I have a Function App with multiple queue triggers set up and am trying to limit concurrency by setting functionAppScaleLimit to 1. After testing this, I'm getting timeouts because two queue triggers will execute at around the same time, but only one is allowed to do work while the other one waits.

For example, I have two queue triggers: QueueTrigger1 and QueueTrigger2 that are executed when blobs are created in two separate places in Azure Storage. I only want one of the queue triggers to be able to run at a time. I've already set the batchSize parameter to 1 so only one message is processed at a time. Each queue trigger can take up to 8 minutes for the scripts to complete execution. If both triggers are executed at around the same time, one will complete and the other will time out and then retry with a successful completion.

Here's an example log from QueueTrigger1:
2020-10-26 07:37:49.201 Executing 'Functions.QueueTrigger1' (Reason='New queue message detected on 'etl-queue-items-1'.', Id=<queue-trigger-1-id>)
//processes work in Python
2020-10-26 07:45:49.472 Executed 'Functions.QueueTrigger1' (Succeeded, Id=<queue-trigger-1-id>, Duration=480291ms)

And QueueTrigger2:
2020-10-26 07:37:56.922 Executing 'Functions.QueueTrigger2' (Reason='New queue message detected on 'etl-queue-items-2'.', Id=<queue-trigger-2-id>)
//8 minutes later
2020-10-26 07:45:49.439 Python queue trigger function processed a queue item:
//attempts to process work in Python
2020-10-26 07:47:56.927 Timeout value of 00:10:00 exceeded by function 'Functions.QueueTrigger2' (Id: '<queue-trigger-2-id>'). Initiating cancellation.
2020-10-26 07:47:56.987 Executed '{functionName}' ({status}, Id={invocationId}, Duration={executionDuration}ms)
2020-10-26 07:47:56.987 Executed 'Functions.QueueTrigger2' (Failed, Id=<queue-trigger-2-id><queue-trigger-2-id>, Duration=600043ms)

It seems unfair that the 10 minute limit is being applied to QueueTrigger2 before it even starts doing any work. How can I ensure that each queue trigger runs independently so I can be sure not to exceed the 1.5GB memory limit and not have to rely on retries?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,321 questions
Azure Queue Storage
Azure Queue Storage
An Azure service that provides messaging queues in the cloud.
97 questions
0 comments No comments
{count} votes

Accepted answer
  1. sadomovalex 3,626 Reputation points
    2020-10-27T15:01:04.703+00:00

    may be you should reconsider architecture in this case. I.e. instead of having 2 queues have only 1 queue and collect items of both types in this single queue (e.g. add additional "type" property to queued item and based on that choose which function should process each queue item). In this case there will be 1 instance running at time without timeout problems

    3 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. sadomovalex 3,626 Reputation points
    2020-10-26T15:29:36.897+00:00

    may be you can increase timeout to 20 minutes (time needed for running 2 instances): so even if 2nd function will be triggered at the same when 1st one - it will still have time to complete its work. Timeout can be changed by functionTimeout property in host.json file.