一个 cpu 核心 运行 多个应用程序可以同时在 spark 集群上运行吗?
Can a cpu core run multiple applications concurrently on spark cluster?
我有两个关于 Apache spark 的问题。
我搭建了一个spark独立集群,每个worker有4个core,那是不是意味着我一个worker上最多只能同时有4个应用运行?
我有一个流程,我希望它定期 运行,最佳做法是什么?在 cron 作业中调用 spark-submit
还是只是在驱动程序中循环我的代码?
This page似乎提供了一个答案,但不符合我的直觉或期望:
The standalone cluster mode currently only supports a simple FIFO scheduler across applications. However, to allow multiple concurrent users, you can control the maximum number of resources each application will use. By default, it will acquire all cores in the cluster, which only makes sense if you just run one application at a time. You can cap the number of cores by setting spark.cores.max in your SparkConf
我从中收集到的是,一个进程确实会完全锁定分配给它的 CPU 核心,直到完成 运行ning。
在您的情况下,您确实可以为每个进程分配 1 个核心,但其他进程显然会被放入队列中,直到核心释放出来。
关于你的第二个问题:我会避免让单个应用程序 运行 永远循环,因为这会阻止它放弃对其正在使用的 CPU 核心的控制。以 cron 作业的方式启动它可以防止这种类型的 CPU 占用。
来自 Learning Spark, Chapter 7 p. 132:
"When sharing a Spark cluster among multiple applications, you will
need to decide how to allocate resources between the executors. The
Standalone cluster manager has a basic scheduling policy that allows
capping the usage of each application so that multiple ones may run
concurrently. Apache Mesos supports more dynamic sharing while an
application is running, while YARN has a concept of queues that allows
you to cap usage for various sets of applications."
因此,这应该对您有所帮助 2。作者在第 138-139 页上还提供了多种要点来帮助您决定使用哪个集群管理器。总的来说,本书的第 7 章非常宝贵,我强烈推荐购买(Databricks 有促销代码)。
关于问题 1,您通过设置配置资源分配:(1) 执行程序内存和 (2) 最大总内核数。听起来您已经设置了最大内核数,因此请考虑执行程序内存。每个应用程序都有一个执行程序(并且只有您允许的内存量)。每个核心可以有多个执行程序。
您可以通过转至 http://masternode:8080 来验证独立模式的这些设置。
我有两个关于 Apache spark 的问题。
我搭建了一个spark独立集群,每个worker有4个core,那是不是意味着我一个worker上最多只能同时有4个应用运行?
我有一个流程,我希望它定期 运行,最佳做法是什么?在 cron 作业中调用
spark-submit
还是只是在驱动程序中循环我的代码?
This page似乎提供了一个答案,但不符合我的直觉或期望:
The standalone cluster mode currently only supports a simple FIFO scheduler across applications. However, to allow multiple concurrent users, you can control the maximum number of resources each application will use. By default, it will acquire all cores in the cluster, which only makes sense if you just run one application at a time. You can cap the number of cores by setting spark.cores.max in your SparkConf
我从中收集到的是,一个进程确实会完全锁定分配给它的 CPU 核心,直到完成 运行ning。 在您的情况下,您确实可以为每个进程分配 1 个核心,但其他进程显然会被放入队列中,直到核心释放出来。
关于你的第二个问题:我会避免让单个应用程序 运行 永远循环,因为这会阻止它放弃对其正在使用的 CPU 核心的控制。以 cron 作业的方式启动它可以防止这种类型的 CPU 占用。
来自 Learning Spark, Chapter 7 p. 132:
"When sharing a Spark cluster among multiple applications, you will need to decide how to allocate resources between the executors. The Standalone cluster manager has a basic scheduling policy that allows capping the usage of each application so that multiple ones may run concurrently. Apache Mesos supports more dynamic sharing while an application is running, while YARN has a concept of queues that allows you to cap usage for various sets of applications."
因此,这应该对您有所帮助 2。作者在第 138-139 页上还提供了多种要点来帮助您决定使用哪个集群管理器。总的来说,本书的第 7 章非常宝贵,我强烈推荐购买(Databricks 有促销代码)。
关于问题 1,您通过设置配置资源分配:(1) 执行程序内存和 (2) 最大总内核数。听起来您已经设置了最大内核数,因此请考虑执行程序内存。每个应用程序都有一个执行程序(并且只有您允许的内存量)。每个核心可以有多个执行程序。
您可以通过转至 http://masternode:8080 来验证独立模式的这些设置。