DEV Community

Vadym Kazulkin for AWS Community Builders

Posted on • Updated on

AWS Lambda SnapStart - Part 9 Measuring Java 21 Lambda cold starts


In the part 7 of our series we re-measured the cold start of the Lambda function with Corretto Java 11 runtime and SnapStart enabled after AWS fixed the "Restore Duration" time displayed in the CloudWatch (Logs). You can refer to the part 7 to review the results of our measurements.

In part 8 we measured the cold start of the Lambda function with Corretto Java 17 runtime and SnapStart enabled .

On November 17 AWS announced support of Corretto Java 21 runtime for Lambda.

Image description

This a very good sign to the Java community that the support of the LTS version comes less than 2 months after this long term release is there. We had to wait for Lambda support of Java 17 way too long :)

SnapStart is also supported with Java 21 directly from the beginning (in the supported regions). I was curious what cold starts we will get with Java 21 with SnapStart enabled and also with and without the usage of priming. So let's measure it.

Measuring the cold start times with Java 21 with and without SnapStart enabled

For measurement purposes I created/copied the sample application and configured Lambda functions to use Java 21 runtime for Lambda and 1024 MB memory .

Now we use the same CloudWatch Logs Insights Query as we used in the part 7 of our series. We also enable SnapStart for both our Lambda functions GetProductByIdWithPureJava21Lambda (without priming) and GetProductByIdWithPureJava21LambdaAndPriming (with priming of DynamoDB invocation) and after approximately 100 cold starts we got the following durations:

Experiment description p50 p90 p99
cold start time w/o SnapSart 3155.88 3292.80 3605.95
cold start time with SnapStart w/o Priming 1591.31 1823.14 2021.67
cold start time with SnapStart with Priming 760.79 955.76 1200.12


For the cold start times measured with Java 11, 17 and 21 runtimes with SnapStart enabled and additionally with and without priming of DynamoDB invocation we got comparable results, but Java 21 measurements had slightly worse results for p90 and p99 especially when using priming. This may depend on the executed measurements.

I also refer to my previous article Reducing Cold Starts on AWS Lambda with Java Runtime - Future Ideas about SnapStart, GraalVM and Co . I think it's now time for AWS to provide some improvements and to further reduce the cold start duration with SnapStart.

Top comments (0)