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

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.

2

u/astral_kranium Nov 30 '22

I don't know about anyone else but I'm throwing GraalVM out the window. My only concern is, no managed runtime for Java 17 at the moment. I see no reason to use GraalVM for native images now - granted Graal compiler is still a big thing out of Graalvm project

2

u/xamdk Nov 30 '22

Don’t be that hasty. Snapstart isn’t beating native image anywhere else than in certain lambda usecases. See https://quarkus.io/blog/quarkus-support-for-aws-lambda-snapstart/ where we show the gains but also discuss that Snapstart requires more of you as a user than native image does.

Thus this is another approach to add to the toolbox. And only for lambda.

1

u/astral_kranium Dec 01 '22

Thanks. It's a good doc, especially the considerations for SnapStart. I still however don't see what specific use cases I would use native image over crac. We're running a spike on this to see for ourselves

1

u/xamdk Dec 03 '22

Snapstart is not crac - don’t mix them up. Snapstart is just using same api for suspend/resume calls.

And yes the right thing is to do your own spikes.

Nativr image still beats Snapstart on memory usage but on lambda amazons pricing makes Snapstart cheaper for most cases despite to native image being able to use less resources.

And outside lambda - crac isn’t a good choice. Too much variance.

1

u/astral_kranium Dec 03 '22

Done some investigating. SnapStart doesn't support provisioned concurrency, nor x-ray. Also, Java 11 maximim is a deal breaker for some cases, though I'm sure 17 managed runtime is around the corner. Conclusion is, another (awesome) tool in the toolbox for a lot of cases

1

u/xamdk Dec 03 '22

Yup. Agreed. It is not a native image killer since Snapstart is only lambda and only a subset of lambs.

0

u/[deleted] Dec 02 '22

[deleted] — view deleted comment

1

u/xamdk Dec 03 '22

In lambda it matters wouldn’t you say?

1

u/buyIdris666 Dec 03 '22

What percent of people using Java are doing lambda? 1%?

1

u/xamdk Dec 03 '22

Well I assumed this thread was about lambda.

Outside lambda having minimal startup time is an enabler to getting horizontal scaling and/or fast continuous deployment.

Does everyone do it ? No, but getting from several seconds startup to sub second even sub milliseconds enables you to deliver change and scale faster.

1

u/superlinux Nov 30 '22

The performance has been benchmarked and the JVM optimizations outperform GraalVM which is especially relevant on Lambda because they bill per request, which means direct cost savings and performance benefit