Azure / azure-functions-durable-js

JavaScript library for using the Durable Functions bindings
https://www.npmjs.com/package/durable-functions
MIT License
128 stars 46 forks source link

How to use the fan out/fan in pattern while limiting the number of parallel executions? #474

Closed GP4cK closed 1 year ago

GP4cK commented 1 year ago

For example, with async.eachLimit, given an array of tasks, you can easily execute all of them but X at a time. Is this achievable with an Orchestrator function?

davidmrdavid commented 1 year ago

Thanks for reaching out @GP4cK. In general, you can limit the global maximum number of concurrent Activities via the host.json parameter named maxConcurrentActivityFunctions. You can read about this here: https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-perf-and-scale#configuration-of-throttles

However, you seem to be asking about a dynamic, per fan-out, limit. I don't think that's possible today, but it would be an interesting feature to design. FYI @hossam-nasr

davidmrdavid commented 1 year ago

To be clear, you could certainly limit the fan out by only scheduling a subset of them at a time, i.e batching the fan-out. But then, after the number of remaining tasks in a batch goes under your value of maxConcurrentActivityFunctions, you wouldn't be maximizing your concurrency capabilities.

GP4cK commented 1 year ago

To be clear, you could certainly limit the fan out by only scheduling a subset of them at a time, i.e batching the fan-out. But then, after the number of remaining tasks in a batch goes under your value of maxConcurrentActivityFunctions, you wouldn't be maximizing your concurrency capabilities

Exactly. I just wanted to check if such a feature was available. I'll get started with maxConcurrentActivityFunctions then. Thanks! Feel free to close the issue or wait for hossam-nasr's answer.

davidmrdavid commented 1 year ago

I'll be closing this for now :)