问题描述
我有一个需要计算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
因此,与其从单个协调器中调用百万个活动,不如触发具有较小批量作业的子协调器,而这些作业又将调用活动功能.
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.
这篇关于持久功能是否适合大量活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!