Lambda and Kappa architectures
Many data products need both a complete, accurate view of history and up-to-the-minute results: fraud scores, live dashboards, recommendations. Lambda and Kappa are two architectures for getting both.
- Lambda architecture (described by Nathan Marz) runs two pipelines side by side: a batch layer that periodically recomputes accurate results over all historical data, and a speed layer that processes new events in real time. A serving layer merges the two.
- Kappa architecture (proposed by Jay Kreps in Questioning the Lambda Architecture (opens in a new tab)) uses one streaming pipeline for everything. To reprocess history, you replay the event log through a new version of the same pipeline.
Diagram
Section titled “Diagram”- In Lambda, every event goes to both the batch layer and the speed layer.
- The serving layer combines accurate batch results with recent real-time results.
- In Kappa, one stream processor reads the retained event log.
- To change the logic, a new version replays the log into a new result table, then replaces the old one.
At a glance
Section titled “At a glance”| Aspect | Lambda | Kappa |
|---|---|---|
| Pipelines | Two: batch and streaming | One: streaming |
| Codebases | Two implementations of the same logic | One |
| Reprocessing history | Rerun the batch job | Replay the log through a new pipeline version |
| Accuracy | Batch layer corrects the speed layer | Depends on the stream processor handling late and out-of-order events correctly |
| Storage need | Raw history in the batch store | Long retention in the event log (or tiered storage) |
| Main risk | The two implementations disagree | Replays are slow or expensive for very long histories |
Why Kappa became common
Section titled “Why Kappa became common”Lambda was a response to early stream processors that couldn’t guarantee correct results, so a batch job had to fix them later. Modern stream processors such as Apache Flink (opens in a new tab) handle event time, late data, windowing and consistent state well, and logs such as Apache Kafka (opens in a new tab) can retain data for long periods. That removed much of the need for a second pipeline, and with it the cost of writing every piece of logic twice.
In practice, many current platforms are a hybrid: a streaming pipeline writes into a lakehouse table, and the same table supports both real-time queries and batch reprocessing. The distinction matters less than it did; the lesson of both designs remains.
When each fits
Section titled “When each fits”Lambda still fits when the batch computation is genuinely different (for example training a model over years of data while scoring events in real time), or when the real-time results only need to be approximately right and are corrected overnight.
Kappa fits when the same logic applies to history and to new events, the log can be retained or replayed from storage, and you want one codebase.
Common pitfalls
Section titled “Common pitfalls”- Lambda’s two codebases drifting apart, so dashboards change numbers overnight.
- Kappa replays that take days because the pipeline wasn’t designed to run faster than real time.
- Ignoring event time. Processing by arrival time gives wrong results when events arrive late or out of order.
- Replays that repeat side effects, such as sending notifications again. Keep side effects out of reprocessing paths. See the replay that emailed every customer.
Related patterns
Section titled “Related patterns”Further reading
Section titled “Further reading”- Jay Kreps, Questioning the Lambda Architecture (opens in a new tab) (2014)
- LinkedIn and Kafka
Written and edited by Abhinav Taduka, enterprise software architect.
New pages are added regularly. Follow Abhinav on LinkedIn to see them first.