[英]Azure function Service Bus Trigger concurrency
I'm developing an Azure Function that executes several operations in Dynamics 365 CRM.我正在开发 Azure Function,它在 Dynamics 365 CRM 中执行多个操作。 I don't fully understand how Azure Functions concurrency works.
我不完全理解 Azure 函数并发是如何工作的。 I have a Consumption Plan, my Azure Function has a function inside that is triggered by a Service Bus message.
我有一个消费计划,我的 Azure Function 里面有一个 function 由服务总线消息触发。
When I tested it the first time, the service bus received around 200 messages and the app started processing a lot of messages at the same time, making a huge load of requests to dynamics 365 that couldn't handle them.当我第一次测试它时,服务总线收到大约 200 条消息,应用程序开始同时处理大量消息,向无法处理它们的 dynamics 365 发出大量请求。 So in the Azure Portal I managed to set the max number of instances to 1, but still the function was processing many messages at one time.
因此,在 Azure 门户中,我设法将最大实例数设置为 1,但 function 仍然一次处理许多消息。 What's the best way to set a limit to that?
对此设置限制的最佳方法是什么? Using maxConcurrentCalls in host.json?
在 host.json 中使用 maxConcurrentCalls? Using maxConcurrentSessions in host.json?
在 host.json 中使用 maxConcurrentSessions? Using WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT in the app configs?
在应用配置中使用 WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT?
Also, what's the difference between setting maxConcurrentCalls at 10, and 1 function instance or setting it at 5 with 2 function instances?此外,将 maxConcurrentCalls 设置为 10 和 1 个 function 实例或将其设置为 5 和 2 个 function 实例有什么区别?
maxConcurrentCalls is the attribute configured in host.json
for the Azure Functions Service Bus Trigger. maxConcurrentCalls是在
host.json
中为 Azure 函数服务总线触发器配置的属性。
By default, the runtime of Functions processes multiple messages concurrently (default value - 16).默认情况下,Functions 的运行时并发处理多条消息(默认值 - 16)。 Set
maxConcurrentCalls
to 1 for setting up to process only a single queue or topic message at a time by the runtime.将
maxConcurrentCalls
设置为 1 以设置运行时一次仅处理单个队列或主题消息。
Also, maxConcurrentCalls
is the max no.此外,
maxConcurrentCalls
是最大数量。 of concurrent calls to the callback that should be initiate per scaled instance.对每个缩放实例应启动的回调的并发调用数。
maxConcurrentSessions - Maximum No. of Sessions handled concurrently per scaled instance. maxConcurrentSessions - 每个扩展实例同时处理的最大会话数。
This setting only applies for functions that receive a single message at a time.
此设置仅适用于一次接收一条消息的函数。
For the requirement of only one message need to be processed at a time per instance than you can use above configuration in the host.json
.对于每个实例一次只需要处理一条消息的要求,您可以在
host.json
中使用上述配置。
If your requirement is Singleton support for Functions to ensure only one function running at a time, then you need to configure this .如果你的需求是Singleton 支持Functions 保证一次只有一个 function 运行,那么你需要配置这个。
WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
This setting has no default limit, which states the max no.此设置没有默认限制,它表示最大数量。 of instances that the app can scale out to.
应用程序可以扩展到的实例数。
WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
to 1WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
设置为 1maxConcurrentCalls
to 1.maxConcurrentCalls
设置为 1。 Few References for more information:很少有参考资料以获取更多信息:
WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
and batchSize - how can I get the desired concurrency WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
和 batchSize - 如何获得所需的并发性maxConcurrentCalls
totally ignored maxConcurrentCalls
完全被忽略host.json
settings in Azure Function Service Bus Trigger explains about maxConcurrentCalls
, maxConcurrentSessions
host.json
设置官方文档Azure Function Service Bus Trigger对maxConcurrentCalls
, maxConcurrentSessions
的解释WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.