c# - Azure持久功能: Fan Out vs. Parallel.ForEachAsync

标签 c# azure performance azure-functions azure-durable-functions

我必须对项目列表运行一个函数。我正在使用 Azure Durable Functions,并且可以使用它们的 fan out/fan in 并行运行这些项目。策略。

但是,我想知道这样做与在单个 Activity 函数中使用新的 Parallel.ForEachAsync 方法之间存在什么区别。我需要使用持久函数,因为这是一个永恒的编排,完成后会重新启动。

最佳答案

Parallel.ForEachAsync 绑定(bind)到一个 Function App 实例。这意味着它与 Function App 拥有的资源绑定(bind)。在消耗计划中运行时,这意味着 1 个 vCPU。

在持久函数中使用扇出/扇入方法时,F2 的每个实例(参见图片)都是它自己的 Function App 实例。反过来,它可以使用分配给它的全部资源。

Fan out / Fan in

简而言之:通过扇出/扇入方法,您将使用(大量)更多资源。可能会给您更快的结果。

您可能最好结合使用两者:将批量工作分派(dispatch)到“F2”,以并行方式处理批量工作。

The fan-out work is distributed to multiple instances of the F2 function. The work is tracked by using a dynamic list of tasks. Task.WhenAll is called to wait for all the called functions to finish. Then, the F2 function outputs are aggregated from the dynamic task list and passed to the F3 function.

The automatic checkpointing that happens at the await call on Task.WhenAll ensures that a potential midway crash or reboot doesn't require restarting an already completed task.

关于c# - Azure持久功能: Fan Out vs. Parallel.ForEachAsync,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72045448/

相关文章:

python - 向量化或加速 PANDAS 列上的 Fuzzywuzzy 字符串匹配

java - 给予改变的独特方式——不输出期望值

azure - Terraform - 根据本地字符串列表验证传递的字符串列表

azure - 如何管理添加到WAMS中的表,或将WAMS与现有SQL DB表相关联?

c# - 从数据库中检索与列表的多个值匹配的记录

c# - 服务器上的 mysql 版本 6.9.5 出现错误

asp.net-mvc - 在本地和 Azure 上使用 Active Directory 进行身份验证

java - 不推荐使用 HttpMethod getResponseBodyAsString 但为什么

c# - 为什么我的 System.Threading.Task.ContinueWith 在错误的时间触发

c# - 使用 Windows Phone 7 解析包含数组的 JSON 对象