Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using GraalVM to run Java in AWS Lambda

Tags:

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.

like image 646
Gleb Avatar asked Aug 31 '18 14:08

Gleb


People also ask

Is GraalVM faster than JVM?

GraalVM native executables can run faster than Scala/Java/JVM applications, with much less memory consumption.

Can Lambda run jar file?

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).

Can you run spring boot in Lambda?

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.


2 Answers

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.

like image 141
JasonPlutext Avatar answered Sep 18 '22 03:09

JasonPlutext


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

like image 42
Aleksandr Filichkin Avatar answered Sep 18 '22 03:09

Aleksandr Filichkin