Spark动态分配配置设置优先级

Spark dynamic allocation configuration settings precedence

我有一个 spark 作业 运行 在启用了动态资源分配的集群上。我提交了带有 num executors 和 executor 内存属性的 spark 作业。这里什么优先?作业 运行 是动态分配还是我在配置中提到的资源?

这取决于哪个配置参数具有更大的值...

spark.dynamicAllocation.initialExecutorsspark.executor.instances 又名 --num-executors(在运行时通过终端启动时)

如果您在 YARN 上使用 Cloudera 并确保您正在根据您的环境查看正确的 CDH 版本,这里是参考文档。

https://www.cloudera.com/documentation/enterprise/6/6.2/topics/cdh_ig_running_spark_on_yarn.html#spark_on_yarn_dynamic_allocation__table_tkb_nyv_yr

还有 Apache YARN 文档:

https://spark.apache.org/docs/latest/configuration.html#dynamic-allocation

所以总结一下,如果您使用 --num-executors,它很可能会覆盖(取消和不使用)动态分配,除非您将 spark.dynamicAllocation.initialExecutors 设置为更高的值。

configuration documentation (2.4.4) 说 spark.dynamicAllocation.initialExecutors :

Initial number of executors to run if dynamic allocation is enabled. If --num-executors (or spark.executor.instances) is set and larger than this value, it will be used as the initial number of executors.

所以对我来说,如果启用了动态分配(即 spark.dynamicAllocation.enabledtrue),那么它将被使用,并且执行者的初始数量将只是 max(spark.dynamicAllocation.initialExecutors, spark.executor.instances)