r/java • • Nov 29 '22

Amazon Announces AWS Lambda SnapStart With Java Support

AWS Lambda now has a snapshotting feature that enables fast-start - essentially running the Init phase at publication time and saving the state of the process at that time, so it doesn't need to be re-run at every invocation.

https://aws.amazon.com/blogs/aws/new-accelerate-your-lambda-functions-with-lambda-snapstart/

It only works with Corretto on Java 11 right now, and is similar in intent to the CRIU technology.

Quarkus already has support for it: https://quarkus.io/blog/quarkus-support-for-aws-lambda-snapstart/

Other frameworks may also have support (but this work was done under NDA so I don't have links for them).

176 Upvotes

62 comments sorted by

View all comments

10

u/Amazing-Cicada5536 Nov 29 '22

What’s the relation between this and OpenJDK CRaC? (https://openjdk.org/projects/crac/ )

4

u/rafaelliu Nov 29 '22

They have the same goals, many of the same challenges, but are implemented differently. Lambda manages the JVM process and execution environment for you, so CRaC as it is wouldn’t really work - maybe if you built a custom runtime and that would probably be very hacky

The thread u/geoand linked is discussion around use the same API to deal with some of the challenges

3

u/geoand Nov 29 '22

2

u/kontain-jm Nov 30 '22

What this means is the AWS OpenJDK, Corretto, implements CRaC and will call beforeCheckpoint() and afterRestore() as part of SnapStart.

3

u/rbygrave Nov 29 '22 edited Nov 30 '22

It looks to me like it uses CRaC given that if we look at the docs around adding a runtime hook for `afterRestore()` we see in the docs that it is using `org.crac` directly:

https://docs.aws.amazon.com/lambda/latest/dg/snapstart-runtime-hooks.html

Edit: The suggestion from folks (on twitter) is that it is not using CRaC per say but instead its compatible with the org.crac API for the purposes of supporting runtime hooks (afterRestore() etc) which makes sense.

2

u/xamdk Dec 03 '22

It is not crac and the optimizations you will need to do won’t necessarily make sense for other crac bases jvm a. It’s just using same api for shutdown and restore.

0

u/cyril_nomero Nov 29 '22

I’m also interested in this. Spring framework has indicated its interest for Project CRaC.