EventsSourcing-on-Azure-Functions
EventsSourcing-on-Azure-Functions copied to clipboard
Use "Throttled Parallelism" for fan-out in commands/queries
Per this blog
public static async Task<string> ScheduleManyInstances(
IDurableOrchestrationClient client,
string orchestrationName,
int count,
ILogger log)
{
log.LogWarning($"Scheduling {count} orchestration(s)...");
DateTime utcNow = DateTime.UtcNow;
string prefix = utcNow.ToString("yyyyMMdd-hhmmss");
await Enumerable.Range(0, count).ParallelForEachAsync(200, i =>
{
string instanceId = $"{prefix}-{i:X16}";
return client.StartNewAsync(orchestrationName, instanceId);
});
log.LogWarning($"All {count} orchestrations were scheduled successfully!");
return prefix;
}
Rather than the existing naive parallelism.