31. Pipeline patterns: choosing and combining
Eight pipeline patterns, each with its own trade: ETL and ELT, event-at-a-time streaming and micro-batch, Lambda and Kappa, fan-out and event-driven handlers. Choose per workload by four questions (freshness, where the transformations belong, recovery and replay, delivery), then combine the patterns around one published event.
- Theory 24: ETL: transform before you load
- Theory 25: ELT: load, then transform in the platform
- Theory 26: Event-at-a-time streaming: state, event time and backpressure
- Theory 27: Micro-batch: a stream as small batches
- Theory 28: The Lambda architecture: two paths and their cost
- Theory 29: The Kappa architecture: one path, replayed
- Theory 30: Fan-out: one event, many independent consumers
- Theory 31: Event-driven pipelines: handlers that are safe to retry
- Theory 32: How to choose and combine pipeline patterns
The clip publishes the ClaimReported event once and follows it to Harbour Mutual's four workloads: the acknowledgement letters (an event-driven handler, ready in ten seconds), fraud scoring (a Kappa stream job, about half a minute), finance month-end (an ETL batch, readable at 10:05) and the search index (a five-minute micro-batch, about three minutes). Then the search index goes down and only search waits; two deliveries repeat and the letters handler posts each letter once; the fraud features change and only the fraud job is replayed.
The idea: a pattern per workload, combined around the event
The Theory section Pipeline patterns takes each pattern apart on the same ten claim events; this chapter puts them back together. Each pattern answers a different need:
- ETL runs the rules before the target; ELT keeps the raw data and runs them in the platform.
- Event-at-a-time streaming handles each event as it arrives, with state; micro-batch handles a stream in small batches, trading freshness for overhead.
- Lambda keeps a batch of record beside a fast path, at the cost of two code paths; Kappa keeps one path and recomputes by replaying the log.
- Fan-out gives one event to many independent consumers; event-driven handlers start work when a business event happens, and must be idempotent.
Choose by asking four questions in order: how fresh must it be; where do the transformations belong; how does it recover, and can it replay; how is it delivered downstream. Then combine: publish each business event once, and let each workload subscribe with its own pattern.
A worked example: one event, four workloads
| Workload | Freshness | Transformations | Recovery and replay | Delivery | Pattern |
|---|---|---|---|---|---|
| Claims notifications | Minutes: a micro-batch is fresh enough, and so is anything that streams. | In a handler per event: there is nothing to aggregate, only one action to take for each claim. | Never by replaying: a replay would send every letter again. A handler retries, and remembers what it has done. | As an event routed to its handler, which must be idempotent because delivery can repeat. | Event-driven |
| Fraud scoring | Seconds: only processing each event as it arrives is fresh enough. | In a stateful stream job: each score needs the customer's recent claims, kept as the job's state. | Its logic changes and every score must be recomputed: keep the log and replay it through the new job. | As one of several independent consumers of the same event: a fan-out, so its failure stops nobody else. | Kappa architecture |
| Finance month-end | A day is enough: a scheduled batch. | Before the target: its readers cannot be kept out of a raw zone, so the rules run on the way in. | The batch is the book of record: a failed load is run again from the source for the period. | As one of several independent consumers of the same event: a fan-out, so its failure stops nobody else. | ETL |
| Search index | Minutes: a micro-batch is fresh enough, and so is anything that streams. | In small batches: the sink takes bulk writes, so events are grouped before they are written. | From its checkpoint: the next batch reads on from the last committed offset, and a rebuild reads the log again. | As one of several independent consumers of the same event: a fan-out, so its failure stops nobody else. | Micro-batch |
The search index's micro-batch every five minutes needs 5 batches for the morning's claims, 100 seconds of overhead, and a claim waits 3 min 17 s on average. The fraud job, if it ran as Lambda instead of Kappa, would keep 3 rules in two code paths (6 test suites).
A replay of the fraud job at full size, thirty days of the log read at 2,000 events a second while 1.4 a second keep arriving, takes about 30.0 minutes; and the letters handler, without a deduplication key, would post 12 letters for ten claims.
Why it matters for Alex
Every team that touches claims will ask Alex for "real-time". Four questions turn that into four precise answers, each with a cost someone has agreed to: a nightly ETL for finance, a five-minute micro-batch for search, a replayable stream for fraud, an idempotent handler for letters. And one published event means a new workload is a new subscription, not a project.
Where it goes wrong
- One pattern for everything. The monthly report runs on a stream nobody needed, or the fraud model waits for the nightly batch.
- The open raw zone. ELT chosen, raw access never restricted.
- Two code paths drifting. Lambda chosen for freshness, and the speed layer forgotten when a rule changes.
- Consumers chained. One outage stops every team.
- Handlers without a key. Customers receive their letters twice.
Exercises
The lab checks each one against facts written down in advance, so any answer the brief allows passes. A pass is kept in this browser.
Work the numbers
Compute each number from the morning's ten claim events, as the Theory pages do by hand. A small rounding difference is accepted.
Which pattern is this?
Each line is a design note or a failure. Choose the pattern it belongs to.
Which pattern carries the workload
Which pipeline pattern fits this workload? Pass all 8 situations to complete it.
Post the customer an acknowledgement letter within five minutes of reporting a claim, exactly one per claim. The broker delivers at least once.
On Azure
One way to build the combined design on Azure:
- Azure Event Hubs keeps the ClaimReported events (up to 7 days on Standard, 90 on Premium and Dedicated); each workload reads through its own consumer group (20 per event hub on Standard, 100 on Premium), and Event Hubs Capture writes the events to the lake.
- Azure Functions handles the letters; its Event Hubs trigger delivers at least once, so the handler deduplicates on the event id.
- Azure Databricks Structured Streaming runs the fraud job (replayed with a new checkpoint from the earliest offset) and the search index's micro-batch with a
processingTimetrigger. - Azure Data Factory runs finance's ETL on a schedule, with mapping data flows for the transformations.
- Where a broker must deliver to subscribers with retries and dead-lettering, Azure Service Bus topics (a dead-letter queue per subscription) or Azure Event Grid (at least once, dead-lettering to storage) fit.
Take it to work
Pipeline pattern choice
Choose and combine pipeline patterns for the workloads on one event.
The event
- Which business event, its id and its schema
- Where it is published and how long it is kept
Each workload
- How fresh it must be
- Where its transformations belong
- How it recovers, and whether it may be replayed
The pattern
- The pattern chosen per workload, and the reason
Delivery
- Its subscription, its dead-letter queue and their owner
- Its deduplication key, if it acts on each event
Costs accepted
- Overhead, second code paths, retention and replay time
Tools in this chapter
- Pipeline patterns lab · Run the same claim events through eight pipeline patterns and see latency, overhead, a consumer failing, a delivery repeated and a logic change replayed.
- Stream lab · Run one claims feed as batch, Lambda and Kappa side by side, inject a late correction and replay the log.
Terms taught here: ETLELTRaw zoneMicro-batchFan-outEvent-driven