I'm trying to understand how parallelization works in Durable Function. I have a durable function with the following code (followed this tutorial: https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-sub-orchestrations?tabs=csharp#example)
[FunctionName(nameof(OrchestratorFunction))]
public async Task RunOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context,
ILogger log)
{
var items = await context.CallActivityAsync<List<Item>>(nameof(GetItemFunction), null);
if (items != null && items .Count > 0)
{
var processingTasks = new List<Task>();
foreach (var item in items)
{
Task processTask = context.CallSubOrchestratorAsync(nameof(SubOrchestratorFunction), item);
processingTasks.Add(processTask);
}
await Task.WhenAll(processingTasks);
}
}
[FunctionName(nameof(SubOrchestratorFunction))]
public async Task RunSubOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context,
ILogger log)
{
var item = context.GetInput<Item>();
var name = await context.CallActivityAsync<Item>(nameof(GetNameFunction), item);
var age = await context.CallActivityAsync(nameof(GetAgeFunction), item);
var address = await context.CallActivityAsync(nameof(GetAddressFunction), item);
var state = await context.CallActivityAsync(nameof(GetStateFunction), item);
var country = await context.CallActivityAsync(nameof(GetCountryFunction), item);
}
What I wanted to do is to get all items and all items should run in parallel.
Does this code run all the items in parallel? Meaning the time taken by 10 items and 10000 items will be the same? On testing, I see a difference in the time taken by 10 items and 10000 items. Am I missing something?