# 数据流模型

数据流模型（Dataflow model）是一种用于分布式数据处理的编程模型，它统一了对有界和无界数据集的批处理与流式分析，让开发者可以在正确性、延迟和成本之间做出权衡，而不必拘泥于独立的批处理或流式系统。该模型由[泰勒·阿基道](https://www.edgepedia.org/zh/tyler-akidau)（Tyler Akidau）与谷歌的十位同事在2015年VLDB论文《数据流模型：在大规模、无界、乱序数据处理中平衡正确性、延迟与成本的实用方法》（《VLDB基金会会刊》第8卷，第1792–1803页）中提出<sup>[1](https://research.google/pubs/the-dataflow-model-a-practical-approach-to-balancing-correctness-latency-and-cost-in-massive-scale-unbounded-out-of-order-data-processing/)</sup>。2015年发布的[Google Cloud Dataflow](https://www.edgepedia.org/zh/google-cloud-dataflow)将该模型实现为托管服务，而该模型的开源化身是[Apache Beam](https://www.edgepedia.org/zh/apache-beam)项目，其核心概念“基于Beam模型（原称数据流模型）”<sup>[2](https://blog.tensorflow.org/2020/03/tensorflow-extended-tfx-using-apache-beam-large-scale-data-processing.html)</sup><sup> • </sup><sup>[3](https://beam.apache.org/documentation/runners/capability-matrix/)</sup>。

| 关键事实 | 详情 |
|---|---|
| 定义性出版物 | 阿基道等，《VLDB基金会会刊》8（2015），第1792–1803页<sup>[1](https://research.google/pubs/the-dataflow-model-a-practical-approach-to-balancing-correctness-latency-and-cost-in-massive-scale-unbounded-out-of-order-data-processing/)</sup> |
| 渊源 | 由谷歌的FlumeJava（批处理）和MillWheel（流处理）系统演化而来<sup>[4](https://research.google.com/pubs/archive/43864.pdf)</sup> |
| 核心主张 | 其语义足够通用，足以涵盖标准批处理、微批处理和流处理模型，以及Lambda架构的混合语义<sup>[5](https://web.stanford.edu/class/cs245/readings/dataflow-model.pdf)</sup> |
| 关键抽象 | 用于聚合无界、乱序数据的窗口、水位和触发器<sup>[6](https://docs.cloud.google.com/dataflow/docs/concepts/streaming-pipelines)</sup> |
| 开源形式 | Apache Beam；Dataflow SDK于2016年2月1日进入Apache孵化器<sup>[7](https://cloud.google.com/blog/products/gcp/dataflow-and-open-source-proposal-to-join-the-apache-incubator/)</sup> |
| 运行器 | 在Dataflow、Flink、Jet、Nemo、Prism、Spark和Twister2上支持可移植性<sup>[8](https://beam.apache.org/roadmap/)</sup> |
| 处理保证 | Dataflow默认对每条记录提供精确一次处理<sup>[9](https://docs.cloud.google.com/dataflow/docs/overview)</sup> |

## 动机：正确性、延迟与成本

论文从无界、无序、全球规模数据集（如网络日志、移动使用统计和传感器网络）的增长出发，也从消费者需求（如事件时间排序和按数据特征开窗）出发。论文认为，系统永远无法同时在正确性、延迟和成本三个维度上实现全面优化，因此实践者需要原则性的抽象，以便在这些轴线上选择合适的权衡<sup>[1](https://research.google/pubs/the-dataflow-model-a-practical-approach-to-balancing-correctness-latency-and-cost-in-massive-scale-unbounded-out-of-order-data-processing/)</sup>。

作者声明的转变是：不再把无界数据集视为最终会变得完整的有限池。在该模型下，新数据会到达，旧数据可能被撤回，系统永远无法知道是否或何时已经看到了全部数据<sup>[1](https://research.google/pubs/the-dataflow-model-a-practical-approach-to-balancing-correctness-latency-and-cost-in-massive-scale-unbounded-out-of-order-data-processing/)</sup>。论文将此与[MapReduce](https://www.edgepedia.org/zh/mapreduce)、FlumeJava和Spark等批处理系统相对照，称这些系统未能满足所述的无界数据需求<sup>[4](https://research.google.com/pubs/archive/43864.pdf)</sup>。

## 核心原语与四个问题

在实现该模型的SDK中，两个核心转换作用于流经系统的（键，值）对，其API是FlumeJava API的演进<sup>[5](https://web.stanford.edu/class/cs245/readings/dataflow-model.pdf)</sup>。在当今使用的Apache Beam表述中，管道是应用于集合的转换图：`PCollection`是数据集合，可以是有界的（固定大小，批处理）或无界的（持续更新，流处理）；`PTransform`是对集合的操作，其中`ParDo`是核心并行处理操作，对每个元素调用用户指定的函数<sup>[10](https://docs.cloud.google.com/dataflow/docs/concepts/beam-programming-model)</sup>。

Beam能力矩阵将模型的概念组织为四个问题：**计算什么**结果，在事件时间中的**何处**，在处理时间中的**何时**，以及结果的细化**如何**关联<sup>[3](https://beam.apache.org/documentation/runners/capability-matrix/)</sup>。根据一项流处理系统综述，数据流模型将对乱序数据的处理分为三个方面：处理迟到记录的事件时间、产生匹配输出的处理时间，以及后续更新与已生成结果的连接方式<sup>[11](https://link.springer.com/article/10.1007/s00778-023-00819-8)</sup>。

## 窗口、水位与触发器

**窗口**决定了数据在事件时间中何处分组。固定（滚动）窗口由静态大小定义，如每小时或每天的窗口；滑动窗口由窗口大小和滑动周期定义，如每分钟开始的每小时窗口；窗口可以在所有数据上对齐，也可以按键不对齐<sup>[5](https://web.stanford.edu/class/cs245/readings/dataflow-model.pdf)</sup>。在Beam中，`GroupByKey`和`Combine`等聚合转换按窗口工作，将无界集合作为一系列有限窗口来处理<sup>[12](https://beam.apache.org/documentation/programming-guide/)</sup>。

**水位**是系统关于窗口中所有数据预计何时到达的概念。数据不保证按时间顺序或可预测的间隔到达，因此一旦水位越过窗口末尾，此后到达且时间戳落在该窗口内的任何元素都属于迟到数据<sup>[6](https://docs.cloud.google.com/dataflow/docs/concepts/streaming-pipelines)</sup>。论文指出水位的两个缺陷：有时太快，导致迟到数据落在水位之后；有时太慢，因为作为全局进度指标，单个慢速数据点可能拖住整个管道。因此作者得出结论：仅靠水位是不够的<sup>[5](https://web.stanford.edu/class/cs245/readings/dataflow-model.pdf)</sup>。

**触发器**决定了分组结果在处理时间中何时作为窗格发出。Beam提供事件时间触发器、处理时间触发器、数据驱动触发器（目前在达到一定元素数量后触发）以及组合这些的复合触发器；触发器允许在窗口完成前产生早期结果，并在水位越过窗口后处理迟到数据<sup>[12](https://beam.apache.org/documentation/programming-guide/)</sup>。该模型还定义了同一窗口的多个窗格如何关联：在丢弃模式下，触发时丢弃窗口内容，后续结果与先前结果无关；在累积模式下，内容保存在持久状态中，后续结果细化先前结果——论文将这种模式与[Lambda架构](https://www.edgepedia.org/zh/lambda-architecture)系统联系起来<sup>[5](https://web.stanford.edu/class/cs245/readings/dataflow-model.pdf)</sup>。

## 与其他模型的关系

根据论文，数据流模型的语义足够宽泛，足以涵盖传统的批处理、微批处理和流处理方法，以及Lambda架构的流批结合语义<sup>[5](https://web.stanford.edu/class/cs245/readings/dataflow-model.pdf)</sup>。Lambda架构在同一数据上运行独立的批处理管道和速度管道；数据流模型则在单一管道内提供Lambda模式通过运行两个系统获得的低延迟估计和最终细化<sup>[5](https://web.stanford.edu/class/cs245/readings/dataflow-model.pdf)</sup>。2023年的一项流处理系统综述将该模型与MillWheel、Flink和Spark并列为普及水位和触发器概念的贡献者<sup>[11](https://link.springer.com/article/10.1007/s00778-023-00819-8)</sup>；2025年《SIGMOD Record》的一篇专栏文章将数据流模型描述为重塑了云数据处理的转变，并指出Apache Flink作为流行的Beam运行器的崛起加速了行业采用<sup>[13](https://sigmodrecord.org/publications/sigmodRecord/2509/pdfs/full-issue.pdf)</sup>。

## 从谷歌服务到Apache Beam

Google Cloud Dataflow是建立在该模型上的托管服务，于2015年发布，并于2015年8月12日正式可用<sup>[2](https://blog.tensorflow.org/2020/03/tensorflow-extended-tfx-using-apache-beam-large-scale-data-processing.html)</sup><sup> • </sup><sup>[14](https://cloudplatform.googleblog.com/2015/08/Announcing-General-Availability-of-Google-Cloud-Dataflow-and-Cloud-Pub-Sub.html)</sup>。2016年1月，谷歌提议将Cloud Dataflow SDK和运行器迁入Apache孵化器；该提案于2016年2月1日被接受，由此产生的项目即Apache Beam<sup>[7](https://cloud.google.com/blog/products/gcp/dataflow-and-open-source-proposal-to-join-the-apache-incubator/)</sup>。[Apache软件基金会](https://www.edgepedia.org/zh/apache-software-foundation)董事会会议记录将Beam的成立日期记为2016年12月20日，截至2025年9月的报告，其有99名提交者和26名PMC成员<sup>[15](https://www.apache.org/foundation/board/minutes/Beam.html)</sup>。

Beam声明的愿景是：开发者基于Beam模型（其等同于数据流模型）表达管道，并在引擎和编程语言之间自由选择，编写可在[Apache Flink](https://www.edgepedia.org/zh/apache-flink)和Spark等开源运行器以及Google Cloud Dataflow等专有运行器之间移植的管道<sup>[16](https://beam.apache.org/about/)</sup>。目前，Dataflow、Flink、Jet、Nemo、Prism、Spark和Twister2运行器支持可移植性<sup>[8](https://beam.apache.org/roadmap/)</sup>。SDK提供Java、Python和Go版本，另有实验性的TypeScript SDK和YAML API<sup>[12](https://beam.apache.org/documentation/programming-guide/)</sup>。Dataflow本身对批处理和流分析使用相同的编程模型，为每个作业分配一个虚拟机池来运行，并执行后端优化以实现并行化<sup>[9](https://docs.cloud.google.com/dataflow/docs/overview)</sup><sup> • </sup><sup>[10](https://docs.cloud.google.com/dataflow/docs/concepts/beam-programming-model)</sup>。

## References

1. [Tyler Akidau et al. (2015). The Dataflow Model: A Practical Approach to Balancing Correctness, Latency, and Cost in Massive-Scale, Unbounded, Out-of-Order Data Processing. Proceedings of the VLDB Endowment 8, 1792-1803.](https://research.google/pubs/the-dataflow-model-a-practical-approach-to-balancing-correctness-latency-and-cost-in-massive-scale-unbounded-out-of-order-data-processing/)
2. [TensorFlow Blog (2020). TensorFlow Extended (TFX): Using Apache Beam for large scale data processing.](https://blog.tensorflow.org/2020/03/tensorflow-extended-tfx-using-apache-beam-large-scale-data-processing.html)
3. [Apache Beam Capability Matrix](https://beam.apache.org/documentation/runners/capability-matrix/)
4. [The Dataflow Model (full paper PDF), Google Research](https://research.google.com/pubs/archive/43864.pdf)
5. [The Dataflow Model (paper PDF), Stanford CS245 readings](https://web.stanford.edu/class/cs245/readings/dataflow-model.pdf)
6. [Streaming pipelines, Cloud Dataflow documentation, Google Cloud](https://docs.cloud.google.com/dataflow/docs/concepts/streaming-pipelines)
7. [Dataflow and open source - proposal to join the Apache Incubator, Google Cloud Blog](https://cloud.google.com/blog/products/gcp/dataflow-and-open-source-proposal-to-join-the-apache-incubator/)
8. [Apache Beam Roadmap](https://beam.apache.org/roadmap/)
9. [Dataflow overview, Google Cloud documentation](https://docs.cloud.google.com/dataflow/docs/overview)
10. [Programming model for Apache Beam, Cloud Dataflow documentation, Google Cloud](https://docs.cloud.google.com/dataflow/docs/concepts/beam-programming-model)
11. [A survey on the evolution of stream processing systems, The VLDB Journal (2023)](https://link.springer.com/article/10.1007/s00778-023-00819-8)
12. [Beam Programming Guide, Apache Beam documentation](https://beam.apache.org/documentation/programming-guide/)
13. [SIGMOD Record, September 2025, reflection on The Dataflow Model](https://sigmodrecord.org/publications/sigmodRecord/2509/pdfs/full-issue.pdf)
14. [Announcing General Availability of Google Cloud Dataflow and Cloud Pub/Sub, Google Cloud Platform Blog (2015)](https://cloudplatform.googleblog.com/2015/08/Announcing-General-Availability-of-Google-Cloud-Dataflow-and-Cloud-Pub-Sub.html)
15. [Board minutes: Beam, Apache Software Foundation](https://www.apache.org/foundation/board/minutes/Beam.html)
16. [About Apache Beam](https://beam.apache.org/about/)

---
*Initially written Oct 26, 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/dataflow-model

English original: https://www.edgepedia.org/dataflow-model
