Introducing Datadog's Next-Generation Rust-Based Lambda Extension | Datadog

Introducing Datadog's Next-Generation Rust-based Lambda Extension

Author Jordan Obey
Author AJ Stuyvenberg

Published: December 3, 2024

In 2021, we announced the release of the Datadog Lambda extension, a simplified, cost-effective way for customers to collect monitoring data from their AWS Lambda functions. This extension was a specialized build of our main Datadog Agent designed to monitor Lambda executions. Over time, we shifted our focus to addressing the specific needs of a resource-constrained environment like Lambda’s, where extension size, cold starts, and API integrations all have an impact on capturing logs, metrics, and traces efficiently within Lambda’s unique lifecycle.

With those factors in mind, we developed a low-overhead Rust-based next-generation Lambda extension. By leveraging Rust’s reliability, efficiency, and sustainability, our next-generation Lambda extension provides a faster, more resilient experience with reduced resource consumption, ensuring consistent performance and lower operational costs at scale.

In this post, we’ll look at how the new Rust-based Lambda extension helps improve Lambda function monitoring.

Enhanced performance and resource efficiency with Rust

One of the primary concerns of any serverless developer is minimizing the cold start latency of their functions. Because Lambda functions share CPU and memory resources with their extensions, it’s important to have an efficient, lightweight Agent that keeps any contributions to the duration of a cold start as short as possible.

Thanks to Rust’s unique memory management model, which enforces strict ownership and borrowing rules, our new Lambda extension minimizes resource overhead and limits cold starts by achieving memory efficiency without relying on a garbage collector. In fact, with the next-gen Lambda extension, we improved our average cold start time from around 450ms to approximately 50ms.

Unlike garbage-collected languages, where memory cleanup happens unpredictably during garbage collection cycles, Rust determines exactly when memory is freed at compile time. This allows us to tightly control memory allocation and deallocation, avoiding runtime pauses and reducing the latency that can negatively impact Lambda performance—making it an ideal fit for our Lambda extension. In fact, with our next-gen extension we were able to halve our overall memory overhead.

mem_overhead.png

Our next-gen extension is also purpose-built to work seamlessly with Lambda’s limited compute power and unique lifecycle. By optimizing CPU usage to occur primarily after the invoke phase, we reduced CPU consumption during execution, which allows the extension to run smoothly and without interruption. This approach decreases the overall billed duration and improves function response time.

Get started with the next-gen Lambda extension today

The next-generation Lambda extension provides you with custom and enhanced metrics, as well as real-time traces and function logs—all with minimal overhead and cold starts. The next-gen extension is automatically available after you follow the installation instructions for the Datadog Agent for AWS Lambda. To learn more about this extension, check out our documentation.

If you’re not already using Datadog, get started today with a 14-day