What Is Fan-Out / Fan-In in CI Pipelines?
Fan-out splits one stage into many parallel jobs; fan-in waits for all of them and joins the results. Together they let CI go wide for speed, then narrow for a single verdict.
Fan-out/fan-in is the fundamental shape of a parallel pipeline. It is how you cut wall-clock time by spreading work across jobs while still ending with one aggregated, gating result.
Fan-out
A single point in the pipeline branches into many independent jobs that run concurrently - splitting a test suite into shards, building several targets, or running a matrix. Each branch is isolated and progresses on its own runner.
Fan-in
After the parallel work, a single job depends on *all* of the fanned-out jobs and runs only once they complete. It aggregates their outputs - merging test reports, combining coverage, or simply acting as the gate that is green only if every branch passed.
jobs:
test:
strategy: { matrix: { shard: [1, 2, 3, 4] } }
report:
needs: test # fan-in: waits for all shardsWhy use it
- Speed: N parallel shards finish in roughly 1/N of the serial time.
- A single fan-in gate gives one clear pass/fail for the whole stage.
- Aggregation (coverage, reports) happens in one place.
Pitfalls
Fan-out multiplies billable minutes and can flood a runner pool, causing queueing. The fan-in job is a synchronization point - it is only as fast as the slowest branch, so an unbalanced split (one shard far heavier than the rest) wastes the parallelism. Balance the shards.
Key takeaways
- Fan-out runs many independent jobs in parallel; fan-in joins their results.
- It trades more billable minutes for less wall-clock time.
- The fan-in job is a gate and a sync point - only as fast as the slowest branch.
- Balance shards so one heavy branch does not negate the parallelism.