如何更改本地模式下的执行者数量?

How to change number of executors in local mode?

是否可以使用某些 Spark Conf 设置在本地模式下为 Spark Streaming 应用程序设置多个执行程序? 例如,当我将 spark.executor.instances 参数更改为 4 时,目前我看不到 Spark UI 在性能或执行程序数量增加方面有任何变化。

本地模式是一种开发工具,所有组件都在一台机器上模拟。由于单个 JVM 意味着单个执行程序更改执行程序的数量根本不可能,并且 spark.executor.instances 不适用。

local 模式下你所能做的就是通过修改 master URL - local[n] 来增加线程数,其中 n 是线程数。

本地模式 根据定义 "pseudo-cluster" 在单一 JVM 中运行。这意味着执行者的最大数量是 1.

如果你想在本地机器上试验多个执行器,你可以做的是在你的本地机器上创建有几个工人的集群运行。 运行 个实例数是您的任务的最大执行程序数。

spark.executor.instances 在本地模式下不受支持。

参考 - https://books.japila.pl/apache-spark-internals/local/?h=local

Local-Mode: In this non-distributed single-JVM deployment mode, Spark spawns all the execution components - driver, executor, LocalSchedulerBackend, and master - in the same single JVM. The default parallelism is the number of threads as specified in the master URL. This is the only mode where a driver is used for execution.

因此您可以通过将 master url 作为 local[n].

传递来将 JVM 中的线程数增加到 n