In the first article of our small series we explored how to develop and deploy Lambda function using Docker Container Image and Java runtime. We explored 2 use cases:
In this article we'll measure cold and warms starts of the Lambda function using this approach AWS Lambda base Docker container image.
For our measurements we'll use our sample application from the first part and use Java 21 runtime for our Lambda functions. For all Lambda functions we give 1024 MB memory and use JAVA_TOOL_OPTIONS: "-XX: TieredCompilation -XX:TieredStopAtLevel=1" as this compilation option provides a very good-trade of between the cold and warm start times.
The results of the experiment below were based on reproducing more than 100 cold and approximately 100.000 warm starts for the duration of 1 hour with Lambda function GetProductByIdWithPureJava21GraalVMNativeImageLambda which is mapped to the Java Lambda handler class which is responsible for retrieving the product (stored in the DynamoDB) by id. For it I used the load test tool hey, but you can use whatever tool you want, like Serverless-artillery or Postman.
Cold (c) and warm (m) start time in ms:
c p50 | c p75 | c p90 | c p99 | c p99.9 | c max | w p50 | w p75 | w p90 | w p99 | w p99.9 | w max |
---|---|---|---|---|---|---|---|---|---|---|---|
3093.26 | 3219.44 | 3314.12 | 4632.16 | 6513.35 | 6517.71 | 5.47 | 6.20 | 7.39 | 17.14 | 43.03 | 1386.07 |
In this article, we measured cold and warms start times of the Lambda function using this approach AWS Lambda base Docker container image. We experienced quite significant cold start and quite competitive warm start times compared to Measuring cold and warm starts with Java 21 using different Lambda memory settings for Lambda with 1024 MB memory and Lambda Java 21 managed runtime.
AWS Lambda SnapStart which significantly reduces cold start times is currently only available for Java Corretto managed runtimes (11, 17 and 21) and not for Docker container images. You can explore jlink tool to assemble and optimize a set of modules and their dependencies into a smaller custom runtime image and Class data sharing (CDS) though which helps reduce the startup time for Java programming language applications, in particular smaller applications, as well as reduce footprint. The advantage of using the Docker Image as deployment artifact for Java is the ability to use recent Java runtime like Java 22 (Java 23 will be released in September 2024).
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3