n8n-orchestration-patterns
Skill18 starsChanged 43 days agoMITView on GitHub
Fan-out / fan-in, parallel sub-workflow execution, and batch-orchestrator patterns in n8n. Use when a workflow processes a LIST in parallel, calls sub-workflows, needs faster wall-clock on many items, has a webhook that would otherwise block for minutes, or asks "how do I run sub-workflows in parallel / fan out / fan in".
In this repository25 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- build-stack-v2Skill
- build-workflowSkill
- build-workflow-v2Skill
- check-mcpsSkill
- data-tablesSkill
- deploySkill
- feedbackSkill
- find-credentialSkill
- find-projectSkill
- init-repoSkill
- inventorySkill
- mirror-syncSkill
- n8nac-cheatsheetSkill
- n8nac-referenceSkill
- n8n-code-javascriptSkill
- n8n-code-pythonSkill
- n8n-modeSkill
- n8n-structured-extractionSkill
- plugin-testingSkill
- pull-schemasSkill
- session-envSkill
- stack-intakeSkill
- sync-credentialsSkill
- test-manualSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 91
When a webhook triggers heavy batch work, do NOT let the webhook connection block for minutes (a real batch orchestrator once blocked 41 …
- Very specific: line 96
Synchronous batch orchestrator: when the item count is bounded and fits inside EXECUTIONS_TIMEOUT, a single synchronous orchestrator (no …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
n8n Orchestration Patterns (fan-out / fan-in / batch)
Battle-tested against the n8n docs (main) and real production workflows. The naive approach (branch-split) does NOT parallelize under the modern default — read the trap first.
The trap: branch-split alone does NOT parallelize
| Mechanic | Behaviour |
executeWorkflow mode: each | runs sequentially, one input item at a time |
executeWorkflow mode: once | all items in one sub-workflow call |
Workflow executionOrder: 'v1' (default ≥ 1.0) | completes one branch before starting the next |
Workflow executionOrder: 'v0' (legacy) | first node of every branch, then second node of every branch — layer-by-layer, all branches interleaved |
N8N_CONCURRENCY_PRODUCTION_LIMIT | does NOT apply to sub-workflow executions |
So: 5 branches each [Filter → executeWorkflow] under executionOrder: 'v1' run serially —
wall-clock = sum of all branches = no speedup. executeWorkflow mode: each is sequential per item.
Pattern A — executionOrder: 'v0' + branch-split (regular mode, no queue)
Layer-by-layer scheduling means when branch 0's executeWorkflow awaits (e.g. an LLM call), the
engine schedules branch 1's, then 2,3,4 → all sub-workflow calls are in-flight at once (Node async I/O).
@workflow({
name: 'Parallel Orchestrator',
settings: {
executionOrder: 'v0', // ← CRITICAL — without this, branches run serially
executionTimeout: 7200,
},
})Shape: a Code node assigns bucket: idx % N → N Filter nodes split by bucket → N executeWorkflow
nodes → Merge (mode: append, numberInputs: N). Speedup ≈ N branches.
Caveat: v0 interleaving was less aggressive than expected for some (n8n issue #13620, closed "not planned"). On production-critical paths: measure, don't assume. Guaranteed N× only via queue mode.
Pattern B — Wait=OFF + DataTable fan-in ← RECOMMENDED
Cleaner than a resumeUrl callback: no webhook between workflows (org veto), no HMAC-signature pain,
and a persistent audit trail. See n8n-autopilot:data-tables for the table CRUD.
- Parent generates a
batch_idper run, countsN= list length. - Fan-out — one
executeWorkflownode,mode: each+Wait for Sub-Workflow Completion: false. Fires all sub-workflows async, no return. Passbatch_id+item_idxto each. - Each sub-workflow ends by writing a DataTable row:
batch_id,item_idx,status,result. - Fan-in — Parent: a
Waitnode + loop pollsCOUNT(*) WHERE batch_id = Xuntil>= N(or timeout), then reads the rows and merges.
Error-state (critical): without an error row the parent polls forever. Do NOT use
continueOnFail: true (masks silent failures — vetoed). Instead set the risky node's
"On Error" → "Continue (using error output)" and route the error output to a DataTable write
(status: 'error', error text). Count still reaches N; the failure is logged and visible.
Gotchas:
- Sub-workflow retry → duplicate row: upsert on
(batch_id, item_idx), not insert — seen8n-autopilot:data-tablesfor the exact upsert shape (filters.conditions + matchingColumns). - Poll loop vs
EXECUTIONS_TIMEOUT: add a max-iterations guard + a timeout branch that returns partial results. - 100 items = 100 concurrent executions;
N8N_CONCURRENCY_PRODUCTION_LIMITdoes NOT cap sub-workflows → cap via queue-mode worker--concurrencyinstead. - Count-query race: DataTable insert is atomic per row, append-only count is safe — no lock needed.
Pattern B2 — official resumeUrl fan-out/fan-in (veto grey zone)
n8n's official answer (templates 2536,
6247).
executeWorkflow Wait=false + pass $execution.resumeUrl (+ unique suffix per item); parent pauses
at a Wait node (resume: On Webhook Call); sub-workflow HTTP-POSTs the result to the resumeUrl →
instant resume instead of polling. Cost: it IS a webhook child→parent (collides with "no webhook
between workflows") and carries HMAC-signature pain. Use only if that veto is lifted for the case.
Pattern C — Queue mode (true parallelism, infra change)
EXECUTIONS_MODE=queue + ≥1 worker with --concurrency=10 (Redis + worker pods). Sub-workflow calls
become queue jobs, processed in parallel. The only guaranteed N× speedup. Self-hosted/k8s: set via Helm values.
Synchronous batch + fast-return webhook
When a webhook triggers heavy batch work, do NOT let the webhook connection block for minutes (a real batch orchestrator once blocked 41 min). Two valid shapes:
- Fast-return: webhook immediately responds
202 { batch_id }viarespondToWebhook, then the batch runs detached; the caller polls a status endpoint / DataTable bybatch_id. - Synchronous batch orchestrator: when the item count is bounded and fits inside
EXECUTIONS_TIMEOUT, a single synchronous orchestrator (no queue/worker) is simpler and was chosen over an async queue/worker split in EV-Workflows once the queue's complexity outweighed its benefit. Pick the simplest shape that fits the timeout — don't add a queue you don't need.
Anti-patterns
- ❌ Branch-split with
executionOrder: 'v1'— serial, zero speedup. - ❌ Treating
executeWorkflow mode: eachas "parallel per item" — docs say sequential. - ❌ Webhook-trigger sub-workflow (or HTTP node hitting
/webhook/…) between your own workflows — org veto. - ❌
continueOnFail: trueto "keep the batch going" — masks silent failures; use the error-output branch.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

