持久功能是否适合大量活动? [英] Is durable functions suited for high amount of activities?

查看:83
本文介绍了持久功能是否适合大量活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要计算50万活动的场景.所有小的计算.由于节流,我只能同时计算30.

I have a scenario where I need to calculate 500k activities. All small calculations. Due to throttling I can only compute 30 simulataniously.

想象下面的简单示例:

[FunctionName("Crawl")]
public static async Task<List<string>> RunOrchestrator(
    [OrchestrationTrigger] DurableOrchestrationContext context)
{  
    WriteLine("In orchistration");
    var outputs = new List<string>();

    // here i get 1 million jobs
    var jobs = await context.CallActivityAsync<List<Influencer>>("GetSocialAccountJobs", "");
    var tasks = new Task<string>[jobs.Count];

    var retryOptions = new RetryOptions(
        firstRetryInterval: TimeSpan.FromSeconds(60), maxNumberOfAttempts: 3);

    for (int i = 0; i < jobs.Count; i++)
    {              

        tasks[i] = context.CallActivityWithRetryAsync<string>("Crawl_Hello", retryOptions, jobs[i].Id);
    }

    await Task.WhenAll(tasks);

    return outputs;
}

每次调用一个活动时,都会调用此协调器功能.并循环所有活动,直到et找到未被调用的活动为止.它将循环数百万次.我是否缺少某些东西,或者持久功能不适合这种情况?

Everytime an activity is called, this orchestrator function is called. And loops all activities until et finds an activity that has not been called. It will loop millions of millions of times. Am I missing something or is durable functions not suited for this kind of scenarios?

推荐答案

耐用功能文档化的性能目标,可在部署持久功能时提供帮助.

Durable Functions auto-scale when running in the Consumption and Elastic Premium plans. There are some documented performance targets that help when deploying durable functions.

具体而言,您可能需要注意以下内容

Specifically, in your case, you might want to note the following

与扇出不同,扇入操作仅限于单个VM.如果您的应用程序使用扇出,扇入模式,并且您担心扇入性能,请考虑将活动功能扇出细分为多个因此,与其从单个协调器中调用百万个活动,不如触发具有较小批量作业的子协调器,而这些作业又将调用活动功能.

So, instead of calling million activities from a single orchestrator, you could trigger a sub-orchestrator with smaller batches of jobs which in-turn would call the activity function.

这篇关于持久功能是否适合大量活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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