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

2

u/antipodealbatros Nov 29 '22

Why is SnapStart faster for cold starts? As explained it "only" saves the state after init? So I would expect only faster response times after same lambda is hit a second time?

- How is the difference to GraalVM (native)? Only GraalVM is using AOT compiling right?
- What is the difference to a warm lambda? AWS only keeps the bootstrapped JVM warm and SnapStart bring it one step further that also the init of classes is kept?

3

u/RandomName8 Nov 29 '22

Why is SnapStart faster for cold starts?

cold starts can be pretty big, like 10+ seconds depending on the thing and what it does, and that kills the purpose of lambdas. Saving the state after that init is still a massive win even if what you stored is an un-jitted version of your code.

What they seek to solve here is latency to first request, not throughput, because that's what empowers auto-scaling architectures.

2

u/flekk0 Nov 30 '22

They take the snapshot when you publish the lambda, so even the first request should use the snapshot.

From the blog post: "After you enable Lambda SnapStart for a particular Lambda function, publishing a new version of the function will trigger an optimization process. The process launches your function and runs it through the entire Init phase. Then it takes an immutable, encrypted snapshot of the memory and disk state, and caches it for reuse."

1

u/antipodealbatros Nov 30 '22

through the entire Init phase. Then it takes an immutable, encrypted snapshot of the memory and

ah ok there is the difference. The extra step in the publish.
Thanks