microsoft / durabletask-java

Java SDK for Durable Functions and the Durable Task Framework
MIT License
14 stars 7 forks source link

Add functionality to restrict number of parallel runs for a workflow #163

Closed SayantaBhar closed 10 months ago

SayantaBhar commented 1 year ago

Need to add new capability to restrict number of parallel running orchestration instances based on some configurable variable say 'max_active_runs'

E.g:

We have an orchestrator function called workflowOrchestrator. WorkflowId1-1234567 is one orchestration instance. WorkflowId2-7346382 is another orchestration instance. Then If max_active_runs set for WorkflowId1 is 1 then no more than 1 instance should be able to spin up for that. That essentially means that there should not be another running instance of WorkflowOrchestrator with instanceId WorkflowId1-< random number >. New instance for WorkflowId1 should eventually spin up only when WorkflowId1-1234567 is completed i.e once current active instances for a workflow is less than max_active_runs then only new instance should spin up. However, if there is no such limitation on WorkflowId2, then any number of workflow orchestrators should be able to spin up with instanceIds Workflow2-< random number >

cgillum commented 1 year ago

We don't have any such controls at the host level. However, It is possible to implement this manually using singleton orchestrations.

For example, you could write a "WorkflowId1-manager" singleton orchestration which is responsible for scheduling all "WorkflowId1-XXX" workflows as sub-orchestrations. You could use that max_active_runs variable from inside "WorkflowId1-manager" to configure how many sub-orchestrations can run concurrently, and write the logic necessary to schedule new instances when old instances complete, etc.

microsoft-github-policy-service[bot] commented 10 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.