【问题标题】:Spark streaming with Yarn: executors not fully utilized使用 Yarn 进行 Spark 流式传输:未充分利用执行器
【发布时间】:2016-12-27 12:50:12
【问题描述】:

我正在使用 Yarn 运行火花流 -

spark-submit --master yarn --deploy-mode cluster --num-executors 2 --executor-memory 8g --driver-memory 2g --executor-cores 8 ..

我正在通过DireactStream 方法(无接收器)使用 Kafka。我有 2 个主题(每个主题有 3 个分区)。

我将 RDD(我有一个 DStream)分成 16 个部分(假设没有执行器 * 核心数 = 2 * 8 = 16 是否正确?)然后我执行 foreachPartition 并将每个分区写入本地文件然后发送它通过 http 到其他服务器(不是 spark)(使用 apache http 同步客户端和池管理器通过多部分发布)。

当我通过 Spark UI 检查此步骤的详细信息(或 JOB 是否正确命名?)时,它显示在单个执行器上执行了总共 16 个任务,一次执行了 8 个任务。

这是 Spark UI 详细信息 -

第 717 阶段(尝试 0)的详细信息

Index  ID  Attempt Status  Locality Level  Executor ID / Host  Launch Time Duration  GC Time Shuffle Read Size / Records Errors
0  5080  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:46 2 s 11 ms 313.3 KB / 6137 
1  5081  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:46 2 s 11 ms 328.5 KB / 6452 
2  5082  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:46 2 s 11 ms 324.3 KB / 6364 
3  5083  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:46 2 s 11 ms 321.5 KB / 6306 
4  5084  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:46 2 s 11 ms 324.8 KB / 6364 
5  5085  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:46 2 s 11 ms 320.8 KB / 6307 
6  5086  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:46 2 s 11 ms 323.4 KB / 6356 
7  5087  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:46 3 s 11 ms 316.8 KB / 6207 
8  5088  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:48 2 s   317.7 KB / 6245 
9  5089  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:48 2 s   320.4 KB / 6280 
10  5090  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:48 2 s   323.0 KB / 6334 
11  5091  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:48 2 s   323.7 KB / 6371 
12  5092  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:48 2 s   316.7 KB / 6218 
13  5093  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:48 2 s   321.0 KB / 6301 
14  5094  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:48 2 s   321.4 KB / 6304 
15  5095  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/27 12:11:49 2 s   319.1 KB / 6267 

我期待它在一个或多个执行器上执行 16 个并行任务(2 个执行器 * 8 个核心)。我想我错过了一些东西。请帮忙。

更新:

  1. 传入的数据分布不均。例如第一个主题有第二个分区,有 5*5 = 25k 条消息(5k = maxRatePerPartition,5s = 批处理间隔),其他两个分区几乎有 0 个数据。第二个主题每批有大约 500-4000 条消息,平均分布在 3 个分区中。

  2. 当主题 1 中没有数据时,我会看到跨 2 个执行器的 16 个并行任务处理。


Index ID  Attempt Status  Locality Level  Executor ID / Host  Launch Time Duration  GC Time Shuffle Read Size / Records Errors
0 330402  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/28 04:31:41 1 s   19.2 KB / 193 
1 330403  0 SUCCESS NODE_LOCAL  2 / executor2_machine_host_name  2016/12/28 04:31:41 1 s   21.2 KB / 227 
2 330404  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/28 04:31:41 1 s   20.8 KB / 214 
3 330405  0 SUCCESS NODE_LOCAL  2 / executor2_machine_host_name  2016/12/28 04:31:41 1 s   20.9 KB / 222 
4 330406  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/28 04:31:41 2 s   21.0 KB / 222 
5 330407  0 SUCCESS NODE_LOCAL  2 / executor2_machine_host_name  2016/12/28 04:31:41 1 s   20.5 KB / 213 
6 330408  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/28 04:31:41 1 s   20.4 KB / 207 
7 330409  0 SUCCESS NODE_LOCAL  2 / executor2_machine_host_name  2016/12/28 04:31:41 1 s   19.2 KB / 188 
8 330410  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/28 04:31:41 1 s   20.4 KB / 214 
9 330411  0 SUCCESS NODE_LOCAL  2 / executor2_machine_host_name  2016/12/28 04:31:41 1 s   20.1 KB / 206 
10  330412  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/28 04:31:41 0.6 s   18.7 KB / 183 
11  330413  0 SUCCESS NODE_LOCAL  2 / executor2_machine_host_name  2016/12/28 04:31:41 1 s   20.6 KB / 217 
12  330414  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/28 04:31:41 1 s   20.0 KB / 206 
13  330415  0 SUCCESS NODE_LOCAL  2 / executor2_machine_host_name  2016/12/28 04:31:41 1 s   20.7 KB / 216 
14  330416  0 SUCCESS NODE_LOCAL  1 / executor1_machine_host_name  2016/12/28 04:31:41 1 s   18.8 KB / 186 
15  330417  0 SUCCESS NODE_LOCAL  2 / executor2_machine_host_name  2016/12/28 04:31:41 1 s   20.4 KB / 213 

【问题讨论】:

  • 请检查answer once。
  • 尝试给--num-executors 6(因为你有2个主题,每个主题有3个分区)。 1 个分区 = 1 个执行器 是理想的选择。 (--executor-cores 将取决于您的核心可用性和每个分区中所需的并行化)
  • 我尝试了 6 个执行器和 4 个核心,但这个阶段的所有任务仍然在同一个执行器上执行(现在一次 4 个)
  • 不应该在所有可用的执行器上并行执行吗?
  • 可能是因为data locality。尝试设置spark.locality.wait=1s。

标签: apache-spark spark-streaming hadoop-yarn apache-httpclient-4.x executor


【解决方案1】:

尝试增加分区数等于执行器核心数,因为您要提供 8 个执行器核心,所以将 Kafka 主题的分区数增加到 8 个。 另外,检查如果你不重新分区会发生什么。

【讨论】:

  • 我怀疑这会解决我的问题,因为阅读不是瓶颈,我猜它是调度
【解决方案2】:

使用 --num-executors 6 设置以下参数

spark.default.parallelism

spark.streaming.concurrentJobs

根据您的要求和环境设置上述参数值。这对你有用。

【讨论】:

    猜你喜欢
    • 2017-05-26
    • 1970-01-01
    • 2017-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-19
    相关资源
    最近更新 更多