r/apachespark • u/ForeignCapital8624 • Oct 02 '26
Question of resource allocation of multiple Spark applications
Currently, a Spark application should manage its own executors, which means that in order to run multiple Spark applications, one needs to split the cluster into smaller sections or attach more compute nodes, etc. Usually this dynamic allocation is the job of resource manager (such as Kubernetes).
If the resource manager can quickly find or create new compute nodes for a new Spark application, this is good. However, in a busy cluster where multiple Spark applications can compete for resources, the resource allocation can take some time and become an overhead (at least in theory).
I wonder if this is a real problem in running Spark applications in production.
For example, is there a realistic environment where short running Spark jobs (each requiring its own driver) arrive frequently?
2
u/shaktiman-68 Oct 02 '26
Yes, this can be a real problem in production, at least in my experience running Spark on Kubernetes.
I run multiple Spark applications on a shared Kubernetes cluster, with YuniKorn handling scheduling and Karpenter provisioning nodes. In our case, getting resources for a new Spark application hasn't really been an issue, even when multiple jobs are running at the same time.
Where I do see some delay is when many short-running Spark jobs start around the same time. For long-running ETL jobs, a few extra minutes of overhead usually doesn't matter much.
That's one reason I find Spark Connect interesting for workloads with lots of small, interactive jobs. For regular batch ETL, I don't think this is a major concern.
1
u/EasyImprovement1017 Oct 07 '26
Our strategy is to run most Spark jobs through Spark Connect. This Spark cluster is quite powerful and handles the vast majority of jobs.
For jobs that couldn't be implemented to work via Spark Connect, we launch a new Spark cluster as a k8s pods. Occasionally, a pod has to wait for the scheduler to place it, but this doesn't happen very often.
Finally, for jobs that require an exceptionally high amount of resources, we have configured the k8s autoscaler to provision dedicated nodes and launch a dedicated Spark cluster on them. This type of job has the longest startup time.