Is durable functions suited for high amount of activities?

ぃ、小莉子 提交于 2020-01-25 10:19:06

问题


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

Imagine following simple sample:

[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;
}

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?


回答1:


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

Unlike fan-out, fan-in operations are limited to a single VM. If your application uses the fan-out, fan-in pattern and you are concerned about fan-in performance, consider sub-dividing the activity function fan-out across multiple sub-orchestrations.

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.



来源:https://stackoverflow.com/questions/59249027/is-durable-functions-suited-for-high-amount-of-activities

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!