Web UI

Apache Spark 提供了一套 Web 用户界面 (UI),可用于监控 Spark 集群的状态和资源消耗。

目录

Jobs 选项卡

Jobs 选项卡显示 Spark 应用程序中所有作业的摘要页面以及每个作业的详细信息页面。 摘要页面显示高级信息,例如所有作业的状态、持续时间和进度以及整体事件时间线。 单击摘要页面上的作业时,您会看到该作业的详细信息页面。 详细信息页面进一步显示事件时间线、DAG 可视化以及作业的所有阶段。

此部分中显示的信息是

Basic info

Event timeline

Details of jobs grouped by status

单击特定作业时,您可以看到该作业的详细信息。

Jobs 详情

此页面显示由其作业 ID 标识的特定作业的详细信息。

Event timeline

DAG

DAG

Stages 选项卡

Stages 选项卡显示一个摘要页面,其中显示 Spark 应用程序中所有作业的所有 stage 的当前状态。

页面开头是摘要,其中包含按状态(active、pending、completed、skipped 和 failed)统计的所有 stage 计数

Stages header

Fair scheduling mode 中,有一个表格显示 pools properties

Pool properties

之后是每个状态(active、pending、completed、skipped、failed)的 stage 详细信息。在 active 的 stage 中,可以使用 kill 链接终止 stage。 仅在 failed 的 stage 中,才会显示失败原因。 单击描述可以访问任务详细信息。

Stages detail

Stage 详情

stage 详细信息页面以跨所有任务的总时间等信息开始,Locality level summaryShuffle Read Size / Records 和 Associated Job IDs。

Stage header

还有该 stage 的 directed acyclic graph (DAG) 的可视化表示,其中顶点表示 RDD 或 DataFrame,边表示要应用的操作。 节点按 DAG 可视化中的操作范围分组,并用操作范围名称(BatchScan、WholeStageCodegen、Exchange 等)标记。 值得注意的是,Whole Stage Code Generation 操作也使用代码生成 id 进行注释。 对于属于 Spark DataFrame 或 SQL 执行的 stage,这允许将 Stage 执行详细信息与 Web-UI SQL 选项卡页面中报告的 SQL 计划图和执行计划中的相关详细信息进行交叉引用。

Stage DAG

所有任务的摘要指标都以表格和时间线显示。

Stages metrics

Aggregated metrics by executor 显示按 executor 聚合的相同信息。

Stages metrics per executors

Accumulators 是一种共享变量。它提供了一个可变变量,可以在各种转换中更新。 可以创建具有和不具有名称的累加器,但仅显示命名的累加器。

Stage accumulator

Tasks 详细信息基本上包括与摘要部分相同的信息,但按任务详细说明。 它还包括指向查看日志的链接以及任务尝试次数(如果因任何原因而失败)。 如果有命名的累加器,则可以在每个任务结束时看到累加器值。

Tasks

Storage 选项卡

Storage 选项卡显示应用程序中持久化的 RDD 和 DataFrame(如果有)。 摘要页面显示所有 RDD 的存储级别、大小和分区,详细信息页面显示 RDD 或 DataFrame 中所有分区的大小和使用的 executors。

scala> import org.apache.spark.storage.StorageLevel._
import org.apache.spark.storage.StorageLevel._

scala> val rdd = sc.range(0, 100, 1, 5).setName("rdd")
rdd: org.apache.spark.rdd.RDD[Long] = rdd MapPartitionsRDD[1] at range at <console>:27

scala> rdd.persist(MEMORY_ONLY_SER)
res0: rdd.type = rdd MapPartitionsRDD[1] at range at <console>:27

scala> rdd.count
res1: Long = 100

scala> val df = Seq((1, "andy"), (2, "bob"), (2, "andy")).toDF("count", "name")
df: org.apache.spark.sql.DataFrame = [count: int, name: string]

scala> df.persist(DISK_ONLY)
res2: df.type = [count: int, name: string]

scala> df.count
res3: Long = 3

Storage tab

运行上述示例后,我们可以在 Storage 选项卡中找到两个 RDD。 提供了存储级别、分区数和内存开销等基本信息。 请注意,新持久化的 RDD 或 DataFrame 在具体化之前不会显示在该选项卡中。 要监控特定的 RDD 或 DataFrame,请确保已触发操作。

Storage detail

您可以单击 RDD 名称“rdd”以获取数据持久性的详细信息,例如集群上的数据分布。

Environment 选项卡

Environment 选项卡显示不同环境和配置变量的值,包括 JVM、Spark 和系统属性。

Env tab

此环境页面包含五个部分。 它是检查您的属性是否已正确设置的有用场所。 第一部分“Runtime Information”仅包含 运行时属性,例如 Java 和 Scala 的版本。 第二部分“Spark Properties”列出了 应用程序属性,例如 ‘spark.app.name’ 和 ‘spark.driver.memory’。

