Lambda and VPCs

lambda

#1

I’ve read that cold starts for a VPC can take 10 seconds. It’s important to have my RDS instance behind a VPC for security. 10 seconds is unacceptable for HTTP requests.

Is there a solution I’m missing here? Are default VPCs faster?


#2

Correct

You can try keeping your Lambda warm by implementing a ping function then calling it regularly. This reduces the chance of someone hitting a cold start in some circumstances.

No.


#3

This only helps that one instance. The minute scale is needed beyond that request time starts climbing again.

Bummer, I think I’ll look into dropping the VPC.

Thanks for the response.


#4

The 10 second cold start usually only applies to the first few concurrent functions. After that, Lambda has already allocated container space that is connected to your VPC. If you have significant load, the cold start times drop dramatically as ENIs are shared between containers. Also note that VPC Lambdas stay warm for a minimum of 15 minutes, as opposed to 5 minutes for non-VPC ones. This means that intermittent spikes that scale up your Lambdas will most likely be warm and ready to respond on subsequent spikes. This dramatically reduces cold starts.

If you absolutely need to keep VPC Lambdas warm, use this: https://github.com/jeremydaly/lambda-warmer

It was endorsed by Chris Munns over at AWS since it follows all of their recommendations. It can even be used to keep several concurrent functions warm.