# Lambda架构

**Lambda架构**是一种数据处理架构，它让批处理管道和流处理管道并行运行，并在查询时合并两者的结果，这样用户既能从批处理层得到精确答案，又能从流处理层得到低延迟、部分近似的答案。该架构由[Apache Storm](https://www.edgepedia.org/zh/apache-storm)的创造者内森·马尔茨（Nathan Marz）提出，包含三个部分：批处理层、服务层和速度层。<sup>[1](https://www.manning.com/authors/nathan-marz)</sup><sup> • </sup><sup>[2](https://narcismiclaus.com/programming/architecture/47-lambda-vs-kappa/)</sup><sup> • </sup><sup>[3](https://sfb876.tu-dortmund.de/PublicPublicationFiles/sfbgk_etal_2015a.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 提出者 | Apache Storm的创造者内森·马尔茨，他定义了该架构，后来在Manning出版的一本书中作了介绍<sup>[1](https://www.manning.com/authors/nathan-marz)</sup> |
| 结构 | 批处理层、服务层和速度层<sup>[3](https://sfb876.tu-dortmund.de/PublicPublicationFiles/sfbgk_etal_2015a.pdf)</sup> |
| 合并模型 | 批处理和流处理管道并行运行，在查询时合并；批处理部分精确，实时尾部部分近似<sup>[2](https://narcismiclaus.com/programming/architecture/47-lambda-vs-kappa/)</sup> |
| 主要批评 | 维护两套计算相同内容的代码库，杰伊·克雷普斯（Jay Kreps）于2014年提出<sup>[2](https://narcismiclaus.com/programming/architecture/47-lambda-vs-kappa/)</sup> |
| 替代方案 | Kappa架构，由LinkedIn的杰伊·克雷普斯于2014年夏天提出，只运行流处理管道，在需要批处理视图时重放历史日志<sup>[4](https://www.ericsson.com/en/blog/2015/11/data-processing-architectures--lambda-and-kappa)</sup><sup> • </sup><sup>[2](https://narcismiclaus.com/programming/architecture/47-lambda-vs-kappa/)</sup> |
| 采用者 | 包括Yahoo和Netflix在内的公司使用<sup>[4](https://www.ericsson.com/en/blog/2015/11/data-processing-architectures--lambda-and-kappa)</sup> |
| 声称的特性 | 健壮性、容错性、可伸缩性、通用性、可扩展性、即席查询、最少维护、低延迟读取和更新<sup>[5](https://arxiv.org/abs/1708.04796)</sup> |

## 三层结构

马尔茨提出的架构由传统的批处理层、服务层和速度层组成。<sup>[3](https://sfb876.tu-dortmund.de/PublicPublicationFiles/sfbgk_etal_2015a.pdf)</sup>批处理层在完整的历史数据集上计算精确结果，例如一个MapReduce或Spark作业将七天的事件聚合为一个计数。速度层使用Storm或Flink等流处理器实时执行相同的聚合，覆盖批处理层尚未处理的数据。服务层在查询到达时合并两个视图。<sup>[2](https://narcismiclaus.com/programming/architecture/47-lambda-vs-kappa/)</sup>

设计目标是建立一个容错、可伸缩、支持批量和增量更新且可扩展的实时数据处理架构。<sup>[4](https://www.ericsson.com/en/blog/2015/11/data-processing-architectures--lambda-and-kappa)</sup>在2011年至2015年的环境中，这是一个站得住脚的设计：低延迟答案来自速度层，精确答案来自批处理层，架构能优雅地承受引擎故障，因为批处理层下次运行时会赶上进度，而速度层的近似结果丢弃成本很低。<sup>[2](https://narcismiclaus.com/programming/architecture/47-lambda-vs-kappa/)</sup>

## 克雷普斯的批评与Kappa

主要的反对意见由[杰伊·克雷普斯](https://www.edgepedia.org/zh/jay-kreps)于2014年提出，此后多年被许多人附和，即Lambda迫使开发者维护两套执行相同计算的独立代码库。两条管道中的逻辑完全相同，但实现是重复的，使用不同的语言、针对不同的API、使用不同的测试工具、部署到不同的基础设施，而且往往由不同的团队负责。<sup>[2](https://narcismiclaus.com/programming/architecture/47-lambda-vs-kappa/)</sup>

2014年夏天，当时负责LinkedIn数据基础设施工作、也是Kafka共同创造者的克雷普斯发表了一篇文章，描述了他所谓的[Kappa架构](https://www.edgepedia.org/zh/kappa-architecture)，该架构解决了与Lambda相关的一些陷阱。他在2014年的文章《质疑Lambda架构》中论证，不可变日志加上流处理可以同时支持实时计算和重新处理：Kappa只运行流处理管道，在需要批处理视图时重放历史日志。<sup>[4](https://www.ericsson.com/en/blog/2015/11/data-processing-architectures--lambda-and-kappa)</sup><sup> • </sup><sup>[6](https://www.automq.com/blog/lambda-vs-kappa-architecture-2026-diskless-kafka)</sup><sup> • </sup><sup>[2](https://narcismiclaus.com/programming/architecture/47-lambda-vs-kappa/)</sup>

Kappa并非在所有情况下都是Lambda的替代品。一些部署在Lambda架构上的用例无法迁移到Kappa架构，评估哪种架构适合给定用例可能很困难，错误的设计决策会给数据分析项目带来严重后果。<sup>[4](https://www.ericsson.com/en/blog/2015/11/data-processing-architectures--lambda-and-kappa)</sup>

## 实践中的使用与批评

Lambda架构已被证明与许多用例相关，并已被包括Yahoo和Netflix在内的公司使用，但它因可能产生的编码开销而受到批评。<sup>[4](https://www.ericsson.com/en/blog/2015/11/data-processing-architectures--lambda-and-kappa)</sup>

## 云平台上的实现

云厂商将这一模式打包为参考设计。[亚马逊云科技](https://www.edgepedia.org/zh/amazon-web-services)（Amazon Web Services）发布了一份存档白皮书《AWS上的批处理和流处理Lambda架构》，其中Kinesis Data Analytics为流处理层分析的指标构建近实时仪表板。<sup>[7](https://d1.awsstatic.com/whitepapers/lambda-architecure-on-for-batch-aws.pdf)</sup>后来的一篇AWS大数据博客文章展示了如何完全无服务器地构建Lambda架构，使用[AWS Glue](https://www.edgepedia.org/zh/aws-glue)——一个完全托管的提取、转换和加载（ETL）服务——替代EC2集群，用于数据收集、批处理、流处理和服务层。<sup>[8](https://aws.amazon.com/blogs/big-data/unite-real-time-and-batch-analytics-using-the-big-data-lambda-architecture-without-servers/)</sup>

## 近期发展

对于新建项目，Lambda和Kappa都越来越被视为遗留模式。存储已被Iceberg和Delta等格式合并为单一的ACID湖仓层，查询界面已被Flink、Materialize和[RisingWave](https://www.edgepedia.org/zh/risingwave)等引擎合并为流式SQL，因此，2011年采用Lambda时还算合理的双代码维护成本，如今只有越来越少的团队还在承担；对于大多数新管道，决策规则变成了“都不用，用湖仓。”<sup>[9](https://pipecode.ai/blogs/lambda-vs-kappa-architecture-2026)</sup>厂商从平台侧提出了同样的论点：[Databricks](https://www.edgepedia.org/zh/databricks)将其湖仓描述为通过在一个平台上统一批处理和流处理工作负载而不是维护独立的技术栈来简化lambda风格的模式。<sup>[10](https://www.databricks.com/blog/what-is-lambda-architecture)</sup>

尽管如此，该架构仍然是一个活跃的研究模板。关于易变环境中大数据分析的工作使用迁移、复制、[MapReduce](https://www.edgepedia.org/zh/mapreduce)模拟以及批处理和流处理组合处理来构建Lambda架构的策略，<sup>[5](https://arxiv.org/abs/1708.04796)</sup>后来关于多模态批处理和流处理集成的提案也自称受到lambda架构的启发。<sup>[11](https://arxiv.org/abs/2108.04343)</sup>

## References

1. [Nathan Marz, Manning author page](https://www.manning.com/authors/nathan-marz)
2. [Lambda vs kappa architecture, Narcis Miclaus](https://narcismiclaus.com/programming/architecture/47-lambda-vs-kappa/)
3. [Fundamentals of Real-Time Data Processing Architectures Lambda and Kappa (Gkolfani et al., TU Dortmund)](https://sfb876.tu-dortmund.de/PublicPublicationFiles/sfbgk_etal_2015a.pdf)
4. [Data processing architectures – Lambda and Kappa, Ericsson blog (2015)](https://www.ericsson.com/en/blog/2015/11/data-processing-architectures--lambda-and-kappa)
5. [Strategies for Big Data Analytics through Lambda Architectures in Volatile Environments, arXiv](https://arxiv.org/abs/1708.04796)
6. [Lambda vs Kappa Architecture in 2026: When Diskless Kafka Changes the Math, AutoMQ blog](https://www.automq.com/blog/lambda-vs-kappa-architecture-2026-diskless-kafka)
7. [Lambda Architecture for Batch and Stream Processing on AWS, AWS whitepaper (archived)](https://d1.awsstatic.com/whitepapers/lambda-architecure-on-for-batch-aws.pdf)
8. [Unite Real-Time and Batch Analytics Using the Big Data Lambda Architecture, Without Servers!, AWS Big Data Blog](https://aws.amazon.com/blogs/big-data/unite-real-time-and-batch-analytics-using-the-big-data-lambda-architecture-without-servers/)
9. [Lambda vs Kappa Architecture: When Each Wins in 2026, PipeCode blog](https://pipecode.ai/blogs/lambda-vs-kappa-architecture-2026)
10. [What is Lambda Architecture?, Databricks](https://www.databricks.com/blog/what-is-lambda-architecture)
11. [Towards a Generic Multimodal Architecture for Batch and Streaming Big Data Integration, arXiv](https://arxiv.org/abs/2108.04343)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026; Oct 25, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 人工智能与数据 › Databases and data systems › Data mining, warehousing, and big data › Big data concepts

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/lambda-architecture

English original: https://www.edgepedia.org/lambda-architecture
