Is there any ability to use GraalVM to run Java in AWS Lambda functions? I read a lot articles about cold starts of Java applications with GraalVM AOT (ahead-of-time) compilation feature and decreasing duration of that and I'd like to try to use it in my AWS Lambda projects.
GraalVM native executables can run faster than Scala/Java/JVM applications, with much less memory consumption.
Lambda supports two types of deployment packages: container images and . zip file archives. This page describes how to create your deployment package as a . zip file or Jar file, and then use the deployment package to deploy your function code to AWS Lambda using the AWS Command Line Interface (AWS CLI).
You can use the aws-serverless-java-container library to run a Spring Boot application in AWS Lambda. You can use the library within your Lambda handler to load your Spring Boot application and proxy events to it. In the repository we have included a sample Spring Boot application to get you started.
With the introduction of Custom AWS Lambda Runtimes at re:Invent 2018, this is now do-able. See further the AWS Lambda Runtime Interface
You can use the bootstrap shell script published at https://docs.aws.amazon.com/lambda/latest/dg/runtimes-walkthrough.html to invoke your GraalVM native image, or you can implement the bootstrap functionality in your native image.
There is also an interesting article in Japanese on an approach which uses Micronaut which Google can translate for you, and corresponding https://github.com/kencharos/try-graal-lambda though imho the case for using Micronaut here is not that compelling.
I have a full sample with Java+ GraalVM+ Custom Runtime with all deployments scripts even. Also, I compared the performance with the most popular runtimes:
https://github.com/Aleksandr-Filichkin/java-graalvm-aws-lambda
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With