【问题标题】:Azure Functions functionAppScaleLimit of 1 isn't working as expected to limit concurrency on Queue TriggerAzure Functions functionAppScaleLimit of 1 未按预期工作以限制队列触发器上的并发
【发布时间】:2021-02-08 11:56:46
【问题描述】:

我有一个设置了多个队列触发器的函数应用程序,并试图通过将functionAppScaleLimit 设置为1 来限制并发。对此进行测试后,我得到了超时,因为两个队列触发器将同时执行,但只有一个被允许在另一个等待时工作。

例如,我有两个队列触发器:QueueTrigger1QueueTrigger2,当在 Azure 存储中的两个不同位置创建 blob 时执行它们。我只希望一个队列触发器能够一次运行。我已经将batchSize 参数设置为1,因此一次只处理一条消息。每个队列触发器最多可能需要 8 分钟才能完成脚本的执行。如果两个触发器几乎同时执行,一个将完成,另一个将超时,然后重试成功完成。

这是来自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)

还有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)

QueueTrigger2 开始执行任何工作之前就对其应用了 10 分钟的限制,这似乎是不公平的。如何确保每个队列触发器独立运行,从而确保不超过 1.5GB 内存限制并且不必依赖重试?

编辑:我正在使用 Linux 消费计划,所以我的 functionTimeout 仅限 10 分钟。

【问题讨论】:

    标签: azure azure-functions azure-blob-storage azure-function-app azure-queues


    【解决方案1】:

    您已经将functionAppScaleLimit 设置为1,您应该做的另一件事是根据此documenthost.json 文件中的batch size 设置为1

    如果您想最小化队列触发的并行执行 函数应用中的函数,您可以将批量大小设置为 1。这 只要您的函数应用运行,设置就会消除并发性 在单个虚拟机 (VM) 上。

    【讨论】:

      猜你喜欢
      • 2021-02-23
      • 2017-07-03
      • 1970-01-01
      • 2013-07-19
      • 2013-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-11
      相关资源
      最近更新 更多