Spark:如何指定持有 RDD 的 executor 数量?

Posted

技术标签:

【中文标题】Spark:如何指定持有 RDD 的 executor 数量?【英文标题】:Spark: How to specify the number of executors to hold an RDD? 【发布时间】:2014-08-31 07:00:59 【问题描述】:

我试图通过将 RDD 分配给尽可能多的执行者来最大化并行性。据我所知,用户可以使用重新分区、合并或并行化来更改分区数。但是我无法找到一种方法来更改执行者的数量来保存分区。任何人都可以暗示如何做到这一点吗?

【问题讨论】:

【参考方案1】:

当您启动 Spark 应用程序时。有一个参数--num-executors来指定你想要多少个executors,并行,--executor-cores是指定每个executors可以并行执行多少个任务。

在您的情况下,您可以指定大量执行器,每个执行器只有 1 个执行器核心。那么比如你有 10 个 partition 和 10 个 executor,那么每个 executor 将被分配一个任务来处理一个 partition。

【讨论】:

【参考方案2】:

在命令行中直接输入 spark-submit,你会得到手册。它包含以下内容

 Spark standalone with cluster deploy mode only:
  --driver-cores NUM          Cores for driver (Default: 1).

 Spark standalone or Mesos with cluster deploy mode only:
  --supervise                 If given, restarts the driver on failure.
  --kill SUBMISSION_ID        If given, kills the driver specified.
  --status SUBMISSION_ID      If given, requests the status of the driver specified.

 Spark standalone and Mesos only:
  --total-executor-cores NUM  Total cores for all executors.

 Spark standalone and YARN only:
  --executor-cores NUM        Number of cores per executor. (Default: 1 in YARN mode,
                              or all available cores on the worker in standalone mode)

 YARN-only:
  --driver-cores NUM          Number of cores used by the driver, only in cluster mode
                              (Default: 1).
  --queue QUEUE_NAME          The YARN queue to submit to (Default: "default").
  --num-executors NUM         Number of executors to launch (Default: 2).
                              If dynamic allocation is enabled, the initial number of
                              executors will be at least NUM.
  --archives ARCHIVES         Comma separated list of archives to be extracted into the
                              working directory of each executor.
  --principal PRINCIPAL       Principal to be used to login to KDC, while running on
                              secure HDFS.
  --keytab KEYTAB             The full path to the file that contains the keytab for the
                              principal specified above. This keytab will be copied to
                              the node running the Application Master via the Secure
                              Distributed Cache, for renewing the login tickets and the
                              delegation tokens periodically.

这取决于您的部署模式。您必须提交脚本以使用上述特定参数触发,以相应地定义执行者的数量。

【讨论】:

以上是关于Spark:如何指定持有 RDD 的 executor 数量?的主要内容,如果未能解决你的问题,请参考以下文章

如何从 Spark 中的 Slaves 内存中创建 RDD?

Hive:Spark中如何实现将rdd结果插入到hive1.3.1表中

什么是 Spark RDD ?

Spark——RDD属性

对同一个 apache Spark RDD 的操作会导致所有语句重新执行

入门大数据---Spark_RDD