【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生成

相关推荐
zwjapple15 分钟前
skill总结
大数据·elasticsearch·搜索引擎
百年江湖随意沉浮1 小时前
DATA AI · 数据可视化
大数据
SelectDB1 小时前
实时更新排错现场:导入了却查到旧数据,和 FINAL 越加越慢的两条路
大数据·数据库·数据分析
SelectDB1 小时前
拿 Planet 的账单一行行对下来,我总结出三个可自查的校验点
大数据·数据库·数据分析
SelectDB2 小时前
Apache Doris + Vane:让多模态数据进入业务分析
大数据·数据库·数据分析
考拉讲支付2 小时前
延迟分账 / 核销分账的技术实现方案:服务完成后再分钱,到底怎么设计?
大数据·运维·人工智能·微信小程序·小程序·系统架构
大大大大晴天️2 小时前
Agent Loop 深度解析:理解、规划、行动、观察与纠错
大数据·ai-agent
ADAI_Bowen2 小时前
写文章 - 知乎
大数据·运维·人工智能
2601_967212722 小时前
安全型轨道式插座合规资质核查与工程选型技术要点
大数据·经验分享·安全
人工智能培训3 小时前
知识图谱:结构化表达实体与关系的知识组织技术
大数据·人工智能·算法·重构·生活·知识图谱