AWS Lambda SnapStart update speeds up application cold starts

People walk in front of an Amazon Web Services sign on display on a conference floor
(Image credit: Getty Images)

Amazon Web Services (AWS) has announced Lambda SnapStart, an update to the Lambda serverless compute service that greatly reduces application start latency.

SnapStart aims to speed up the cold start times of applications through the use of snapshots which can run multiple execution environments.

RELATED RESOURCE

IBM FlashSystem 5000 and 5200 for mid-market enterprises

Manage rapid data growth within limited IT budgets

FREE DOWNLOAD

Once enabled within a Lambda function, Lambda SnapStart will begin its optimisation, storing an encrypted snapshot of the memory and disk state in the cache to be called upon at a later time. Snapshots that have not been called for 14 days are removed from the cache memory.

AWS Lambda runs functions within a secure execution environment that cycle through an initialisation (Init), invocation (Invoke), and shutdown phase. Running through these every time code is called upon can be slow and lead to increased costs.

With Lambda SnapStart, each snapshot can be retrieved and invoked without the need for the Init phase, and populates the execution environment in chunks as required. This results in far faster load and execution times, and AWS claims Lambda SnapStart can enable Java functions to start up ten times faster.

“Initialising the runtime for some languages can be expensive,” said Jeff Barr, chief evangelist at AWS, in a blog post.

“For example, the Init phase for a Lambda function that uses one of the Java runtimes in conjunction with a framework such as Spring Boot, Quarkus, or Micronaut can sometimes take as long as ten seconds - this includes dependency injection, compilation of the code for the function, and classpath component scanning.”

In the same post, Barr gave an example of the service in action, in which he reduced the initialisation of an example function from just over 6 seconds to under 200 milliseconds. This is possible through the restoration of the snapshot saved in the cache, and the subsequent invocation of the function handler.

For all its benefits, the introduction of Lambda SnapStart does necessitate any changes to existing developer practice. Code that has relied on generating content during the Init phase might require alteration, like pseudo random number generators, for example, as the restoration phase does not provide the unique conditions of initialisation.

With this in mind, AWS has updated functions such as OpenSSL’s RAND_BYTES function so that it works in a SnapStart environment, as well as similar functions within Java and Amazon’s Linux.

Similarly, AWS has warned developers to check over code that downloads reference data during the Init phase, as this can be made stale through SnapStart’s caching.

AWS Lambda is the firm’s serverless computing service, which allows companies to run code without the need to provision or manage servers in-house. Developers can use it to run apps and focus entirely on their maintenance, without the additional burden of servers or hardware.

The announcement was made at the firm’s annual conference AWS re:Invent, held in Las Vegas. SnapStart is available now for Lambda customers at no extra cost, in the Asia Pacific, Europe, US East, and US West regions.

Rory Bathgate
Features and Multimedia Editor

Rory Bathgate is Features and Multimedia Editor at ITPro, overseeing all in-depth content and case studies. He can also be found co-hosting the ITPro Podcast with Jane McCallion, swapping a keyboard for a microphone to discuss the latest learnings with thought leaders from across the tech sector.

In his free time, Rory enjoys photography, video editing, and good science fiction. After graduating from the University of Kent with a BA in English and American Literature, Rory undertook an MA in Eighteenth-Century Studies at King’s College London. He joined ITPro in 2022 as a graduate, following four years in student journalism. You can contact Rory at rory.bathgate@futurenet.com or on LinkedIn.