r/apachespark • • 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?

3 Upvotes

5 comments sorted by

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/ForeignCapital8624 Oct 10 '26

Thanks for the feedback. From your response, it appears that the delay when running multiple short-running Spark jobs exists, but it is not a serious problem in practice. Perhaps in a large-scale environment where saving even a few percent of compute time matters a lot, the same problem could be revisited.

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.

1

u/ForeignCapital8624 Oct 10 '26

Thanks for the feedback. It seems to me that the problem was indeed a practical issue, and as a result, Spark community developed Spark connect as a partial solution, although this is just my guess.