A Language-based Serverless Function Accelerator

Emily Herbert, Arjun GuhaarXiv 2019

Abstract: Serverless computing allows programmers to run functions in response to external events with sub-second pricing and transparent elasticity. However, today's serverless platforms exhibit high latency because they rely on expensive operating system-level sandboxing, such as containers and virtual machines. This paper presents Containerless, a serverless function accelerator that transparently lowers latency and resource utilization using language-based sandboxing. Containerless builds source-level, interprocedural execution trace trees for JavaScript functions, compiles them to a safe subset of Rust, and links them to a lightweight runtime. By leveraging the fact that serverless functions must tolerate re-execution for fault tolerance, the system can seamlessly transition between language-based and OS-based sandboxing when unsupported operations are encountered. Our evaluation demonstrates that Containerless significantly improves performance for a wide range of serverless workloads.

Introduction

Modern serverless platforms like AWS Lambda or Google Cloud Functions rely on operating system-level isolation to run untrusted code. While secure, this approach is "heavy," leading to significant "cold start" latencies and high memory/CPU overhead for the small, short-lived functions typical of serverless computing. Existing language-based alternatives often require programmers to switch to complex languages like Rust or use memory-intensive Just-In-Time (JIT) compilers that are slow to reach peak performance. Containerless addresses this gap by maintaining the ease of JavaScript while offering the efficiency of a lightweight, language-level sandbox.

System Architecture and Methods

Containerless employs a hybrid, speculative approach to function acceleration:

  1. Tracing and Instrumentation: When a function first runs, it executes inside a standard container. Containerless instruments the JavaScript source code to dynamically build an inter-procedural execution trace tree. Unlike traditional tracing JITs that focus on sequential code, Containerless can trace through asynchronous callbacks—a staple of serverless I/O.
  2. Trace-to-Rust Compilation: Once a stable "hot path" is identified, the system compiles the trace tree into a safe subset of Rust. This compiled code is then used for subsequent requests, bypassing the container entirely.
  3. Lightweight Runtime: The Rust-based sandbox uses arena allocation instead of garbage collection. Since serverless functions have transient in-memory state, the system clears the entire arena after each request, eliminating GC pauses and reducing the memory footprint.
  4. Transparent Fallback: If the compiled Rust code encounters an unknown execution path or an unsupported operation, it aborts. Because serverless functions are designed to be idempotent, Containerless can transparently restart the request in a standard container without user-facing errors.
The trace tree language used by Containerless to represent JavaScript execution paths, including support for asynchronous events.

Evaluation

The system was evaluated using a suite of six canonical serverless benchmarks: authorize (credential validation), upload (cloud storage push), status (GitHub status updates), banking (transactional updates), autocomplete (word completion), and maze (compute-intensive pathfinding).

Key Results

The evaluation shows that Containerless significantly outperforms traditional container-based execution:

  • Throughput: I/O-bound functions saw a geometric mean speedup of 3.4x.
  • Resource Efficiency: CPU utilization was reduced by a factor of 0.20x, and memory utilization was lowered by 0.81x compared to standard containers.
  • Latency Dynamics: As shown in the performance profile, the system exhibits a characteristic latency drop. After an initial tracing phase, the system exhibits a "double dip" in latency—first warming up the container, then dropping even further once the Rust acceleration kicks in.
Latency over time showing the transition from container-based execution to accelerated Rust execution.

For purely compute-intensive tasks like the maze benchmark, the standard Node.js JIT outperformed the simple traces of Containerless, highlighting that this approach is best suited for the I/O-heavy "glue" code that dominates serverless computing.

Discussion and Future Work

Containerless demonstrates that the fault-tolerance requirements of serverless (idempotency) can be repurposed as a powerful mechanism for performance optimization. Current limitations include the need for manual Rust shims for new Node.js built-in functions and lack of support for reflective features like eval. Future work will focus on automating API coverage and developing more sophisticated heuristics for adaptive tracing. Additionally, while Rust provides strong memory safety, running multiple functions in the same address space requires careful mitigation against side-channel attacks like Spectre.

Summary updated

BibTeX
@misc{herbert2019language,
  author = {Emily Herbert and Arjun Guha},
  title = {{A Language-based Serverless Function Accelerator}},
  year = {2019},
  eprint = {1911.02178},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1911.02178},
}
Figure