Yes, I know cold starts are frustrating in lambda. Lets start the post with a formal introduction. AWS Lambda is revolutionising the cloud. It is the swiss army knife for cloud architects and developers are creating interesting use cases day-by-day with the lambda.
Lambda is amazing. It is cost-efficient, infinitely scalable, serverless. But lets accept the fact that, they do have some drawbacks. One such is cold start ❄️. What is cold start? Lets go with definition given by Yan Cui.
A cold start occurs when an AWS Lambda function is invoked after not being used for an extended period of time resulting in increased invocation latency.
In case of a lambda powered web app, it affects the user experience when the backend takes lot of time to respond the user queries. In a production setup, lambdas are usually deployed within a VPC’s private subnet. This is because lambda has to access the database, which is usually deployed in private subnets. These lambdas inside VPC worsens the cold start. It quadruples the invocation latency.
Statistics behind Cold Start
Lambda is billed per invocation. It makes no sense for AWS to keep our functions warm all the time. Yan Cui has done an excellent work by using various strategies to understand the cold start in lambda. Here are…