有Azure函数有多个输出绑定是否存在性能方面的顾虑?

huangapple go评论62阅读模式
英文:

Are there any performance concerns with an Azure function that has many output bindings?

问题

我有一个Azure函数,它具有CosmosDB更改Feed触发器,我想要用它来填充6个不同的物化视图。为了实现这一目标,我添加了6个不同的CosmosDbOutput绑定。是否存在使用这么多输出绑定的性能问题?我似乎找不到任何提到一个函数上有大量绑定的文档。函数是否有绑定数量的限制?Azure函数正在监听的摄入表每分钟可能会接收数万次更新,所有这些更改都需要upsert到所有6个物化视图中。

在我的项目中使用CosmosAsyncClient相比在函数中使用输出绑定有什么优势吗?

英文:

I have an Azure function that has a CosmosDB change feed trigger that I would like to populate 6 different materialized views. To accomplish this, I added 6 different CosmosDbOutput bindings. Are there any performance concerns with that many output bindings? I can't seem to find any documentation that mentions large amounts of bindings on one function. Do functions even have a limit to the amount of bindings they have? The ingestion table that the azure function is listening to may get tens of thousands of updates per minute, and all these changes need to upsert into all 6 materialized views.

Is there any advantage of using the CosmosAsyncClient in my project instead of using output bindings in the function?

@FunctionName("ingestionToMaterializedViews")
    public void CosmosTriggerAndOutput(
            @CosmosDBTrigger(
                    name = "cfTrigger",
                    databaseName = "%CosmosDBDatabaseName%",
                    collectionName = "ingestion",
                    leaseCollectionName = "leases",
                    connectionStringSetting = "",
                    createLeaseCollectionIfNotExists = true) Object inputItem,
            @CosmosDBOutput(
                    name = "a",
                    databaseName = "%CosmosDBDatabaseName%",
                    collectionName = "testNameA",
                    connectionStringSetting = "%CosmosDBConnectionString%") OutputBinding<List<Item>> outputA,
            @CosmosDBOutput(
                    name = "b",
                    databaseName = "%CosmosDBDatabaseName%",
                    collectionName = "testNameB",
                    connectionStringSetting = "%CosmosDBConnectionString%") OutputBinding<List<Item>> outputB,
            @CosmosDBOutput(
                    name = "c",
                    databaseName = "%CosmosDBDatabaseName%",
                    collectionName = "testNameC",
                    connectionStringSetting = "%CosmosDBConnectionString%") OutputBinding<List<Item>> outputC,
            @CosmosDBOutput(
                    name = "d",
                    databaseName = "%CosmosDBDatabaseName%",
                    collectionName = "testNameD",
                    connectionStringSetting = "%CosmosDBConnectionString%") OutputBinding<List<Item>> outputD,
            @CosmosDBOutput(
                    name = "e",
                    databaseName = "%CosmosDBDatabaseName%",
                    collectionName = "testNameE",
                    connectionStringSetting = "%CosmosDBConnectionString%") OutputBinding<List<Item>> outputE,
            @CosmosDBOutput(
                    name = "f",
                    databaseName = "%CosmosDBDatabaseName%",
                    collectionName = "testNameF",
                    connectionStringSetting = "%CosmosDBConnectionString%") OutputBinding<List<VinItem>> outputF,
            final ExecutionContext context) {

This is what the signature currently looks like.

答案1

得分: 0

输出绑定将为每个不同的 connectionStringSetting 保留一个 Singleton 客户端实例,如果它们都使用相同的 connectionStringSetting,那么应该没问题,因为它们都会在底层重用相同的客户端。

如果问题是,我是否需要那么多的集合,这取决于您的用例。

但从性能的角度来看,没有什么问题,您仍然会得到 Singleton。

不过,请注意,如果您正在配置扩展以使用直接连接模式,每个集合代表不同的分区,具有不同的连接,因此建立的连接数量将取决于集合的数量(无法避免这种情况)。

英文:

The Output binding will keep a Singleton instance of the client for each different connectionStringSetting, if all these are using the same connectionStringSetting, then it should be fine because they would all reuse the same client underneath.

If the question is, do I need that many collections, that depends on your use case though.

But from the performance perspective, there is nothing wrong, you still get the Singleton.

Be advised though, if you are configuring the Extension on Direct Connectivity mode, that each collection represents different Partitions, with different Connections, so the volume of Connections established will be a factor of the number of collections (there is no way to avoid that).

huangapple
  • 本文由 发表于 2023年2月9日 03:03:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390553.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定