AWS has introduced the general availability of Lambda SnapStart for Python and .NET functions, a feature designed to improve the startup performance of serverless applications significantly.
Earlier, the company introduced Lambda SnapStart for Java functions to reduce cold starts. With the SnapStart for Python and .NET functions, this is now also applied for functions written in Python, C#, F#, and Powershell.
Lambda SnapStart optimizes function cold-start latency by initializing environments ahead of time and caching their memory and disk states. This cached environment is then used to resume execution, minimizing delays often caused by cold starts. Channy Yun, a principal developer advocate for AWS cloud, writes:
When you invoke the function version for the first time, and as the invocations scale up, Lambda resumes new execution environments from the cached snapshot instead of initializing them from scratch, improving startup latency.
(Source: AWS News Blog Post)
Marc Brooker, VP/Distinguished Engineer at Amazon Web Services, explains in a LinkedIn blog post:
Each Lambda function runs in one or more Firecracker-based MicroVMs, and each MicroVM has some associated state: memory, device state, CPU registers, and the like. A "snapshot" is when we tell Firecracker to store this state - writing down the memory and other state to a file on disk. This snapshot can be restored on the same physical machine, or a different machine with the same hardware configuration. Restoring is a simple matter of copying that state back into memory, back into the devices, and back into the CPU, then telling the (virtual) CPU that it can go ahead and start running.
Developers can use the AWS Management Console, AWS Command Line Interface (AWS CLI), or AWS SDKs to activate, update, and delete SnapStart for Python and .NET functions. They can activate Lambda functions using Python 3.12 and higher and .NET 8 and higher managed runtimes.
Yan Cui, an AWS Serverless Hero, tweeted:
Wow, SnapStart is now available for Python and .Net functions.
Interesting they didn't do it for Node, I guess it's not about popularity, so must be something about Node that doesn't work well with SnapStart.
Currently, AWS Lambda SnapStart for Python and .NET functions are available in US East (N. Virginia), US East (Ohio), US West (Oregon), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Frankfurt), Europe (Ireland), and Europe (Stockholm) AWS regions.
Lastly, with Python and .NET managed runtimes, SnapStart charges include the caching cost per published function version and restoration costs for each instance. The company recommends deleting unused function versions to lower SnapStart cache costs. Lambda's pricing details are available on the pricing page.