Skip to main content

Pattern for parallel sub-workflow execution followed by wait-for-all loop

Workflow preview

Workflow preview
100%
Pattern for parallel sub-workflow execution followed by wait-for-all loop preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

What this workflow does This (set of) workflow(s) shows how to start multiple sub workflows, asynchronously, in parallel, and then wait for all of them to complete. Normally sub workflows would nee...

Best for

  • Engineering automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, n8n-nodes-base.splitinbatches, n8n-nodes-base.wait, n8n-nodes-base.code, n8n-nodes-base.set, n8n-nodes-base.if, n8n-nodes-base.httprequest, n8n-nodes-base.respondtowebhook

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Hubschrauber.

Original n8n.io source

1.1 Workflow description

Title
Pattern for parallel sub-workflow execution followed by wait-for-all loop
Workflow name
Pattern for parallel sub-workflow execution followed by wait-for-all loop

What this workflow does

This (set of) workflow(s) shows how to start multiple sub-workflows, asynchronously, in parallel, and then wait for all of them to complete. Normally sub-workflows would need to be run synchronously, in series, or, if they are executed asynchronously (to run concurrently, in parallel), there is no easy way to merge/wait for an arbitrary number of them to complete.

This is a "design pattern" template to show one approach for running multiple, data-driven instances of a sub-workflow "asynchronously," in parallel (instead of running them one at a time in series), but still prevent the later steps in the workflow from continuing until all of the sub-workflows have reported back that they are finished, via callback URL. There are other techniques involving messaging services, database tables, or other external "flow manager" helpers, but this technique accomplishes the goal fully within n8n.

Setup

To implement this pattern, examine the nodes in the template and modify the incoming data leading to:

  1. A split-out loop to acynchronously execute a sub-workflow multiple times, in parallel.
    • For instance, each sub-workflow might process one of a list of incoming documents.
    • The resumeUrl for the main/parent workflow is provided to all of the sub-workflow executions, along with a unique identifier that can be counted later (e.g. a document file-name).
  2. A "wait-for-all" loop that checks whether all sub-workflows have reported back (if node) and builds a unique list of identifiers from the callbacks received from each execution of the sub-workflow.
    • The sub-workflow should be designed to respond immediately (async) and later send a callback request when it has finished processing.
    • The callback request should include the unique identifier value received when the sub-workflow it was started.

This is meant to be a possible answer to questions like this one about running things in parallel, maybe this one about waiting for things to finish, this one about managing sub-batches of things by waiting for each batch, or this one about running things in parallel. The topic of how to do this comes up A LOT, and this is one of the only techniques that (so far) seems to work.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When clicking ‘Test workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - Loop Over Items

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 3 - Webhook Callback Wait

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 4 - Update finishedSet

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 5 - Initialize finishedSet

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 6 - Simulate Multi-Item for Parallel Processing

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 7 - If All Finished

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2

Block 8 - Start Sub-Workflow via Webhook

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 9 - Acknowledge Finished

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.1

Block 10 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 12 - Continue Workflow (noop)

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 13 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Wait

Type / Role
n8n-nodes-base.wait - wait
Config choices
Version 1.1

Block 16 - Call Resume on Parent Workflow

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 17 - Respond to Webhook

Type / Role
n8n-nodes-base.respondToWebhook - respondToWebhook
Config choices
Version 1.1

Block 18 - Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

3. Summary Table

Workflow Pattern for parallel sub-workflow execution followed by wait-for-all loop
Complexity advanced
Nodes 18
Categories Engineering
Author Hubschrauber
Published 11 Nov 2024

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2536/2536.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Pattern for parallel sub-workflow execution followed by wait-for-all loop do?

What this workflow does This (set of) workflow(s) shows how to start multiple sub workflows, asynchronously, in parallel, and then wait for all of them to complete. Normally sub workflows would nee...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering use case.