Hadoop Properties

单击“Hadoop Properties”链接将显示与 Hadoop 和 YARN 相关的属性。 请注意,诸如 ‘spark.hadoop.*’ 之类的属性不在此部分中显示,而是在“Spark Properties”中显示。

System Properties

“System Properties”显示有关 JVM 的更多详细信息。

Classpath Entries

最后一部分“Classpath Entries”列出了从不同来源加载的类,这对于解决类冲突非常有用。

Executors 选项卡

Executors 选项卡显示有关为应用程序创建的 executors 的摘要信息,包括内存和磁盘使用情况以及任务和 shuffle 信息。 Storage Memory 列显示用于缓存数据的内存量和保留的内存量。

Executors Tab

Executors 选项卡不仅提供资源信息(每个 executor 使用的内存量、磁盘量和核心数),还提供性能信息(GC time 和 shuffle 信息)。

Stderr Log

点击执行器 0 的 ‘stderr’ 链接,将在其控制台中显示详细的标准错误日志

Thread Dump

点击执行器 0 的 ‘Thread Dump’ 链接,将显示执行器 0 上 JVM 的线程转储,这对于性能分析非常有用。

SQL 选项卡

如果应用程序执行 Spark SQL 查询,则 SQL 选项卡将显示有关查询的信息,例如持续时间、作业以及物理和逻辑计划。 在这里,我们包含一个基本示例来说明此选项卡

scala> val df = Seq((1, "andy"), (2, "bob"), (2, "andy")).toDF("count", "name")
df: org.apache.spark.sql.DataFrame = [count: int, name: string]

scala> df.count
res0: Long = 3

scala> df.createGlobalTempView("df")

scala> spark.sql("select name,sum(count) from global_temp.df group by name").show
+----+----------+
|name|sum(count)|
+----+----------+
|andy|         3|
| bob|         2|
+----+----------+

SQL tab

现在,以上三个 dataframe/SQL 运算符将显示在列表中。 如果我们点击最后一个查询的 ‘show at <console>: 24’ 链接,我们将看到查询执行的 DAG 和详细信息。

SQL DAG

查询详细信息页面显示有关查询执行时间、持续时间、关联作业列表以及查询执行 DAG 的信息。 第一个块 ‘WholeStageCodegen (1)’ 将多个运算符(‘LocalTableScan’ 和 ‘HashAggregate’)编译成单个 Java 函数,以提高性能,并且诸如行数和溢出大小之类的指标都列在该块中。 块名称中的注释 ‘(1)’ 是代码生成 ID。 第二个块 ‘Exchange’ 显示 shuffle 交换的指标,包括写入的 shuffle 记录数、总数据大小等。

logical plans and the physical plan

点击底部的 ‘Details’ 链接将显示逻辑计划和物理计划,它们说明了 Spark 如何解析、分析、优化和执行查询。 物理计划中受整体阶段代码生成优化影响的步骤,以星号开头,后跟代码生成 ID,例如 ‘*(1) LocalTableScan’

SQL 指标

SQL 运算符的指标显示在物理运算符的块中。 当我们想深入了解每个运算符的执行细节时,SQL 指标非常有用。 例如,“number of output rows” 可以回答 Filter 运算符之后输出了多少行,“shuffle bytes written total” 在 Exchange 运算符中显示了 shuffle 写入的字节数。

以下是 SQL 指标的列表

