There have been plenty of articles written on the ways to optimize your AWS Lambda functions to run quicker and to avoid the dreaded “cold boot” scenario. This is despite the fact that it was reported by Amazon tech advocates that an extreme minority of function invocations are actually cold booted (approximately 0.2%). That said, there are a number of scenarios I’ve encountered where you’re definitely going to hit a lot of cold boots and it’d really be better to avoid them:

  1. Small projects or prototyping with several functions in play, all of which you may call at different, spaced out times. Even if your tinkering with something that will never see the light of day, waiting for Lambdas to spin up gets tedious quick.
  2. You’ve stood up a portfolio or demo website and you’re applying for a job. If you’re trying to make a good impression with something cool you’ve built, it’s best to avoid ruining it by presenting a load spinner for extended periods.
  3. It’s often mentioned that the cold boot wait time is a couple of seconds — that has NOT been my experience at all. For me, I’ve regularly spent 5–6 seconds waiting for my Lambda to roll out of bed and get to work.

With these fairly lightweight scenarios in mind, let’s dive into a simple, straightforward approach to warming your Lambdas.

The Obligatory Opening Explanation

Simply stated, a “cold boot” is the slow first time startup of a Lambda function.

After the function initially “boots”, it is available on a much faster basis until the Lambda goes unused for an extended period of time (or the data center is struck by an asteroid). After this extended period of time (or unfortunate wrath of the heavenly bodies), the Lambda function is destroyed so the whole cold boot process has to start up again.

#aws-lambda #python #serverless #cloudwatch

Out from the Cold-A Simple Guide To AvoidingCold Boots byWarming Your AWSLambda Functions
1.55 GEEK