Everything you need to know about cold starts in AWS Lambda

Written by serhatcan | Published 2018/06/01
Tech Story Tags: aws | aws-lambda | serverless | cold-start | cold-starts-in-aws-lambda

TLDRvia the TL;DR App

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

How does language, memory and package size affect cold starts of AWS Lambda?_Comparing the cold start times of AWS Lambda using different languages, memory allocation, and sizes of deployment…_read.acloud.guru

Dealing with cold starts in AWS Lambda_Suppose you want to buy a ticket to a concert of your favorite band and you know that the tickets are running out. You…_medium.com

Resolving Cold Start️ in AWS Lambda_Yes, I know cold starts are frustrating in lambda. Lets start the post with a formal introduction. AWS Lambda is…_medium.com

How to Warmup_This part is not mandatory but if you want to warmup your lambda functions follow along._docs.thundra.io


Published by HackerNoon on 2018/06/01