Pipes and filters
Pipes and filters breaks a processing task into a sequence of independent steps (filters), each doing one job, connected by pipes that carry data from one step to the next. Each filter reads input, transforms it and writes output, without knowing anything about the filters before or after it.
It’s one of the oldest architecture styles. Unix shell pipelines are the classic example (cat log | grep ERROR | sort | uniq -c), and the same idea powers ETL jobs, stream processing platforms, compilers, image and video processing, and document ingestion for AI systems.
Diagram
Section titled “Diagram”- Records flow from a source through a chain of filters, each connected by a pipe such as a queue, topic or stream.
- Each filter does one thing and can be developed, tested, scaled and replaced independently.
- Records that fail a filter go to a dead-letter destination for inspection, instead of stopping the whole pipeline.
How it works
Section titled “How it works”- Filters are independent and single-purpose. Each one has a clear input and output contract. Filters can be written in different languages or run on different infrastructure.
- Pipes decouple and buffer. In a single process, pipes may be in-memory streams. In distributed systems they’re queues, topics or streams (for example Kafka, Pub/Sub, Kinesis), which absorb bursts and let filters run at different speeds.
- Composition. New pipelines are built by rearranging or adding filters, much like Unix commands.
- Parallelism. A slow filter can run as many instances, each reading from the same pipe.
- Batch or streaming. The same style works for nightly batch jobs and continuous streams. Frameworks such as Apache Beam express one pipeline that can run either way.
- Error handling per filter. Bad records go to a dead-letter queue with the reason, so one malformed record doesn’t halt everything.
- Simple, testable steps: each filter can be unit-tested with sample input and output.
- Reuse and recombination: the same filters appear in many pipelines.
- Independent scaling: add capacity only where the bottleneck is.
- Clear data lineage: it’s obvious which step changed what.
- Not for interactive request-response work: pipelines are about throughput, not low-latency answers to a single user.
- Overhead between steps: serializing data through many pipes costs time and money.
- Shared state is awkward: filters that need to join or aggregate across records need careful design (windows, state stores).
- End-to-end debugging across many asynchronous steps needs good tracing and correlation IDs.
When to use it
Section titled “When to use it”- Data integration and ETL or ELT, including feeding a data warehouse or lakehouse.
- Stream processing: fraud scoring, clickstreams, IoT telemetry, log processing.
- Media and document processing: image resizing, video transcoding, OCR, and chunking and embedding documents for RAG.
- Compilers and any workflow that’s naturally a sequence of transformations.
When to avoid it
Section titled “When to avoid it”- Interactive workflows where a user waits for one answer.
- Processes with many branches, loops and human decisions; a workflow or orchestration engine fits better.
Common pitfalls
Section titled “Common pitfalls”- Filters that know about each other, for example a filter that checks which step comes next. That defeats the point.
- Giant filters that do five things, so they can’t be reused or scaled separately.
- No idempotency: when a pipe redelivers a message, the filter processes it twice. See idempotency.
- No dead-letter handling, so one bad record blocks or crashes the pipeline.
- No schema contracts between filters, so an upstream change silently breaks downstream steps.
In practice
Section titled “In practice”- Scenario: moving from nightly batch to real time
- Scenario: reports never match, where pipeline lineage helps reconcile numbers
- LinkedIn: building Kafka to connect every system, the log that turned many pipelines into one platform
Related patterns
Section titled “Related patterns”Glossary: idempotency, eventual consistency
Further reading
Section titled “Further reading”- Gregor Hohpe and Bobby Woolf, Pipes and Filters (opens in a new tab) (Enterprise Integration Patterns)
- Microsoft, Pipes and Filters pattern (opens in a new tab)
- Apache Beam, Programming model overview (opens in a new tab)
- Frank Buschmann et al., Pattern-Oriented Software Architecture, Volume 1 (Wiley, 1996)
Written and edited by Abhinav Taduka, enterprise software architect.
New pages are added regularly. Follow Abhinav on LinkedIn to see them first.