相关链接

讲真,这节课大概都听不懂(


Shuffle 概述

MapReduce 概述

image-20220818105838700

Map

image-20220818110201543

三张 gif

Shuffle

image-20220818110112097

本质:通过哈希区别不同类型数据

Reduce

image-20220818110128825

为什么 Shuffle 对性能非常重要

image-20220818110332418

总结

image-20220818110546718

批式计算的发展流程

Shuffle 算子

算子分类与应用

image-20220818110639976

image-20220818110821961

这个例子中,把一个 txt 按行分割,然后统计每个单词的个数

reduceByKey 产生 Shuffle,做的是 A + B 的操作(有很多机器)

最后 collect,返回结果

Spark 中对 Shuffle 的抽象 - 宽依赖、窄依赖

image-20220818141952223

image-20220818142111966

Shuffle Dependency

image-20220818142234422

image-20220818142343877

image-20220818142501449

Shuffle 过程

image-20220818142746399

Hash Shuffle

写数据

image-20220818142843344

写数据优化

image-20220818142945360

把每个 Partition 映射到某个文件的片段

Sort Shuffle

写数据

image-20220818143110849

每个 task 只用一个文件存储真实数据

读数据

image-20220818145317253

Shuffle 过程的触发流程

image-20220818145333838

前 5 行只是记录计算过程,在 Collect 的时候才会进行计算

Shuffle Handle 的创建

image-20220818145540977

Shuttle Handed 与 Shuffle Writer 的对应关系

image-20220818145755080

Writer 实现

BypassMergeShuffleWriter

image-20220818145844735

仅适用于Partition较少的情况

UnsafeShuffleWriter

image-20220818150319693

image-20220818150809663

SortShuffleWriter

image-20220818151128495

Reader 实现

网络时序图

image-20220818151420607

ShuffleBlockFetchIterator

image-20220818152506891

External Shuffle Service

image-20220818152853800

Shuffle 优化使用的技术

Zero Copy

image-20220818154218648

Natty Zero Copy

image-20220818154610873

常见问题

image-20220818154808160

Shuffle 优化

image-20220818155233602

image-20220818155322854

Shuffle 参数优化

image-20220818155338573

Shuffle 倾斜优化

image-20220818155615083

image-20220818155736815

案例 - 参数优化

image-20220818155837635

image-20220818155941258

Push Shuffle

上面讲的是 Spark 3.0 的算法

为什么要 Push Shuffle

image-20220818160049502

Push Shuffle 的实现

image-20220818160142293

Magnet 实现原理

image-20220818160232562

image-20220818160333799

Magnet 可靠性

image-20220818160513326

Cloud Shuffle Service 思想

image-20220818160722457

Cloud Shuffle Service 架构

image-20220818160738101

Cloud Shuffle Service 写入读取

image-20220818160843239

image-20220818161051038

image-20220818161108643

实践案例 - CSS 优化

image-20220818161200511

总结

image-20220818161226128