num-executors 可以覆盖 spark-submit 中的动态分配吗

Arv*_*mar 5 apache-spark spark-submit

可以在 spark-submit 命令中指定 num-executors 覆盖已启用的动态分配 (spark.dynamicAllocation.enable true) 吗?

ali*_*uya 5

从日志中可以看到:

INFO util.Utils: Using initial executors = 60, 
max of spark.dynamicAllocation.initialExecutors, spark.dynamicAllocation.minExecutors and spark.executor.instances
Run Code Online (Sandbox Code Playgroud)

这意味着spark将采用max(spark.dynamicAllocation.initialExecutors,spark.dynamicAllocation.minExecutors,spark.executor.instances)

Spark.executor.instances 是 --num-executor。


Arv*_*mar 0

要显式控制执行器的数量,可以通过设置“ --num-executors”命令行或spark.executor.instances配置属性来覆盖动态分配。

" --num-executor" 的属性spark-submit与 不兼容spark.dynamicAllocation.enabled。如果同时指定了spark.dynamicAllocation.enabledspark.executor.instances,则关闭动态分配并spark.executor.instances使用有限数量”。

此外,它还会发出警告 WARN SparkContext: Dynamic Allocation and num executors are Both set,因此动态分配被禁用。

  • 上述答案适用于 Spark 1.6。我认为在 Spark 2.2 中,情况有所不同,这里您不能使用 --num-executors 覆盖动态分配。根据spark最新文档https://spark.apache.org/docs/latest/configuration.html#dynamic-allocation“如果设置了`--num-executors`(或`spark.executor.instances`)并且更大小于该值,将作为初始执行器数量。” (3认同)