Spark执行程序,任务和分区

随着我不断阅读有关Spark架构和调度的在线资源,我开始变得更加困惑。一种资源说:The number of tasks in a stage is the same as the number of partitions in the last RDD in the stage。另一方面:Spark maps the number tasks on a particular Executor to the number of cores allocated to it。因此,第一个资源说如果我有1000个分区,那么无论我的机器是什么,我都会有1000个任务。在第二种情况下,如果我有4台核心计算机和1000个分区,那又如何?我将有4个任务?那么如何处理数据?

另一个困惑:each worker can process one task at a timeExecutors can run multiple tasks over its lifetime,both in parallel and sequentially。那么任务是顺序的还是并行的?

haoqiwei123 回答:Spark执行程序,任务和分区

  • 任务数由RDD / DataFrame的分区数给定
  • 执行器可以并行处理的任务数由其内核数决定,除非将spark.task.cpus配置为非1(这是默认值)

因此,将任务视为必须处理的某些(独​​立)工作块。他们肯定可以并行运行

因此,如果您有1000个分区和5个执行器,每个执行器有4个核心,则通常将并行运行20个任务

本文链接:https://www.f2er.com/3131686.html

大家都在问