Skip to content

// Orchestration · ~2 min read

Parallel Fan-Out / Fan-In

Reach for it when: independent sub-tasks can run at once and merge into one answer.

After this lesson you can: Run independent sub-tasks at the same time and join them with an explicit rule.

// 60-second mental model

How to hold it in your head

Split independent work. Run it at the same time. Merge when every branch returns — or when your join rule says “enough.”

Fan-out/fan-in dispatches independent sub-tasks concurrently, then joins results with an explicit rule: wait for all, wait for the first k, or take the first success.

How this differs

MapReduce runs the same job on every chunk; fan-out runs different, independent jobs. If one branch needs another’s output, you want a Sequential Pipeline.

// Mini architecture

Fan-out independent work · join with a rule

A Dispatcher sends work to three branches, A, B and C, at the same time. All three branches feed into a Join or merge step, which produces the final result.

Branches must be independent. If B needs A’s output, you wanted a pipeline — not fan-out.

// Mini-project

Three-source brief, wait-all join (stub)

Dispatcher + three stub branches

Goal: Fan out research stubs for docs, blog, and changelog; merge only after all three return.

  1. Dispatcher receives a product question.
  2. Fan out `branch_docs`, `branch_blog`, `branch_changelog` stubs in parallel (`Promise.allSettled`, or `Promise.all` with each branch wrapped in `.catch(() => null)`; plain `Promise.all` rejects as soon as one branch fails).
  3. Join rule: wait-all; on any failure, mark that branch `null` and continue.
  4. Merger builds a brief with one section per non-null branch.
  5. Refuse a serial “call A then B then C” path in the stub runner.
  6. Log wall-clock vs. sum-of-branch times to show the point.

Simulated delays are fine. The lesson is independence + join policy, not real crawlers.

// Common failure

What goes wrong

Symptom

Fake parallelism — branches secretly depend on each other and deadlock or race.

Fix

Assert independence in the dispatcher. Dependent work belongs in a sequential pipeline.

// Self-reflection

Sit with this

Which of your “parallel” agent runs still waits on a hidden shared file?

Sources

Session only. Nothing is saved.