在YARN上使用Spark时,maxExecutors、num-executors和initialExecutors之间有什么关系?

问题描述 投票:0回答:1

首先,我读了这篇文章,其中说如果未明确设置

spark.dynamicAllocation.maxExecutors
,则
num-executors
的值将等于
spark.dynamicAllocation.maxExecutors
。然而,从本文的以下部分来看,它说“
--num-executors
spark.executor.instances
充当执行器的最小数量,默认值为2”,这让我很困惑。

  1. 我的第一个问题是

    --num-executors
    在Spark 2.x或更高版本中的用法是什么?它是否像一个在动态分配之前有用的过时选项?当引入dynamicAllocation时,
    --num-executors
    --max-executors
    的行为更像是
    spark.dynamicAllocation.*
    的一些默认值?

  2. --conf spark.dynamicAllocation.maxExecutors
    --max-executor
    有什么区别?后者的作用就像前者的别名吗?

同时,文章并没有提及

num-executors
spark.dynamicAllocation.initialExecutors
之间的关系。所以我做了一个实验,我发送以下参数:

--conf spark.dynamicAllocation.minExecutors=2  --conf spark.dynamicAllocation.maxExecutors=20  --conf spark.dynamicAllocation.enabled=true --conf spark.dynamicAllocation.initialExecutors=3 --conf spark.dynamicAllocation.maxExecutors=10  --num-executors 0  --driver-memory 1g  --executor-memory 1g  --executor-cores 2  

结果发现,一开始分配了3个executor(对应

initialExecutors
),然后减少到2个(对应
minExecutors
),看起来
--num-executors
在这里没什么用。但是,文章中说“-num-executors 或spark.executor.instances 充当执行器的最小数量”,所以现在存在矛盾。

  1. 我的第三个问题是
    num-executors
    spark.dynamicAllocation.initialExecutors
    之间的关系是什么,
    spark.dynamicAllocation.initialExecutors
    先于
    num-executors
    吗?从文档中,我发现当
    num-executors
    设置得大于
    spark.dynamicAllocation.initialExecutors
    时,它将覆盖
    spark.dynamicAllocation.initialExecutors
apache-spark hadoop-yarn
1个回答
1
投票

您的第一篇文章来自 Qubole 的开发人员指南,它不一定反映 Apache Spark 的默认行为。

回答您的问题:

  1. num-executors
    不一定会过时,如果您使用单独的进程或命令设置了动态分配,则当动态分配因任何原因关闭时,
    num-executors
    可以充当正确分配的保障。因此,我通常将
    num-executors
    设置为等于
    spark.dynamicAllocation.maxExecutors
  2. 我不知道
    max-executors
    ,但我会假设它是一个别名,其中较小者和
    spark.dynamicAllocation.maxExecutors
    是设置的最大值(如果两者都指定了),按照 Spark 的典型逻辑。最好只使用
    spark.dynamicAllocation.maxExecutors
  3. 使用动态分配时,
    num-executors
    的行为与
    spark.dynamicAllocation.initialExecutors
    而不是
    spark.dynamicAllocation.minExecutors
    。初始执行器设置为
    spark.dynamicAllocation.initialExecutors
    spark.dynamicAllocation.minExecutors
    spark.executor.instances
    中的最大值(来自 源代码)。
© www.soinside.com 2019 - 2024. All rights reserved.