Page 264 - 《软件学报》2025年第7期
P. 264
秦政 等: 面向 Apache Flink 流式分析应用的高吞吐优化技术 3185
Stream processing systems in big data, exemplified by Apache Flink, have been widely applied. Flink enhances system throughput by
parallelizing computing tasks across cluster nodes. However, current research indicates that Flink has weak single-point performance and
poor cluster scalability. To improve the throughput of stream processing systems, researchers have focused on optimizations in designing
control planes, implementing system operators, and improving vertical scalability. However, there is still a lack of attention to the data
flow in streaming analysis applications. These applications are driven by event streams and employ stateful processing functions, including
low voltage detection in smart grids and advertising recommendation. This study analyzes the data flow characteristics of typical streaming
analysis applications, identifies three bottlenecks in optimizing scalability, and proposes corresponding optimization strategies: the key-level
watermark strategy, the dynamic load distribution strategy, and the the key-value based exchange strategy. Based on these optimization
strategies, this study implements Trilink based on Flink and applies it to various applications such as low voltage detection, bridge arch
crowns monitoring, and the Yahoo Streaming Benchmark. Experimental results show that the modified system, Trilink, achieves more than
a 5-fold increase in throughput in a single-machine environment and over a 1.6-fold improvement in horizontal scalability acceleration in
an 8-node setup, compared to Flink.
Key words: streaming processing; distributed system; performance optimization; big data system
1 引 言
随着互联网的快速发展, 特别是物联网、移动计算等技术的广泛应用 [1,2] , 人类社会进入“万物互联”时代, 由
此产生的数据规模快速膨胀. 海量数据赋能了众多数据驱动的行业应用, 包括智能交通、智慧城市、智能电网、
智慧物流、商品推荐等, 数据已经成为重要的生产要素. 在上述广泛业务场景下, 数据实时产生、传递并等待分析.
流式数据 [3] 指持续产生、没有边界的数据, 如物联网设备上的传感器数据和网页上的广告点击事件等. 流式
数据准确地刻画现实世界连续不断的动态变化, 蕴含着丰富的分析价值. 流式数据通常由流式处理系统进行实时
分析, 通过持续的计算任务快速地对数据进行处理并给出响应. 例如, 在交通基础设施数字化中的隧道施工场景
下, 可以通过传感器实时采集拱顶沉降数据并进行处理分析, 提高监测和预警能力, 从而增强施工安全保障. 另一
方面, 流式数据往往具有流速大, 流量快的特点. 例如, 在典型电网场景中, 数据以每秒 10 万级的速度流入中央处
理节点; FaceBook 每小时的图片上传量约 15 000 000 张 ; 阿里巴巴在线交易每秒产生约 580 000 条实时交易数据 ,
[5]
[4]
对系统性能提出了极高的要求.
[6]
流式处理系统 Apache Flink 已经被广泛采用, 并在多个领域证明了其价值 [7–10] . Flink 通过高效的并行化计算
设计, 有效增加系统处理能力, 满足日益增长的数据处理需求. 然而, 尽管现有的流式处理技术在性能和可用性方
面取得了显著进步, 但它们在水平可扩展性方面仍存在不足, 特别是在处理高速数据流或面临高复杂度计算时, 系
统可能会面临性能瓶颈问题. 例如, 计算负载的不均衡会导致单点性能瓶颈和整体吞吐率下降. 已有研究指出 [11] ,
以 Yahoo Streaming Benchmark [12] 为例的 Flink 流式数据分析应用的水平可扩展性随节点数增多加速比逐渐下降,
从 1 节点拓展到 4 节点时, 吞吐率提升 1 倍, 但是从 4 节点扩展到 16 节点时, 吞吐率没有任何提升.
海量数据及其规模的持续增加对流式数据处理系统的性能提出了更高的要求. 因此, 针对流式处理系统的水
平可扩展性进行优化具有实际的研究意义, 这不仅可以进一步提高系统处理能力, 也可以在同等计算能力下有效
节约硬件资源. 已有优化工作尝试从动态资源分配和任务调度等方法提高 Flink 水平扩展性从而提高系统吞吐, 然
而它们往往需要针对特定的计算任务和流式数据分布特性进行配置, 在面对动态变化的实时数据流时, 其存在着
较明显的滞后性和较大的计算开销.
本工作在分析典型流式分析应用的基础上进行通用数据流建模, 从数据流视角观察分析流式处理过程中可能
存在的瓶颈问题, 并针对性的通过测试和分析进行验证; 进一步地, 结合测试分析结果, 设计一系列的优化机制和
策略应对水平扩展的瓶颈问题, 提高流式处理系统性能.
首先, 通过对多个典型流式处理应用的数据流进行分析, 发现显著影响 Flink 流式处理系统的实时处理和水平
扩展能力的问题如下.
(1) 数据乱序耦合: 在流式数据的产生、采集和传输中, 存在不可避免的数据乱序, 造成计算结果的不确定性.
为保证计算正确性, 现有 Flink 系统采用子任务级水位线机制, 当数据达到水位线阈值后再进行计算消费. 然而, 在

