Tips > Building Workflows

Implement Fan-Out/Fan-In for Parallel Processing

The fan-out/fan-in pattern splits work across multiple parallel branches, processes each branch independently, then merges all results back together.

The fan-out/fan-in pattern runs several independent branches in parallel from one trigger, then a Merge node in Append mode waits for all of them and combines the results for a final step. Use it when one output needs data from multiple independent sources: querying them at once cuts total time from the sum of every call down to the duration of the slowest single call.

What is the fan-out/fan-in pattern?

The fan-out/fan-in pattern splits work across multiple parallel branches, processes each branch independently, then merges all results back together. This is essential when you need data from multiple independent sources to produce a single output, and you want all sources queried simultaneously rather than sequentially.

Real-world example: Your daily report workflow needs data from three independent APIs -- GitHub (commits), Jira (tickets), and Datadog (error rates). Fetching them sequentially takes 12 seconds; in parallel it takes 4 seconds (the slowest single API).

How do you build fan-out/fan-in in n8n?

Schedule Trigger (daily at 08:00)
  |
  +---> GitHub - Get Commits (yesterday)      --> Set: format_github
  |
  +---> Jira - Get Resolved Tickets           --> Set: format_jira
  |
  +---> HTTP Request - Datadog Error Rates    --> Set: format_datadog
  |
  Merge Node (mode: Append, wait for all 3)
  |
  Code Node: Build Report
  |
  Slack - Post Daily Summary

A Code node collects the three branch outputs and builds the report:

// All three data sources arrive as separate items
const items = $input.all();

const github = items.find(i => i.json.source === 'github')?.json;
const jira = items.find(i => i.json.source === 'jira')?.json;
const datadog = items.find(i => i.json.source === 'datadog')?.json;

const report = {
  date: new Date().toISOString().split('T')[0],
  summary: [
    `Commits: ${github?.commit_count ?? 'N/A'} across ${github?.repos ?? 'N/A'} repos`,
    `Tickets Resolved: ${jira?.resolved_count ?? 'N/A'} (${jira?.story_points ?? 'N/A'} story points)`,
    `Error Rate: ${datadog?.error_rate ?? 'N/A'}% (${datadog?.trend ?? 'N/A'} vs yesterday)`,
  ].join('\n'),
  details: { github, jira, datadog }
};

return [{ json: report }];

The Slack message output looks like this:

Daily Engineering Report - 2025-01-15
--------------------------------------
Commits: 23 across 4 repos
Tickets Resolved: 12 (34 story points)
Error Rate: 0.3% (down vs yesterday)

Note: Merge Node Wait Behavior. When three branches connect to a single Merge node in "Append" mode, the Merge node waits until all three branches have completed before passing data downstream. If one branch fails, the Merge node can be configured to continue with partial data or stop the workflow.

When should you use fan-out/fan-in?

This pattern reduces overall execution time from the sum of all API call times to the time of the slowest single call.

Related: Use Path Parameters in Webhook URLs for Dynamic Routing · Use Edit Fields in "Map Each" Mode for Simple Renames

Showcase builds

19 complete workflows from my own projects, each with its n8n workflow JSON to import. Showcase entries link the file at the end of the article.

See the showcase builds

Keep reading

190 entries grouped by topic, from first workflow to queue mode. Free, no signup.

Browse the encyclopedia

Need it built?

I design, build and run n8n systems for clients. Every engagement starts with a $1,500 diagnostic audit, credited toward the build.

Book an introductory call