Improving Spark Application Throughput Via Memory Aware Task Co-location: A Mixture of Experts Approach

Vicent Sanz Marco, Ben Taylor, Barry Porter, Zheng Wang

Introduction

Apache Spark has become a cornerstone of big data processing. However, its resource utilization is often suboptimal. Most Spark applications are characterized as "memory-hungry" but "CPU-lazy." To avoid catastrophic Out-of-Memory (OOM) errors, users typically over-provision memory resources. This leads to significant CPU underutilization, as reserved memory prevents other tasks from being co-located on the same physical server.

While task co-location is a potential solution, it introduces the risk of hitting the "memory wall," where excessive memory demand leads to disk paging or system crashes. Existing resource-aware schedulers often rely on inaccurate user estimates or simplistic models that fail to capture the diverse memory scaling behaviors of different algorithms.

The Mixture of Experts Framework

To address these challenges, we propose a Mixture of Experts (MoE) framework designed to predict the memory footprint of Spark applications accurately. The core philosophy is that no single mathematical model can represent all Spark workloads. Instead, the system identifies the specific memory-usage pattern of an incoming job and selects the most appropriate specialized "expert" model.

The online workflow for memory prediction and task scheduling.

The online workflow consists of several stages:

  1. Feature Extraction: A new job is initially run on a small data sample (~100MB). During this phase, 22 runtime features are collected using tools like perf and vmstat.
  2. Function Prediction: A K-Nearest Neighbor (KNN) classifier analyzes the reduced feature set to categorize the application into one of three patterns: Piecewise Linear, Exponential, or Napierian Logarithmic.
  3. Model Calibration: The system performs two short runs on 5% and 10% of the total input data to fine-tune the parameters of the selected expert model.
  4. Task Scheduling: The calibrated model predicts the memory footprint for the full dataset, allowing the scheduler to pack tasks onto hosts efficiently without exceeding physical RAM or CPU limits.

Feature Engineering and Principal Component Analysis

A critical component of the MoE approach is identifying the most predictive runtime features. The initial 22 features include metrics related to cache performance, I/O, and thread contention.

Analysis of principal components and the most significant raw features for memory prediction.

Using Principal Component Analysis (PCA), we determined that the first five principal components account for 95% of the variance in application behavior. Further analysis of the raw features revealed that L1 cache miss rates (L1_TCM and L1_DCM) are the most significant indicators of memory footprint. This insight highlights that memory behavior is more closely tied to low-level hardware interactions than to high-level I/O or contention metrics.

Experimental Evaluation

The framework was evaluated using 44 Spark applications from benchmarks including HiBench, BigDataBench, Spark-Perf, and Spark-Bench.

Performance Metrics

  • Accuracy: The system achieved a memory footprint prediction error of less than 5% across diverse workloads.
  • Throughput: Compared to isolated execution, the MoE approach delivered an 8.69x improvement in System Throughput (STP).
  • Comparative Advantage: The framework outperformed Quasar, a state-of-the-art resource-aware scheduler, by 1.28x in throughput and 1.68x in job turnaround time.
  • Efficiency: The system reached 83.9% of the performance of a theoretical "Oracle" scheduler, demonstrating minimal overhead.

Conclusion

By leveraging a Mixture of Experts approach and low-level hardware features, we can significantly improve the efficiency of Spark clusters. The ability to accurately predict memory footprints allows for aggressive task co-location, turning idle CPU cycles into productive throughput. Future work will focus on modeling I/O contention and adapting to dynamic program phases within long-running applications.

Summary updated

BibTeX
@inproceedings{marco2017improving,
  author = {Vicent Sanz Marco and Ben Taylor and Barry Porter and Zheng Wang},
  title = {{Improving Spark Application Throughput Via Memory Aware Task Co-location: A Mixture of Experts Approach}},
  booktitle = {Middleware},
  year = {2017},
  doi = {10.1145/3135974.3135984},
}
Figure