MarcJ
MarcJ

Reputation: 97

AWS alternative for Lambda in VPC

Currently, I use AWS Lambda as backend behind AWS API Gateway with lambda proxy integration. Since my lambda function needs to have access to VPC resources, the lambda functions is in a VPC. Unfortunately, lambda in VPC has extreme long cold start times (sometimes more than 10 seconds). Therefore, I want to use alternatives for my lambda scripts which are written in python. One alternative I thought about is to use elastic beanstalk with a python flask application and integrate this via a load balancer and VPC Link to API Gateway.

Are there any better or easier approches to use python or node js scrips as API Gateway backend without using lambda and with access to VPC components from the scripts to avoid the long cold start times?

Upvotes: 1

Views: 280

Answers (1)

hephalump
hephalump

Reputation: 6164

There's lots of really great articles about when to and when not to use a VPC for Lambda functions. A recent one by Yan Cui that looks at Lambda in VPC's in depth can be found here.

One strategy that we've successfully used is to keep our functions inside a VPC hot/warm. The strategy we use is described here but at a high level you can keep your function hot/warm by setting a CloudWatch event that invokes the function with a "warmer" event, which causes it to stay active. We do this with a number of functions, that operate inside a VPC, and this eliminates our cold-start issue.

Upvotes: 1

Related Questions