Serhat Can

@serhatcan

Everything you need to know about cold starts in AWS Lambda

There are many blog posts about cold starts in AWS Lambda out there. I was doing some research and wanted to list the good ones here as well as some bullet points for quick insights into the topic.

What is a cold start?

A latency experienced when you trigger a function.

A cold start only happens if there is no idle container available waiting to run the code. This is all invisible to the user and AWS has full control over when to kill containers.

What is the effect of cold-start?

  • Frustrated users because of slow response
  • Paying more money for speed (sometimes)
  • Timeouts in the calling function if not thought through — chain reaction
  • Caring about an operational concern which has nothing to do with you

When should you care?

  • If you are using a statically typed language like Java and C# 
    (no shame in there! :D)
  • If you have a customer facing/sync application
  • If your request volume is low or sparse
  • Once you deploy a new version (all containers are destroyed)

What are the factors which increase the cold-start time?

  • The language choice
  • Memory size
  • Code size
  • VPC
  • HTTPS calls
  • Things that require classpath scan (Java)

What are the solutions to this problem?

First, accept that you can’t guarantee that you won’t experience cold-starts. The ultimate solution must come from the cloud provider. We can only try to improve.

  • Do nothing if it is not a huge problem (recommended)
  • Wait for AWS to improve it
  • Increase memory (and pay more)
  • Do some warm-up

Good links about cold-starts

More by Serhat Can

Topics of interest

More Related Stories