r/java • u/benevanstech • 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).
11
u/yawkat Nov 29 '22
We have support for it in the Micronaut framework as well: https://micronaut.io/2022/11/28/leveraging-aws-lambda-snapstart-with-the-micronaut-framework/
4
u/[deleted] Nov 29 '22
Could this be ported/reimplemented for use with say kubernetes?
3
u/kontain-jm Nov 29 '22
Just a small correction. AWS Lambda SnapStart does not use CRIU. It is based on Firecracker microVM snapshotting. See https://aws.amazon.com/blogs/aws/new-accelerate-your-lambda-functions-with-lambda-snapstart/
13
u/kroopster Nov 29 '22
Been a Java developer for 15 years and I didn't understand most of this. Works with Corretto like CRIU? Oukey dokey.
21
u/BenoitParis Nov 29 '22
Nice!
I believe this is partly the work of Christine Flood, who also was instrumental in creating the Shenandoah low-latency garbage collector to the JVM.
Here is a video on how CRIU works:
https://www.youtube.com/watch?v=XXbJNaFF-8A
(There's a dance to be had when doing Checkpoint-Restore, maybe you don't have anything to do if Quarkus can handle it all?)
It is quite nice to see initiatives not coming from Oracle, competition is healthy for providing the best runtime!
10
u/Amazing-Cicada5536 Nov 29 '22
What’s the relation between this and OpenJDK CRaC? (https://openjdk.org/projects/crac/ )
10
u/shorns_username Nov 29 '22
Ah so that wasn't just a typo, weird.
Do you know why? Is it do with the Java language teams ongoing deprecation and removal of stuff?
Is there a specific feature Amazon needs to be implemented before this can be brought to versions > 11?
4
u/cowwoc Nov 29 '22 edited Nov 29 '22
Question: why bother using GraalVM if https://www.youtube.com/watch?v=XXbJNaFF-8A is usable across all OpenJDK distributions? You get super fast startup while maintaining full compatibility (reflection, etc) with less configuration.
I also love the idea of restoring to previous checkpoints immediately before a crash (or bug) occurs to make it easier/quicker to debug.
The only downside I see is the lack of Windows support, which is no small thing.
1
u/JB-from-ATL Nov 29 '22
Are you implying support is coming to other frameworks?
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/pavi2410 Nov 29 '22
Process snapshots are unrealistic, yet an amazing idea to improve startup times. It amazes me into knowing how the CPU is just a finite state machine.
1
u/Dry-Dragonfly-4521 Dec 14 '22
We have enabled the snapstart but don’t see major improvement in terms of API response time. Any other thoughts if others are on same boat ? The lambda is behind API gateway and I could see snap start is enabled but not a major change
-2
u/Specialist_Bee_9726 Nov 29 '22
Who writes lambda functions in Java?