简体   繁体   English

VPC中Lambda的AWS替代产品

[英]AWS alternative for Lambda in VPC

Currently, I use AWS Lambda as backend behind AWS API Gateway with lambda proxy integration. 当前,我将AWS Lambda用作具有lambda代理集成的AWS API Gateway的后端。 Since my lambda function needs to have access to VPC resources, the lambda functions is in a VPC. 由于我的lambda函数需要访问VPC资源,因此lambda函数位于VPC中。 Unfortunately, lambda in VPC has extreme long cold start times (sometimes more than 10 seconds). 不幸的是,VPC中的lambda具有极长的冷启动时间(有时超过10秒)。 Therefore, I want to use alternatives for my lambda scripts which are written in python. 因此,我想对用python编写的lambda脚本使用替代方法。 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. 我考虑过的另一种方法是将弹性beantalk与python flask应用程序一起使用,并通过负载平衡器和VAPI 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? 是否有更好或更轻松的方法来使用python或node js脚本作为API网关后端,而不使用lambda并从脚本访问VPC组件,从而避免漫长的冷启动时间?

There's lots of really great articles about when to and when not to use a VPC for Lambda functions. 关于何时以及何时不将VPC用于Lambda函数,有很多非常好的文章。 A recent one by Yan Cui that looks at Lambda in VPC's in depth can be found here . 这里可以找到Yan Cui的最新作品,它深入研究了VPC的Lambda。

One strategy that we've successfully used is to keep our functions inside a VPC hot/warm. 我们成功使用的一种策略是将我们的功能保持在VPC内热/热。 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. 这里描述我们使用的策略但在较高级别上,您可以通过设置CloudWatch事件来保持函数的热/热状态,该事件将通过“ warmer”事件调用该函数,从而使该函数保持活动状态。 We do this with a number of functions, that operate inside a VPC, and this eliminates our cold-start issue. 我们通过在VPC内运行的许多功能来执行此操作,从而消除了冷启动问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM