Temporal child workflows and fan-out

Child workflows give a Temporal parent workflow its own history, ID and lifecycle, which suits independent sub-processes and parallel fan-out. This page explains when to use them, how to configure them, and when a plain activity is the better choice.

On this page

When Temporal child workflows and fan-out fit your design

Use a child workflow when a piece of work needs its own history, its own workflow ID and its own lifecycle, separate from the parent that started it. Fan-out is the pattern of starting many child workflows in parallel from one parent, waiting for their results and then continuing. Both fit when a parent process must split work into sub-processes or parallel units that should be retried, observed and stopped on their own. A child with its own history also keeps a large or long-running sub-process from adding every event to the parent's history, and all of those events are stored in the persistence layer you operate, so this separation affects storage planning.

Decide early what should happen to running children when the parent closes. The parent close policy sets whether each child is terminated, cancelled or left running, and a child left running after its parent finishes is a common source of orphaned work. Confirm the options and their defaults for your SDK and server versions in the Temporal documentation before you rely on one. Fan-out also multiplies the number of executions your team must find and report on. Each child appears in the Web UI and in visibility queries, so review the Temporal visibility documentation and choose a visibility store that can handle the search volume you expect.

Activities are often the simpler choice when each unit is a single call to an external system that needs only a retry policy, with no signals, no waiting and no need to inspect the unit as its own execution. A child workflow adds a workflow ID, a history and its own retry and timeout behavior for every unit, so that overhead pays off only when the unit has durable steps of its own. Before you commit, estimate the typical and worst-case number of children per run, and ask your Temporal team to confirm the current limits on children per parent and history size for the server version you plan to run.

Child workflow options and when each fits

This table compares the main configuration choices for a child workflow: workflow ID strategy, parent close policy, task queue and timeouts, and retry policy. Read each row as a decision: the 'when it fits' column names the situation, and the trade-off column names what you give up. Confirm exact option names and defaults in the Temporal SDK documentation for your language before you write code.

OptionWhen it fitsTrade-off to weigh
Workflow ID strategy (deterministic ID derived from business key)Each record or entity should map to at most one child run, so a retried parent does not start duplicates.A reused ID can collide with a closed run, so confirm the ID reuse policy and conflict policy for your SDK.
Workflow ID strategy (random or generated ID)Children are one-off units where duplicate prevention is handled elsewhere, such as in the parent's own bookkeeping.Replays and parent retries can start duplicate children unless the parent tracks what it has already started.
Parent close policy: terminateThe child has no value once the parent stops, and leaving it running would waste capacity or hold resources.Abrupt termination gives the child no chance to run cleanup, so compensating work must be designed for that case.
Parent close policy: request cancelThe child should stop at a safe point and run its own cleanup when the parent closes or is cancelled.The child may keep running for some time after the parent closes, so confirm the child handles cancellation promptly.
Parent close policy: abandonThe child is a long-lived or independently meaningful process that should outlive the parent.The parent no longer controls it, so ownership, visibility and shutdown must be tracked by another mechanism.
Dedicated task queue for childrenChild workflows need different worker sizing, scaling or deployment cadence from the parent.Each extra task queue adds worker pools to deploy, monitor and scale.
Timeouts (run and task timeouts on the child)A child must not hold the parent indefinitely, for example when a dependency stalls.Timeouts that are too short cause avoidable failures, so set them from measured run times rather than guesses.
Retry policy on the childA child fails for transient reasons that a fresh attempt can clear, and the failure is safe to repeat.Retrying a child re-runs all of its activities, so confirm each one is idempotent before enabling retries.

How a child workflow differs from an activity

A child workflow is a full workflow execution started by a parent workflow. It gets its own event history, its own run ID and its own entry in the Temporal Web UI and visibility store, so it can be listed, queried and reasoned about as a separate execution. A child can contain activities, timers, signals and even further child workflows. An activity, by contrast, is a single unit of work that runs inside the parent's flow. Its attempts and results are recorded as events in the parent's history, and it has no execution of its own that an operator can open separately. When choosing between them, ask whether the unit of work needs its own durable state, its own timers or its own observable identity. If it does not, an activity is usually the simpler design.

The difference shows up most clearly in what the parent waits for. When a parent starts an activity, it waits for that activity to complete, fail or time out, and retries are handled by the activity's Retry Policy within the same parent flow. When a parent starts a child workflow, it waits for the child run to reach a terminal state, and the child's own retries, timers and failures play out in the child's history. The parent can also be configured to continue without waiting for a child at all, so the child keeps running after the parent moves on. Teams should decide explicitly which of these waits they want for each piece of work, and document the answer before code is written, since it determines how failures and cancellations propagate.

Set up a parent with child fan-out in order

This sequence takes a parent workflow from design to a tested fan-out, where each child runs as its own execution with a stable ID and a defined close behavior. The result is a parent that starts children in parallel, collects their outcomes and handles cancellation and replay correctly.

  1. Define the parent and child workflow types

    Write the parent workflow and the child workflow as separate workflow functions, each with its own registered type name and input and output structs. Keep the child's input limited to what it needs to process one unit of work, so the parent does not pass large record sets through it. Confirm that each type is registered on the worker's task queue and that the child can run on its own when started from a test. Done when a single child can be started directly and completes with its expected result.

  2. Derive deterministic child workflow IDs from business keys

    Set each child's workflow ID from a stable business key, such as an account or record identifier combined with the parent's run purpose, rather than a random value. Deterministic IDs let you find a child from its business record and stop duplicates if the parent restarts. Check that the ID scheme produces unique values across a sample of inputs, including duplicates in the input list, and decide in advance how the parent handles a duplicate key. Done when the ID function is written, unit tested, and documented next to the parent code.

  3. Choose the parent close policy for each child

    Set the parent close policy on every child start option so the team decides, per child type, what happens to a running child when its parent closes or is terminated. Terminate, abandon and request-cancel are the options Temporal documents, and each has different effects on cleanup work. Review the choice with the team that owns the business process, because it decides whether a child keeps running after the parent ends. Done when each child type has a written policy and the start options in code match it.

  4. Start children in parallel and collect results

    Start the children from the parent without waiting on each one, keep the futures in a list, and then wait on all of them to gather results or errors. Cap the number of children in flight with a bounded batch or a semaphore pattern so the history and the downstream systems do not receive an unbounded burst. Record which children failed and why, so the parent can decide whether to fail, retry or continue. Done when a test with a known input list returns one result per child and the counts match.

  5. Verify each child as its own execution

    Open the Web UI or query the workflow list for the test run and confirm that every child appears as a separate execution with its own event history, its own workflow ID and a link to its parent. Check that the child IDs match the deterministic scheme from the earlier step. If a child is missing or shares an ID with another, stop and fix the ID or the start logic before continuing. Done when the execution list shows the expected number of children with unique IDs and correct parent links.

  6. Test cancellation and close behavior

    Cancel the parent during a test run while children are still active, and confirm that each child reacts according to its configured parent close policy. Check that cancellation reaches the children and that any cleanup in the child's compensation or finalization logic runs. Repeat the test with the parent terminated so the team sees the effect of the forced close. Done when the observed child states match the documented policy for each child type and the results are recorded in the test report.

  7. Test replay and determinism of the fan-out

    Run the parent and child workflow code against recorded histories using the SDK replay tooling, and confirm that the start order, the ID function and the collection logic replay without non-determinism errors. Change the batch size or the ordering in a copy and confirm the replay test catches the change, so the team knows the test is effective. Keep the recorded histories in source control with the test. Done when replay passes on the current code and fails on the intentionally changed copy.

How a parent fans out to child workflows and collects results

The diagram starts with a parent workflow running on the Temporal Service, which schedules several child workflows onto a task queue. Each child gets its own history and workflow ID, and a worker process picks up its tasks and records progress back in the service. The parent waits on each child, collects the results and decides what happens if a child fails. Check that the parent's close policy matches what should happen to children when the parent closes.

A parent starts child workflows on a task queue, and workers record each child's history in the service.

Where fan-out goes wrong

Child workflows and fan-out give you parallelism and isolated histories, but they also move risk into places that are easy to miss: the service, downstream APIs, workflow IDs, and the lifecycle of children after their parent changes state. The cards below cover the failure modes teams most often hit and a first mitigation for each.

Unbounded fan-out overload

Starting one child per record for a large set can flood the Temporal Service with workflow starts and then flood a downstream API with activities at the same moment. Cap the number of children in flight at the parent, batch the input, and size worker concurrency against the rate the external system can accept. Check the peak number of open child executions in a load test before production.

Deployment docs

Non-deterministic child IDs

If a parent generates child workflow IDs from random values, timestamps or map iteration order, a replay can produce different IDs and Temporal treats the workflow as non-deterministic. Derive IDs from business keys that the workflow already holds, such as an order number plus a step name. Review the parent code path for any call to a clock, random source or unordered collection before it sets an ID.

Orphaned children after parent close

When a parent completes, fails or is terminated, its children may keep running unless the parent close policy says otherwise. A child left running can keep writing to systems the parent believed were finished. Set the parent close policy on each child deliberately, and decide per child type whether it should terminate, cancel or abandon when the parent closes.

Parent history growth from results

Collecting every child result into the parent's state grows the parent's event history with each completion and can push it toward history limits. Return small summaries from children, write bulk results to a database or object store keyed by child ID, and use Continue-As-New in the parent when the batch is long. Measure history size during testing with the same data volumes you expect.

Child signature changes

A running child was started with the input and workflow type of the code that existed at the time, so changing its parameters or logic can break executions that are still open. Treat child workflow signatures as a public contract, add new optional fields rather than renaming them, and gate logic changes with versioning until the old executions finish. Confirm the versioning approach with your SDK documentation before the first change.

Cancellation that does not reach children

Cancelling a parent does not automatically give every child the same outcome, and a child that is blocked in an activity may take time to observe the request. Users may see the parent cancelled while work continues underneath. Propagate cancellation explicitly, handle the cancellation scope in each child, and test cancel requests during fan-out in a staging environment.

When activities are the simpler choice

A single-step unit of external work, such as calling a payment API, writing a record to a database or sending one email, usually belongs in an activity, not a child workflow. Activities already give you what most of these calls need: a timeout, a retry policy with backoff, and a result recorded in the parent's history. The RetryPolicy on the activity options is where you control attempts and intervals, and where you mark business errors as non-retryable so they fail fast. If the work is idempotent and finishes in one call, adding a child adds a second workflow execution, its own history and its own ID for no gain in control.

A child workflow earns its place when the unit of work has lifecycle or visibility needs of its own. Examples include a unit that must be searched, listed or cancelled independently in the Web UI or through the visibility store, a unit that runs for a long time and needs its own history to stay small, or a unit that other workflows may need to reuse. Test each candidate with a simple question: will an operator ever need to look at this piece by its own workflow ID? If the answer is no, a child is usually overhead. Also check the parent close policy you would set, because that decision is what makes a child behave differently from an activity when the parent ends. Confirm your own visibility and history size expectations with your Temporal deployment team before you commit to a child for each item.

When the work is a large set of records, or several steps that must be undone together on failure, read the sibling pages before deciding. The batch processing with Temporal design covers fan-out over large record sets and the iterator and sliding window options for sets that outgrow a single fan-out. The saga pattern page covers compensating actions per step, which is a different question from fan-out and often uses activities as the unit of work. Choose the design by the failure and visibility behavior you need, then use child workflows only where that behavior requires a separate workflow.

Security and operational considerations

Child workflows add executions that are easy to overlook in an access review, a data flow map or a dashboard. The cards below cover who can reach them, what data they carry, and how to see them when something stalls. Confirm each control against your own access model before the design is final.

Namespace-scoped visibility of children

Child executions live in the same namespace as their parent, so anyone who can read that namespace can usually see the child's workflow ID, status, history and inputs. Confirm whether your reviewers, support staff and analysts should see child histories at all. If a child processes restricted records, decide whether it belongs in a separate namespace with its own access rules, and document that choice in the design record.

Self-hosted security docs

Who can signal or cancel children

Any caller with API access to a namespace can send a signal or request cancellation to a child workflow by its ID, and the parent does not have to be involved. Plan which roles may cancel fan-out branches, which services may signal them, and whether operators can terminate a child directly. Map these actions to your RBAC model and confirm the required roles in your environment before go-live.

Self-hosted authorization default

If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. A fan-out design that depends on namespace roles will not enforce them until an Authorizer and ClaimMapper are in place. Verify the authorization configuration on every frontend before routing production child workflows through it.

Security configuration docs

Payload encryption for child inputs

Parent-to-child inputs and child results are stored in workflow history like any other payload, so sensitive batch data is visible to anyone who can read history. Self-hosted Temporal supports custom payload codecs with a codec server for encryption. Decide which fields need encryption before the first child is written, because changing codecs later affects how existing histories decode and who holds the keys.

Monitoring open child executions

A parent that finishes or continues while children remain open can hide stuck or runaway branches. Alert on the count of running children per parent type, on children older than their expected duration, and on fan-out parents that stop making progress. Use visibility queries for these checks, and confirm that your visibility store, such as Elasticsearch or OpenSearch, has the capacity to answer them at your execution volume.

Parent close policy and cleanup

The parent close policy decides whether open children are terminated, cancelled or left running when the parent closes. Choose the policy per child type, not once for the whole design, because a payment settlement child and a report generation child rarely need the same behavior. Review these settings during access and data retention reviews, since a child left running after its parent closes may keep processing data outside its approved scope.

Questions buyers ask before building fan-out on Temporal

What drives the cost of a child-workflow design on Temporal?

