【问题标题】:What is the relationship between a Node, Worker, Executor, Task and PartitionNode、Worker、Executor、Task和Partition是什么关系
【发布时间】:2021-07-28 12:35:07
【问题描述】:

我试图了解 Spark 架构中不同组件和元素之间的关系,但无法掌握它。有人可以验证我的假设并纠正我的错误。

  1. 我的理解 - 节点是实际的物理机器。一个节点可以包含主驱动程序,而其他节点可以包含工作程序。
    Q - 一个节点可以有多个驱动程序(如果我有多个应用程序)?

  2. 我的理解 - 工作人员是节点内的一个进程。虽然不推荐,但每个节点内可以有多个工作人员。

  3. 我的理解 - 执行者是工作进程中的子进程(?)。每个工人可以有多个执行者。
    Q.什么指标决定了每个工作人员的执行者数量?
    问:JVM 的想法是与执行程序进程相关联还是在更高的“工作者”级别?
    Q. core和executor是什么关系?
    Q - RAM 和 HD 可以在执行者级别分配吗?
    例如,如果我有一个具有 100GB RAM 和 5 TB HD 的工作节点,我可以为每个执行程序分配 20 GB RAM 和 1 TB HDD 吗?

  4. 我的理解 - 分区是实际数据的一部分。这种拆分可以使用散列法、循环法或范围进行。
    问 - 是什么决定了这些数据分区的位置?
    例如,如果我有一个包含 2 个节点、10 个执行程序(每个节点有 5 个执行程序)和一个包含 20 个分区的数据帧的集群,我假设每个执行程序中有 2 个分区,或者是否有可能分区分布歪斜?我需要做些什么来确保我的所有具有某个分区键的分区都位于同一个工作进程中,这样当这些分区必须一起工作以执行聚合或连接时,网络传输最少?
    Q - 执行 repartition() 时会发生什么。例如,如果我在 10 个执行程序中有 20 个分区(例如,每个分区有 2 个分区)并且我重新分区(2)。我现在将只有 2 部分数据,我认为它们将存放在几个 executor 中。剩下的执行者怎么办?

  5. 假设 - 任务是执行实际询问的最低工作单元。任务的数量取决于分区的数量。所以,如果有 20 个分区,我将在每个阶段有 20 个任务。
    问 - 这些任务是由单个执行者执行的吗?
    问 - 如果我的执行程序(例如 10 个)少于分区(例如 20 个),这是否意味着在任何时候都只会并行执行 10 个任务?并行度是否受执行者数量的限制?

提前致谢!

【问题讨论】:

    标签: apache-spark


    【解决方案1】:
    1. 我的理解——节点是实际的物理机器。一个节点可以包含主驱动程序,而其他节点将包含工作程序。 (This is Correct as a starting Point)

    Q - 一个节点可以有多个驱动程序(如果我有多个应用程序)?

    Yes Because driver is just a process that gets created based on the program that you might have written. And you can have multiple process running on the same node.

    1. 我的理解 - 工作人员是节点内的一个进程。尽管不推荐,但每个节点内可以有多个工作器。

    your understanding here seems wrong because worker is actually a node or machine. Either you say it worker or worker node both are same

    1. 我的理解 - 执行者是工作进程中的子进程(?)。每个工人可以有多个执行者。 An executor is a process inside the worker node and a single worker node can have multiple executors

    问。什么指标决定了每个工作人员的执行者数量?

    configuration(Number of cores and memory) of your worker node decides what is the max executors it can run on any specific worker node.

    问。 JVM 的想法是与执行程序进程相关联还是在更高的“工作者”级别?

    It is associated with the executor process. Spark executor is a single JVM instance on a node that serves a single spark application

    问。 core和executor是什么关系?

    Core property controls the number of concurrent tasks an executor can run. For example if you request 2 executor each with 2 cores then you can run 4 concurrent tasks at the same time during your job execution.

    问 - RAM 和 HD 可以在执行程序级别分配吗? 例如,如果我有一个具有 100GB RAM 和 5 TB HD 的工作节点,我可以为每个执行程序分配 20 GB RAM 和 1 TB HDD 吗?

    Generally spark perform all its computation in memory. RAM is allocated at the executor level and HD would be allocated at the Worker node level only. Spark would just spill the data to the disk only when it does not fit in memory

    我的理解 - 分区是实际数据的一部分。这种拆分可以使用散列、循环或范围进行。 Q - 是什么决定了这些数据分区的位置?

    These partitions could be anywhere and might not be equally distributed in most of the cases.It could happen some of the executors does not have a single partition and other executors have more than 2 partitions.

    In order to have colocated partitions or partitions that have same keys you would have to repartition data based on the specific column in your dataframe and then it would partition your data based on the values of that column and make sure that same column values are there in the same partition

    When you repartition the data to 2 partitions then it would shuffle the data between all the executors and then break the dat into 2 partitions and then that data could be on any of the executors and other executors would be empty or idle in that case.

    1. 假设 - 任务是执行实际询问的最低工作单元。任务的数量取决于分区的数量。因此,如果有 20 个分区,我将在每个阶段有 20 个任务。

    you would have 20 tasks for that specific stage and it wont remain same for all the stages as stage gets created when there is data shuffle that needs to happen. If there is no shuffle happening based on the code that you might have written it would just create a single stage with 20 tasks for sure.

    问 - 这些任务是由个人执行者执行的吗? Yes

    Q - 如果我的执行程序(例如 10 个)少于分区(例如 20 个),这是否意味着在任何时候只有 10 个任务会并行执行?并行度是否受执行者数量的限制? Yes

    【讨论】:

    • 谢谢你,尼昆吉。关于您对第二点的回应,我的理解源于 Spark 文档。特别是 SPARK_WORKER_INSTANCES 的定义 - 每台机器上运行的工作实例数(默认值:1)。如果你有非常大的机器并且想要多个 Spark 工作进程,你可以使这个大于 1。如果您确实设置了这个,请确保还明确设置 SPARK_WORKER_CORES 以限制每个工作人员的核心,否则每个工作人员将尝试使用所有核心。
    • 对于最后一个问题 (5) - 如果每个 executor 每个都有 2 个 core 会怎样?这会将并行度增加到 20 吗?如果是,那么这是否意味着程度受执行者数量*每个执行者核心数量的限制?
    • 非常感谢您耐心地回答我的问题。可悲的是,我还没有足够的声望点来支持你的答案。但请注意,这非常有帮助!
    • @jerry 关于您的第 2 点混淆工作者实例是该机器上的执行者。您可以在同一台机器上处理多个执行程序,这就是您需要提供每个执行程序或工作程序实例应该使用的核心数量的原因。您对第五点的第二条评论是正确的。
    • 如果有帮助,您可以接受答案。您不能对答案投赞成票,但您可以接受答案,因为您是提出此问题的人。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-27
    • 2013-04-14
    • 1970-01-01
    • 1970-01-01
    • 2014-03-14
    • 2013-06-14
    相关资源
    最近更新 更多