November 30, 2022 / Poonam Pratik
When the Lambda service receives a request to run a function, the service first prepares an execution environment. During this step, the service downloads the code for the function, which is stored in an internal S3 bucket (or in Amazon ECR if the function uses container packaging). It then creates an environment with the memory, runtime, and configuration specified. Once complete, Lambda runs any initialization code outside of the event handler before finally running the handler code.
Download the code & start a new execution environment are frequently referred to as a “cold start”. You are not charged for the time it takes for Lambda to prepare the function but it does add latency to the overall invocation duration.
Cold start times have long been one of the biggest complaints about Lambda.
Functions using Java runtimes typically experience significantly longer initialization times than functions using other runtimes. SnapStart for Java reduces startup latency for Java-based functions running on AWS Lambda.
Today, AWS announced a new feature called SnapStart for Lambda.
This new feature is now available on the platform, though it has to be enabled for existing Lambda functions, and for now, it only works for Java functions that make use of the Corretto runtime.
SnapStart aims to speed up the cold start times of applications through the use of snapshots that can run multiple execution environments.
Once enabled, when you first run that function, it will perform a standard initialization. After that, it will create an encrypted snapshot of the memory and disk state, and cache for reuse. Then, when the function is invoked again, Lambda will grab the cache and start up the function. AWS Lambda further improves invoke times by dividing snapshots into chunks. This means only the chunks required for your function are downloaded from a distributed cache on invoke. In real terms, this process removes several seconds of latency from function execution and scaling times. Cached snapshots are removed after 14 days of inactivity.
AWS Serverless Developer | Project Consulting and Support | Data Science | Data Analysis
Poonam Pratik, an accomplished author, Result oriented and a dedicated professional with 15+ years experience of working in IT project consulting, custom product development.
Have queries about your project idea or concept? Please drop in your project details to discuss with our AWS Global Cloud Infrastructure service specialists and consultants.