The main driver is how many child workflows the design creates and how much work each one does, because both shape the build effort and the running cost. Design time goes into deciding parent and child boundaries, workflow IDs, parent close policies and failure handling, and that work is mostly one-time. Recurring cost comes from what the service consumes: on Temporal Cloud, pay-as-you-go pricing starts at 50 US dollars per million actions, so every child start, activity and signal counts toward actions. On self-hosted Temporal, the recurring cost is the infrastructure, database and visibility store that carry the extra history. Ask any partner to price the design by number of child executions per run, expected peak parallelism and retention period, and to separate one-time build work from recurring operating cost.

How long does a fan-out build take?

Duration depends on scope rather than on the Temporal feature itself. A fan-out that splits one known batch type into children, with one worker deployment and simple retries, is a much smaller piece of work than a design that adds per-record idempotency, rate control, visibility queries and monitoring across several task queues. The variables to confirm are the number of distinct child workflow types, how many environments need to be built, whether the team needs a load test before production, and how many external systems each child calls. This page does not give a duration because none was supplied for this scope. Ask for a written plan with milestones and a test phase, and check that it names what is excluded.

What does the work need from our team?

A fan-out build needs people who own the business rules for each child operation, engineers who can write and test workflow code, and someone who runs the platform. The business owners must define what a child workflow represents, what counts as a failure that should stop the parent, and what must happen to records that cannot be processed. Engineers need access to the existing systems the children call, test data, and a staging Temporal environment. The platform owner must decide where the Temporal Service runs, how workers are deployed and who receives alerts. Ask the partner to list these inputs in the scope document so that gaps are found before the build starts.

Can our in-house team build fan-out on Temporal alone?

A team with experience in Temporal SDK development and distributed systems can build a basic parent and child design alone. The harder parts are the ones teams underestimate: deterministic workflow code that survives later changes, idempotent activities, parent close policy choices, and load behavior under large fan-outs. Those are the areas where an outside review or build support is most useful. Confirm the team's experience with replay testing, worker tuning and production incident handling before deciding. DeployOpen plans, implements and tests self-hosted platforms in infrastructure you control, so a fixed-scope engagement can cover the build while your team keeps ownership of the code and operations.

How do child workflows affect Temporal Server and visibility load?

Each child workflow has its own event history, so a parent that starts many children creates many histories instead of one large one. This keeps individual histories smaller, but the total number of executions, events and visibility records grows with the fan-out width. On self-hosted Temporal, the persistence database and the advanced visibility store absorb that growth, and Elasticsearch or OpenSearch is recommended for anything beyond a few workflow executions. Ask for an estimate of total executions per day, peak concurrent children and retention, then test those numbers in a load run before production. Plan visibility queries and dashboards around parent and child workflow IDs so operators can find failed children quickly.

When should we use activities instead of child workflows?

Use an activity when the unit of work is a single call to an external system that does not need its own history, retries or visibility. Activities are simpler to build, test and monitor, and they avoid the extra executions a child workflow adds. Child workflows fit better when each unit has several steps, its own timers or signals, or a need to be queried and retried as a separate business process. Many designs combine both: a child workflow coordinates a batch of records, and each record is handled by one activity. Review the page on batch processing with Temporal before choosing, because very large sets may need a different pattern.

What should we check before the design goes to production?

Check that every child workflow ID is deterministic and unique within the namespace, that parent close policies match the business meaning of stopping a parent, and that activities called by children are idempotent. Run replay tests on any workflow code change and confirm that a worker restart does not break in-flight children. Confirm that the Temporal Service is not reachable from the public internet, that the default noopAuthorizer has been replaced with configured authorization, and that visibility is backed by a store sized for the fan-out. Ask the partner to provide the test results and a runbook for stuck or failed children as part of the handover.

How DeployOpen scopes and delivers Temporal workflow design work

DeployOpen approaches Temporal child workflows and fan-out as a scoped design and build task inside infrastructure you control. The work starts with the workflow map and the parent and child boundaries, then moves through implementation, testing and a handover your engineers can run.

How we scope

  • Map which steps become child workflows and which stay as activities, with the reason for each
  • Agree the workflow ID scheme, parent close policy and expected fan-out width in writing
  • Confirm the deployment target, namespaces and visibility store the workflows will use

How we build

  • Implement parent and child workflows with deterministic code, versioned for in-flight executions
  • Add fan-out and result collection with bounded concurrency and tested failure handling
  • Test cancellation, retries and worker restarts against the agreed workflow design

How we hand over

  • Document the workflow graph, IDs, close policies and history size assumptions for your engineers
  • Walk your team through replay tests, deployment steps and how to inspect parent and child executions
  • Deliver runbooks for stuck children, cancellations and resets agreed in the written scope

How we support

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts
  • Ongoing support, upgrades and continuous testing are available as a retainer
  • A quote follows from the written scope, so ask what is one-time and what recurs

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.