Contents

Parallelization

Also known as: fan-out / fan-in, scatter-gather, concurrent orchestration

Who decides
Code
Shape
Fan-out

Intent

Run several LLM calls at the same time on pieces of work that do not depend on each other, then combine their outputs in one aggregation step. Your code fixes the split before the run starts: either different subtasks in each branch (sectioning) or the same task run several times (voting).

Problem

You are building a due-diligence tool for a small investment team. An analyst uploads the data room of Acme Robotics (corporate documents, three years of financial statements, the main customer contracts, a market study) and asks: “Is Acme a reasonable acquisition target?”

The answer needs a legal review, a financial review and a market review. None of them needs the others’ output. The first versions of the tool break in three ways:

The data room goes through a legal, a finance and a market review one after the other, so the report only arrives after about 60 seconds although no review depends on another.Data roomLegalreview, 20 sFinancereview, 20 sMarketreview, 20 sReportafter 60 s60 s of waiting, though no review needs another's output(merging the three into one prompt is faster, but each concern gets less attention)
Scroll to see all of it.
The three reviews are independent, yet the sequential version makes each one wait for the previous one.

Solution

Write the split in code. Start one LLM call per independent piece at the same time, wait for them at a barrierBarrier A point in the code that waits until every task it started in parallel has finished, or a deadline has passed, before going on., then hand all the results to one aggregator. Each branch sees only its own prompt and the shared input; branches never talk to each other while they run.

On the Acme data room, a run looks like this:

  1. Split. Code builds the list of branch tasks: legal_review, financial_review and market_review, each with its own focused prompt and the same data room.
  2. Fan out. All three calls start together, with a limit on how many run at once and a timeout for each.
  3. Review. Each branch returns its findings in a fixed format: what it found, how serious it is, and the document that shows it. The legal review flags a customer contract that ends on a change of control.
  4. Fan in. A barrier waits until every branch has finished or timed out. All three reviews came back; had one timed out, the barrier would record it as missing.
  5. Aggregate. One more LLM call merges the three reports into a risk summary. It keeps every distinct risk, says which review raised it, and states where two reviews disagree.
  6. Return. The analyst gets the summary about 25 seconds after uploading, with a line saying all three reviews completed.

That run is sectioning. With voting, three branches would each read the same contracts for change-of-control clauses, and code would flag a clause if any of them reports it. The nearest pattern, Orchestrator–Workers, has the same fan-out shape, but there a lead model decides at run time how many subtasks exist and what each covers; here your code wrote the list before the run.

Structure

The data room goes to a splitter in code, which starts three isolated review calls at the same time; their results go to a fan-in barrier, then to an aggregator that produces the report with branch status.run at the same time: at most 3 in flight, 60 s timeout eachData roomSplittercode, fixedLegal reviewisolated LLM callFinance reviewisolated LLM callMarket reviewisolated LLM callFan-inwaits for allAggregatorLLM synthesisReportwith branch status12345
Scroll to see all of it.

Hover over a number, or tap it, to read what it is.

Solid arrows carry the input forward and dashed arrows carry a branch’s result back. The accent arrows are the fan-out, which code starts.
  1. Splitter. Code that turns the input into a fixed list of branch tasks, each with its own prompt. It is written before the run, and no branch’s task depends on another’s result.
  2. Branches. One LLM call per subtask or per sample, started at the same time under a concurrency limit and a timeout. Each returns its result in a known format and never sees the other branches.
  3. Fan-in barrier. Waits for every branch, a quorum or a deadline, and records which branches succeeded and which failed.
  4. Aggregator. Turns the branch outputs into one result, either with plain code (a union, a majority vote, a k-of-N threshold) or with one more LLM call that writes a synthesis.
  5. Result with branch status. The merged answer, plus which branches completed, whether the result is missing a part, and for voting the vote counts.

Use it when / Avoid it when

Use it when

Avoid it when

How it fails

Hidden dependency

One branch needed a fact another branch found, and their reports contradict each other with no way for the merge to tell why.

Mitigation: draw the dependencies between subtasks before building, and chain any two that are linked.

Silent partial failure

One branch errors and the aggregator merges the rest as if nothing happened, so a section is missing or a vote is skewed.

Mitigation: choose a failure policy up front (fail the run, require a quorumQuorum The minimum number of branches that must succeed for the result to count, such as 3 of 5., or mark the result as incomplete) and have the aggregator write “not available” for a missing part.

Rate-limit storm

All branches start at once, many get HTTP 429 errors, and immediate retries make the burst worse.

Mitigation: cap concurrency below the provider’s limit and retry with exponential backoff.

Correlated errors

Every vote shares the same mistake, so the majority is confidently wrong, and adding votes only adds cost.

Mitigation: vary the branches (different prompts, shuffled answer options, different models), or check answers with tests where you can.

Related patterns

Try it

Describe the shared input and one row per branch. The generator writes a prompt for each branch, the aggregator prompt or rule, and a run spec for your fan-out code: limits, failure policy and aggregation rule.

Further reading