Databricks 中的集群资源使用情况

Cluster Resource Usage in Databricks

我只是想知道是否有人可以解释 Databricks 集群中的所有计算资源是否共享,或者这些资源是否与每个工作人员相关联。例如,如果两个用户连接到一个由 2 个工作人员组成的集群,每个工作人员有 4 个核心,并且一个用户的工作需要 2 个核心,而另一个用户需要 6 个核心,他们是否能够共享总共 8 个核心或全部 4 个核心?在只需要 2 个核心的工作期间,一名工作人员的核心不可用?

TL;DR; 是的,默认行为是允许共享,但您将不得不严格控制这么小的集群的默认并行度。

查看 Job Scheduling for Apache Spark. I'm assuming you are using an "all-purpose" / "interactive" cluster where users are working on notebooks OR you are submitting jobs to an existing, all-purpose cluster and it is NOT a job cluster 部署了多个 spark 应用程序。

Databricks 默认以 FAIR 调度模式运行

Under fair sharing, Spark assigns tasks between jobs in a “round robin” fashion, so that all jobs get a roughly equal share of cluster resources. This means that short jobs submitted while a long job is running can start receiving resources right away and still get good response times, without waiting for the long job to finish. This mode is best for multi-user settings.

Apache Spark 默认为 FIFO

By default, Spark’s scheduler runs jobs in FIFO fashion. Each job is divided into “stages” (e.g. map and reduce phases), and the first job gets priority on all available resources while its stages have tasks to launch, then the second job gets priority, etc. If the jobs at the head of the queue don’t need to use the whole cluster, later jobs can start to run right away, but if the jobs at the head of the queue are large, then later jobs may be delayed significantly.

请记住,“作业”一词是特定的 Spark 术语,表示正在执行的启动一个或多个阶段和任务的操作。参见 What is the concept of application, job, stage and task in spark?

所以在你的例子中你有...

  • 2 个 Worker,每个 4 个内核 == 8 个内核 == 可以并行处理 8 个任务
  • 一个应用程序 (App A) 有一个启动只有 2 个任务的阶段的作业。
  • 一个应用程序 (App B) 有一个作业启动一个包含 6 个任务的阶段。

在这种情况下,是,您将能够共享集群的资源。然而,问题在于默认行为。如果您正在读取许多文件、执行连接、聚合等,您将 运行 了解 Spark 将把您的数据分成可以并行操作的块这一事实(参见 运行 =16=]).

因此,在一个更现实的示例中,您将拥有...

  • 2 个 Worker,每个 4 个内核 == 8 个内核 == 可以并行处理 8 个任务
  • 一个应用程序 (App A) 有一个作业启动了一个包含 200 个任务的阶段
  • 一个应用程序(应用程序 B)有一个作业启动三个阶段,分别有 8 个、200 个和 1 个任务

在像这种 FIFO 调度这样的场景中,默认情况下,将导致这些应用程序中的一个阻塞另一个,因为执行者的数量完全被一个阶段中的任务数量所淹没。

在 FAIR 调度模式下,由于执行者数量较少,仍然会有一些阻塞,但由于 FAIR 调度在任务上进行循环,因此每个作业都会完成一些工作级.

在 Apache Spark 中,您可以通过创建不同的资源池并仅将应用程序提交到它们具有“隔离”资源的那些池来进行更严格的控制。执行此操作的“更好”方法是使用 Databricks 作业集群,这些集群具有专用于 运行.

应用程序的隔离计算