Online Learning for Right-Sizing Serverless Functions

Prasoon Sinha, Kostis Kaffes, Neeraja J. YadwadkarASSYST @ ISCA 2023

TL;DR

This paper introduces Lachesis, a novel serverless resource allocation framework that uses online learning to dynamically right-size function invocations. By accounting for input variability and decoupling resource types, Lachesis significantly improves performance and reduces idle resources compared to static allocation methods.

What Problem Does This Paper Address?

Serverless computing offers convenience by abstracting away resource management. However, this abstraction creates a "black box" for both users and providers. Users lack control over performance and cost, often resorting to overprovisioning resources to ensure their applications meet performance targets. Providers, in turn, struggle to optimize resource utilization due to a lack of visibility into how different inputs affect function execution. Existing systems typically offer a single memory knob, which couples CPU and memory, leading to inefficiencies for workloads that are not uniformly CPU or memory-bound. This paper tackles the challenge of dynamically and efficiently allocating resources to serverless functions on a per-invocation basis, considering the nuances of input data and function behavior.

Methods

The core of Lachesis is an online learning agent that predicts the optimal number of CPU cores for each function invocation. Instead of relying on user-specified static resource limits, Lachesis takes the function, its input, and a Service Level Objective (SLO) as input.

Here's a breakdown of their approach:

  • Input and Function Featurization: Lachesis extracts relevant features from both the function itself (e.g., number of calls, libraries used) and the specific input (e.g., image size, video resolution, matrix density). This allows it to capture the unique characteristics of each invocation.
  • Cost-Sensitive Multi-Class Classification: Rather than a simple regression, Lachesis employs a cost-sensitive classification approach. Each "class" represents a specific CPU core count. The system learns a linear regressor for each class to predict its cost. The class with the lowest predicted cost is chosen for allocation. This method allows for nuanced cost differentiation between under- and over-provisioning.
  • Online Learning and Feedback Loop: After each invocation, Lachesis collects metrics like maximum CPU utilization and execution time. This feedback is used to update the online learning model, allowing it to adapt to changing workload patterns and improve its predictions over time.
  • Decoupled Resource Allocation: A key design principle is decoupling CPU and memory allocation. This allows Lachesis to allocate resources more precisely based on a function's actual needs, rather than being constrained by the fixed CPU-memory ratios imposed by many current platforms.

Datasets

The paper does not introduce new datasets but rather uses a collection of 12 serverless functions from literature and benchmark suites. These functions cover a range of application types, including scientific computing, data processing, and machine learning inference/training. The authors collected approximately 8,000 runs across these functions, varying input sizes and CPU limits to characterize their behavior.

Key Insights and Ideas

  • Input Matters (A Lot!): Function performance and resource utilization are highly sensitive to input properties beyond just size. For example, video resolution significantly impacts CPU and memory usage, even for videos of similar file sizes.
  • Single vs. Multi-Threaded Functions: Serverless platforms host a mix of single-threaded and multi-threaded functions. Simply adding more CPU cores doesn't always help; for single-threaded functions, it can lead to significant idle resources.
  • Resource Coupling is Inefficient: The tight coupling of CPU and memory in many serverless platforms leads to substantial underutilization. For instance, memory-bound functions might be allocated excessive CPU, and compute-bound functions might require massive memory allocations, both resulting in wasted resources.
  • Online Learning for Adaptability: Static allocation policies are inherently suboptimal due to the dynamic and input-dependent nature of serverless workloads. Online learning provides a mechanism for systems to continuously adapt and right-size resources per invocation.

Key Results

Lachesis demonstrated significant improvements over static allocation baselines:

  • Speedup: Lachesis achieved up to 2.6x speedup compared to static allocation decisions made by users.
  • Idle Cores Reduction: The framework reduced idle cores by 82%.
  • Cost Reduction: For the resnet-50 function alone, Lachesis reduced user cost by 63% over 100 invocations.
  • SLO Violations: Lachesis generally maintained a low SLO violation rate, often outperforming medium-sized static allocations while significantly reducing idle resources. In cases with unrealistic SLOs, Lachesis would attempt to meet them by allocating more resources, even up to the maximum available, highlighting the limitations of the SLO itself.

Limitations and Future Work

  • Per-Function Agents: Currently, Lachesis uses a separate online agent for each function due to the diverse features extracted from different input types. The authors plan to standardize features to enable a single agent for all functions.
  • CPU-Centric Allocation: While Lachesis decouples resources, it currently focuses on CPU allocation. Future work includes augmenting it to dynamically allocate memory per invocation as well.
  • Cold Starts: Per-invocation allocations can increase the number of containers used per function, potentially leading to more cold starts, which degrade performance. The authors propose designing a scheduler that balances fine-grained allocation benefits with the cost of cold starts.

Summary updated

BibTeX
@inproceedings{sinha2023online,
  author = {Prasoon Sinha and Kostis Kaffes and Neeraja J. Yadwadkar},
  title = {{Online Learning for Right-Sizing Serverless Functions}},
  booktitle = {ASSYST @ ISCA},
  year = {2023},
  url = {https://openreview.net/forum?id=4zdPNY3SDQk},
}
Figure