DEV Community

Ken Collins for AWS Heroes

Posted on • Updated on • Originally published at lamby.cloud

💔 Goodbye Cold Starts ❤️Hello Proactive Initialization

💁 Full Rails & Lambda Details at:
https://lamby.cloud/docs/cold-starts

As described in AJ Stuyvenberg's post on the topic Understanding AWS Lambda Proactive Initialization, AWS Lambda may have solved some of your cold start issues for you since March 2023. Stated in an excerpt from AWS' docs:

For functions using unreserved (on-demand) concurrency, Lambda occasionally pre-initializes execution environments to reduce the number of cold start invocations. For example, Lambda might initialize a new execution environment to replace an execution environment that is about to be shut down. If a pre-initialized execution environment becomes available while Lambda is initializing a new execution environment to process an invocation, Lambda can use the pre-initialized execution environment.

This means the Monitoring with CloudWatch is just half the picture. But how much is your application potentially benefiting from proactive inits? Since Lamby v5.1.0, you can now find out easily using CloudWatch Metrics. To turn metrics on, enable the config like so:

config.lamby.cold_start_metrics = true
Enter fullscreen mode Exit fullscreen mode

Lamby will now publish CloudWatch Embedded Metrics in the Lamby namespace with a custom dimension for each application's name. Captured metrics include counts for Cold Starts vs. Proactive Initializations. Here is an example running sum of 3 days of data for a large Rails application in the us-east-1 region.

A CloudWatch Metrics graph showing a running sum of cold starts vs proactive inits for a large Rails application on Lambda.

This data shows the vast majority of your initialized Lambda Contaienrs are proactively initialized. Hence, no cold starts are felt by end users or consumers of your function. If you need to customize the name of your Rails application in the CloudWatch Metrics dimension, you can do so using this config.

config.lamby.metrics_app_name = 'MyServiceName'
Enter fullscreen mode Exit fullscreen mode

Top comments (0)