Spark Scheduling in Kubernetes

Palantir
10 min readintermediate
--
View Original

Overview

The article discusses the implementation of Spark scheduling in Kubernetes, focusing on the development of the k8s-spark-scheduler extender to improve batch job scheduling. It highlights the challenges faced during Spark's execution on Kubernetes, including executor scheduling and autoscaling, and presents solutions such as FIFO gang scheduling.

What You'll Learn

1

How to implement FIFO gang scheduling for Spark applications in Kubernetes

2

Why executor scheduling issues occur in Kubernetes and how to mitigate them

3

How to use resource demand objects for effective cluster autoscaling

Prerequisites & Requirements

  • Understanding of Kubernetes and Spark architecture
  • Familiarity with Kubernetes scheduler and extender API(optional)

Key Questions Answered

What problems does the k8s-spark-scheduler aim to solve?
The k8s-spark-scheduler addresses issues of unreliable executor scheduling and slow autoscaling in Spark applications running on Kubernetes. It aims to ensure that Spark applications can efficiently acquire the necessary resources without being starved of executors, especially under conditions of cluster oversubscription.
How does FIFO gang scheduling improve Spark application performance?
FIFO gang scheduling improves performance by ensuring that all pods for a Spark application are scheduled together, preventing partial application launches that can lead to resource starvation. This approach helps maintain predictable performance for larger applications by managing the order of pod scheduling based on submission time.
What is the role of resource demand objects in Kubernetes autoscaling?
Resource demand objects are created when the cluster lacks sufficient capacity to schedule a Spark application. These objects help the custom autoscaling controller, called Scaler, to adjust the cluster size accordingly, allowing for better resource management and utilization during demand surges.

Key Statistics & Figures

Pods processed per second
more than 10
This metric reflects the performance of the Spark Scheduler Extender in larger Kubernetes clusters.
Concurrent Spark jobs executed
hundreds
This indicates the capacity of the system to handle multiple Spark applications simultaneously across over 1000 nodes.
Hosts spun up during demand surges
100+
This demonstrates the efficiency of the autoscaling mechanism in responding to increased resource demands.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Key Actionable Insights

1
Implement FIFO gang scheduling to ensure that all necessary pods for a Spark application are launched together.
This approach prevents resource starvation and enhances performance for larger applications, especially in environments with limited resources.
2
Utilize resource demand objects to improve cluster autoscaling efficiency.
By creating these objects when resources are insufficient, you can ensure that your cluster scales appropriately to meet the demands of Spark applications.
3
Monitor the performance of the k8s-spark-scheduler in production environments.
Regular monitoring can help identify bottlenecks and optimize scheduling requests, leading to better resource utilization and application performance.

Common Pitfalls

1
Failing to implement gang scheduling can lead to resource starvation for larger applications.
Without gang scheduling, smaller applications may be prioritized, causing larger applications to wait indefinitely for resources.
2
Not utilizing resource demand objects can result in inefficient cluster scaling.
If the cluster does not adjust based on demand, it may lead to performance bottlenecks and resource shortages during peak usage.

Related Concepts

Kubernetes Scheduling
Spark Architecture
Cluster Autoscaling
Resource Management