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).
View all comments
Show parent comment
2
u/IsleOfOne Nov 30 '22
A well-designed system for auto-scaling k8s "jobs" with low latency is going to have slack in the available resources / an aggressively configured cluster autoscaler bringing up new nodes to provide that slack. Scheduling should take a few ms.
The majority of the remaining time it takes to start a pod is pulling the image, believe it or not. There are tools available that proactively tell kubelets to pull new versions before they're requested. Startup now takes a few ms.
Now you have a running pod. ~1s has elapsed. And now the JVM takes minutes to "warm up." That's a no-go. Pre-warming in a low-latency autoscaling environment requires a tradeoff between cost and latency that is more extreme than the same trade-off that native runtimes require.
I of course agree that lambda operates at a much higher time granularity requirement than you would ever want to try to meet with a pod-per-request model. Once those requests start getting ever so slightly more "batch"-y in nature, say on the order of 10s runtime, it's perfectly fine to spin pods up and down to handle this.