SQL 指标含义运算符
number of output rows (输出行数) the number of output rows of the operator (运算符的输出行数)Aggregate operators, Join operators, Sample, Range, Scan operators, Filter, etc. (聚合运算符、连接运算符、采样、范围、扫描运算符、过滤器等)
data size (数据大小) the size of broadcast/shuffled/collected data of the operator (运算符广播/shuffle/收集的数据大小)BroadcastExchange, ShuffleExchange, Subquery
time to collect (收集时间) the time spent on collecting data (收集数据所花费的时间)BroadcastExchange, Subquery
scan time (扫描时间) the time spent on scanning data (扫描数据所花费的时间)ColumnarBatchScan, FileSourceScan
metadata time (元数据时间) the time spent on getting metadata like number of partitions, number of files (获取元数据所花费的时间,例如分区数、文件数)FileSourceScan
shuffle bytes written (shuffle 写入的字节数) the number of bytes written (写入的字节数)CollectLimit, TakeOrderedAndProject, ShuffleExchange
shuffle records written (shuffle 写入的记录数) the number of records written (写入的记录数)CollectLimit, TakeOrderedAndProject, ShuffleExchange
shuffle write time (shuffle 写入时间) the time spent on shuffle writing (shuffle 写入所花费的时间)CollectLimit, TakeOrderedAndProject, ShuffleExchange
remote blocks read (远程读取的块数) the number of blocks read remotely (远程读取的块数)CollectLimit, TakeOrderedAndProject, ShuffleExchange
remote bytes read (远程读取的字节数) the number of bytes read remotely (远程读取的字节数)CollectLimit, TakeOrderedAndProject, ShuffleExchange
remote bytes read to disk (从远程读取到磁盘的字节数) the number of bytes read from remote to local disk (从远程读取到本地磁盘的字节数)CollectLimit, TakeOrderedAndProject, ShuffleExchange
local blocks read (本地读取的块数) the number of blocks read locally (本地读取的块数)CollectLimit, TakeOrderedAndProject, ShuffleExchange
local bytes read (本地读取的字节数) the number of bytes read locally (本地读取的字节数)CollectLimit, TakeOrderedAndProject, ShuffleExchange
fetch wait time (获取等待时间) the time spent on fetching data (local and remote) (获取数据所花费的时间(本地和远程))CollectLimit, TakeOrderedAndProject, ShuffleExchange
records read (读取的记录数) the number of read records (读取的记录数)CollectLimit, TakeOrderedAndProject, ShuffleExchange
sort time (排序时间) the time spent on sorting (排序所花费的时间)Sort
peak memory (峰值内存) the peak memory usage in the operator (运算符中的峰值内存使用量)Sort, HashAggregate
spill size (溢出大小) number of bytes spilled to disk from memory in the operator (运算符中从内存溢出到磁盘的字节数)Sort, HashAggregate
time in aggregation build (聚合构建中的时间) the time spent on aggregation (聚合所花费的时间)HashAggregate, ObjectHashAggregate
avg hash probe bucket list iters (平均哈希探测桶列表迭代次数) the average bucket list iterations per lookup during aggregation (聚合期间每次查找的平均桶列表迭代次数)HashAggregate
data size of build side (构建端的数据大小) the size of built hash map (构建的哈希映射的大小)ShuffledHashJoin
time to build hash map (构建哈希映射的时间) the time spent on building hash map (构建哈希映射所花费的时间)ShuffledHashJoin
task commit time (任务提交时间) the time spent on committing the output of a task after the writes succeed (写入成功后,提交任务输出所花费的时间)any write operation on a file-based table (对基于文件的表进行的任何写入操作)
job commit time (作业提交时间) the time spent on committing the output of a job after the writes succeed (写入成功后,提交作业输出所花费的时间)any write operation on a file-based table (对基于文件的表进行的任何写入操作)
data sent to Python workers (发送给 Python worker 的数据) the number of bytes of serialized data sent to the Python workers (发送给 Python worker 的序列化数据字节数)ArrowEvalPython, AggregateInPandas, BatchEvalPython, FlatMapGroupsInPandas, FlatMapsCoGroupsInPandas, FlatMapsCoGroupsInPandasWithState, MapInPandas, PythonMapInArrow, WindowsInPandas
data returned from Python workers (从 Python worker 返回的数据) the number of bytes of serialized data received back from the Python workers (从 Python worker 接收回的序列化数据字节数)ArrowEvalPython, AggregateInPandas, BatchEvalPython, FlatMapGroupsInPandas, FlatMapsCoGroupsInPandas, FlatMapsCoGroupsInPandasWithState, MapInPandas, PythonMapInArrow, WindowsInPandas

Structured Streaming 选项卡

当在微批处理模式下运行结构化流作业时,Web UI 上会显示一个结构化流选项卡。 概述页面显示有关正在运行和已完成的查询的一些简要统计信息。 此外,您可以检查失败查询的最新异常。 有关详细统计信息,请点击表格中的“run id”。

Structured Streaming Query Statistics

统计信息页面显示了一些有用的指标,可用于深入了解流式查询的状态。 目前,它包含以下指标。

作为早期版本,统计信息页面仍在开发中,并在未来的版本中会进行改进。

Streaming (DStreams) 选项卡

如果应用程序使用带有 DStream API 的 Spark Streaming,则 Web UI 会包含一个 Streaming 选项卡。 此选项卡显示数据流中每个微批处理的调度延迟和处理时间,这对于对流式应用程序进行故障排除非常有用。

JDBC/ODBC Server 选项卡

当 Spark 作为 分布式 SQL 引擎运行时,我们可以看到此选项卡。 它显示有关会话和提交的 SQL 操作的信息。

页面的第一部分显示有关 JDBC/ODBC 服务器的一般信息:启动时间和运行时间。

JDBC/ODBC Header

第二部分包含有关活动和已完成会话的信息。

JDBC/ODBC sessions

第三部分包含提交的操作的 SQL 统计信息。

JDBC/ODBC SQL Statistics