Is there a way to limit number of open workflows running at any given time?

Hi!
We have a usecase where, a parent workflow spawns child workflows. we want to make sure the number of these child workflows in open state at any given time is within a limit.

In my prototype,
I had a parent workflow executing 8 child workflows(PARENT_CLOSE_POLICY_ABANDON & a different childTaskQueue)
Each childWorkflow would start, sleep for 5 minutes and then complete.
I had 2 childworkers, each with setMaxConcurrentWorkflowTaskExecutionSize(2) and expected 4 childWorkflows to run first, and next 4 to run after 5 minutes.

Is there a way to achieve this?

You cannot control the number of parallel workflows through worker options. setMaxConcurrentWorkflowTaskExecutionSize limits the throughput of workers, but doesn’t affect the parallelism of workflows. So I wouldn’t change this number.

You can limit the number of parallel children of a single parent programmatically. See the batch samples that demonstrate some of the options.

1 Like