【Flink精讲】Flink任务调度机制

Graph 的概念

Flink 中的执行图可以分成四层: StreamGraph -> JobGraph -> ExecutionGraph -> 物理执

行图。

  • StreamGraph:是根据用户通过 Stream API 编写的代码生成的最初的图。用来表示程序的拓扑结构。
  • JobGraph: StreamGraph 经过优化后生成了 JobGraph,提交给 JobManager 的数据结构。主要的优化为,将多个符合条件的节点 chain 在一起作为一个节点,这样可以减少数据在节点之间流动所需要的序列化/反序列化/传输消耗。
  • ExecutionGraph: JobManager 根据 JobGraph 生成 ExecutionGraph。 ExecutionGraph 是JobGraph 的并行化版本,是调度层最核心的数据结构。
  • 物 理 执 行 图 : JobManager 根据 ExecutionGraph 对 Job 进行调度后,在各个TaskManager 上部署 Task 后形成的"图",并不是一个具体的数据结构。

WordCount举例

java 复制代码
public static void main(String[] args) throws Exception {
// 检查输入
final ParameterTool params = ParameterTool.fromArgs(args);
...
// set up the execution environment
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
// get input data
DataStream<String> text =
env.socketTextStream(params.get("hostname"), params.getInt("port"), '\n', 0);
DataStream<Tuple2<String, Integer>> counts =
// split up the lines in pairs (2-tuples) containing: (word,1)
text.flatMap(new Tokenizer())
// group by the tuple field "0" and sum up tuple field "1"
.keyBy(0)
.sum(1);
counts.print();
// execute program
env.execute("WordCount from SocketTextStream Example");
}

StreamGraph在Client生成

分区器

JobGraph在Client生成

ExecutionGraph在JobManager生成

相关推荐
智能运维指南21 分钟前
智能体自治运维选型指南:2026年企业如何从“AI辅助”走向“AI自治”
大数据·运维·人工智能
迅易科技39 分钟前
从数据可视化到运营闭环,制造企业如何构建卓越运营数字化体系?
大数据·制造·big data
Elastic 中国社区官方博客1 小时前
Elasticsearch:什么是向量数据库?
大数据·运维·数据库·人工智能·elasticsearch·搜索引擎·ai
久美子1 小时前
铁轨、迷宫与护栏:AI 数据工程的确定性骨架
大数据
旗开得胜马到成功2 小时前
AI编程智能体删库后,我把开发环境从每日备份换成中科热备CDP秒级回滚
大数据·elasticsearch·ai编程
guanchabao2 小时前
工程项目信息网站选择先避开三个误区,再对着清单挑
大数据
数智化管理手记2 小时前
数据质量无法保障?自动化数据质量规则校验如何搭建方案?
大数据·数据库·自动化
移动云开发者联盟2 小时前
密态计算落地!MobileClaw解锁安全AI新范式
大数据·人工智能·安全
星川皆无恙2 小时前
大数据知识图谱项目:基于neo4j知识图谱+flask的大数据电影问答系统(超详细讲解及源码)
大数据·知识图谱·neo4j
weishuangyun1236 小时前
微信小程序怎么选公司?上线流程详解
大数据·小程序