gpt4 book ai didi

hadoop - Spark 合并与执行者和核心数量的关系

转载 作者:可可西里 更新时间:2023-11-01 14:44:25 26 4
gpt4 key购买 nike

我提出了一个关于 Spark 的非常愚蠢的问题,因为我想消除我的困惑。我是 Spark 的新手,仍在尝试了解它的内部工作原理。

比如说,如果我有一个输入文件列表(假设 1000 个),我想在某处处理或写入,并且我想使用合并将我的分区数减少到 100。

现在我用 12 个执行器运行这个作业,每个执行器有 5 个核心,这意味着它运行时有 60 个任务。这是否意味着每项任务都将独立地在一个分区上工作?

Round: 1 12 executors each with 5 cores => 60 tasks process 60 partitions
Round: 2 8 executors each with 5 cores => 40 tasks

process the rest of the 40 partitions and 4 executors never place a job for the 2nd time

或者来自同一个执行器的所有任务将在同一个分区上工作?

Round: 1: 12 executors => process 12 partitions
Round: 2: 12 executors => process 12 partitions
Round: 3: 12 executors => process 12 partitions
....
....
....
Round: 9 (96 partitions already processed): 4 executors => process the remaining 4 partitions

最佳答案

Say, if I have a list of input files(assume 1000) which I want to process or write somewhere and I want to use coalesce to reduce my partition number to 100.

在spark中默认number of partitions = hdfs blocks,因为指定了coalesce(100),Spark会将输入数据分成100分区。

Now I run this job with 12 executors with 5 cores per executor, that means 60 tasks when it runs. Does that mean, each of the tasks will work on one single partition independently?

Worker node with executors

当你通过时,可能也会通过。

--num-executors 12:要在应用程序中启动的执行程序数。

--executor-cores 5 :每个执行器的内核数。 一次 1 个核心 = 1 个任务

所以分区的执行是这样的。

第一轮

12 个分区 将由 12 个执行器处理,每个执行器有 5 个任务(线程)

第二轮

12 个分区 将由 12 个执行器处理,每个执行器有 5 个任务(线程)
.
.
.

第 9 轮(已处理 96 个分区):

4 个分区 将由 4 个执行器处理,每个执行器有 5 个任务(线程)

注意:通常,一些执行者可能会快速完成分配的工作(各种参数,如 data locality 、网络 I/O、CPU 等)。因此,它将通过等待配置的调度时间来选择下一个要处理的分区。

关于hadoop - Spark 合并与执行者和核心数量的关系,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38465692/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com