Spark jobs optimization
Apache Spark jobs on EKS have unique characteristics, they require large burst capacity, run for variable durations, and can waste resources if drivers outlive executors or if executor pools are over-provisioned.
Actions
Implement Spark-specific node management and scheduling optimizations. Refer to this GitHub repository
Spark configuration for cost optimization
For sample commands to create dynamic allocation scales executors based on pending tasks,see this GitHub repository
Spark job lifecycle optimization
Optimization For the complete scripts and manifests, see the 09-spark-jobs-optimization | Configuration | Savings |
|---|---|---|
Dynamic allocation |
| 30–50% fewer executor-hours |
Executor idle timeout |
| Rapid scale-down |
Spot instances for executors | Node selector for spot capacity type | 60–90% off on-demand pricing |
On-demand for driver | Prevent job failure from Spot interruption | N/A (reliability) |
Node decommissioning |
| Graceful Spot handling |
Recommendations:
Use Spot instances for Spark executors (they are fault-tolerant by design)
Keep Spark drivers on On-Demand instances to prevent job failures
Enable dynamic allocation to scale executors based on pending tasks
Set aggressive
executorIdleTimeout(30–60s) to release resources quicklyUse Karpenter's
consolidationPolicy: WhenEmptyfor Spark NodePools to avoid disrupting running executorsSchedule large batch Spark jobs during off-peak hours for better Spot availability and lower contention