cadence-workflowtemporal-workflow

What is a good use case for a child workflow in Temporal or Uber Cadence?


I am trying to understand the use cases for a child workflow with Temporal/Uber Cadence. What is the advantage of a child workflow vs. simply splitting your workflow into functions? I have a rather complex workflow that I am considering splitting into multiple child workflows, but I am unsure of the pros/cons of doing so.


Solution

  • The main limitation of a child workflow versus collocating all the application logic in a single workflow is lack of the shared state. Parent and child can communicate only through asynchronous signals. But if there is a tight coupling between them it might be simpler to use a single workflow and just rely on a shared object state.

    I personally recommend starting from a single workflow implementation if your problem has bounded size in terms of number of executed activities and processed signals. It is just simpler than multiple asynchronously communicating workflows.

    Also it is frequently overseen that workflows are not just functions, you can use the full power of OO in them. Use structures, interfaces and other OO techniques to break the logic into more manageable abstractions.