Azure 函数 CosmosDBTrigger 不可缩放 [英] Azure Function CosmosDBTrigger unscaleable

查看:22
本文介绍了Azure 函数 CosmosDBTrigger 不可缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 CosmosDBTrigger 的 Azure 函数,该函数用于使用 Application Insights 监控的消费游戏.被监控的集合在更改提要中插入了 500,000 个.消费计划在几分钟内将实例数量增加到 15,但只有第一个实例能够处理任何更改.

I have a Azure Function with a CosmosDBTrigger working on a consumption play monitored with Application Insights. The collection being monitored has 500,000 inserts in the change feed. The consumption plan scales up the number of instances to 15 within a few minutes but only the first instance is able to process any changes.

我认为这是因为租约是由第一个实例保留的.我本质上是为 14 实例付费,什么都不做.

I assume this is because of the lease is kept by the first instance. I am essentially paying for 14 instances to do nothing.

我注意到您应该能够在 CosmosDBTrigger 上设置一个名为 LeaseOptions 的属性,但我目前在尝试时遇到错误:"Error CS0655 'LeaseOptions' is not a valid named属性参数,因为它不是有效的属性参数类型"

I noticed you are supposed to be able to set a property on CosmosDBTrigger called LeaseOptions but I currently get an error whenever I try: "Error CS0655 'LeaseOptions' is not a valid named attribute argument because it is not a valid attribute parameter type"

有没有办法扩展 CosmosDBTrigger Azure 函数,以便它可以同时被 10、20 甚至 200 个实例处理?

Is there a way to scale a CosmosDBTrigger Azure Function so it can be processed by 10, 20 or even 200 instances at a time?

推荐答案

正如 Drew 提到的,LeaseOptions 是不可配置的,但它是 即将推出.

As Drew mentioned, the LeaseOptions are not configurable, but it's something that is coming soon.

至于扩展,触发器将在 在实例之间更改馈送处理器库的设计 以平衡负载.这会在实例出现的几秒钟内发生,并且根据租约数量分配的实例数量是有限的.由于每个租约代表一个 分区键范围,在最多,每个实例将分配 1 个租约.添加超过分区键范围数量的更多实例不会增加更多并行处理.

As for the scaling, the Trigger will start sharing leases following the Change Feed Processor Library's design among the instances to balance the load. This happens within a couple of seconds that the instances appear and there is a limit on how many instances will be distributed based on the amount of leases. Since each lease represents a Partition Key Range, at maximum, they will be distributed 1 lease per instance. Adding more instances over the amount of Partition Key Ranges will not add more parallel processing.

可能是在算法可以共享租约之前创建/销毁实例.

It could be that the instances are being created / destroyed sooner than the algorithm can share the leases.

这 500,000 个插入是分布在几个分区中还是都在同一个分区中?功能是否落后于更改,或者是否以良好的速度处理它们?您是否有其他函数(在本地或在 Azure 中运行)使用相同的租约集合监视相同的集合?

Are the 500,000 inserts spread among several partitions or are all in the same partition? Is the Function lagging behind the changes or is it processing them at good speed? Do you have other Functions (either running locally or in Azure) monitoring the same collection using the same lease collection?

附带说明,您支付的不是实例数量,而是 金额执行次数.

As a side note, you are not paying for the amount of instances, but the amount of executions.

这篇关于Azure 函数 CosmosDBTrigger 不可缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