Is there a maximum number of child workflows

Is there a maximum number of child workflows within a full hierarchy?

I have a workflow that loops and with each iteration of the loop it starts a child workflow. Those child workflows are recursive so they too loop and start child workflows.

I’ve arbitrarily limited the data so it is a maximum of 1000 iterations but based on user data this could end up being 1 parent with 1000 direct descendants or 1 parent that has 1 child which then has 1 child which then has 1 child etc (1000 times). Or any combination in between here.

I’m just looking for a reasonable limit an if my chosen 1000 is anywhere near that.

Your limitation (per workflow execution) is 50K history events in the workflow history, see docs here.

Unlike in some other workflow paradigms (bpmn comes to mind), with Temporal there is no reason to use child workflows just for organization. Since you are writing workflow as code, you can use OO techniques like structures, interfaces to break up your logic into more manageable abstractions.

Some of the uses for child workflows are

  • partition the max event history limit into smaller chunks
  • helps mange resources using its business-level id to guarantee uniqueness
  • execute periodic logic without blowing up the parent workflow history
    (see more in docs here)

One limitation of using child workflows is lack of shared state (between parent and child) as they can communicate only via async signals.

That said I don’t think there should be issues with your numbers. Temporal is capable of executing hundreds of millions of open workflows concurrently. Would recommend to do load testing tho as you might have to fine-tune your deployments to handle large loads to achieve large numbers.

1 Like