The Pipeline Pattern
A pipeline breaks a computation into a fixed sequence of stages, where the output of one stage becomes the input of the next. Each stage runs on its own worker, and items flow through like products on an assembly line.
The power of a pipeline comes from overlap. While stage two works on the first item, stage one is already processing the second item. Once the pipeline is full, every stage is busy at once, so throughput rises even though each individual item still passes through every stage.
- Stages Each stage does one transformation and passes the result forward.
- Buffers Queues between stages let a faster stage run ahead without waiting.
- Throughput In steady state, the pipeline produces one output per slowest stage time.
The slowest stage sets the pace, much like the slowest worker on an assembly line. This stage is the bottleneck, and speeding up any other stage will not help until the bottleneck is widened, often by splitting it or adding more workers to it.
Latency for a single item is still the sum of all stages, so a pipeline trades steady throughput against per item delay. It shines when you have a steady stream of work rather than one isolated job.
Key idea
A pipeline overlaps stages so each item flows through in sequence while all stages stay busy, and the slowest stage sets the overall throughput.