为什么AWS Lambda在VPC中起作用有时会超时,有时会正常工作? [英] Why AWS lambda functions In a VPC sometimes timeout and sometimes work fine?

查看:178
本文介绍了为什么AWS Lambda在VPC中起作用有时会超时,有时会正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VPC中有一些lambda函数,其中一些需要Internet才能工作,所以我添加了一个NAT实例(t2.micro),问题是我有一些函数有时可以工作,有时可以超时.例如,一个调用FB API的函数有80%的时间工作而20%的超时时间.另一个功能是使用boto3在50%的超时时间内创建竞价型实例,并且日志会提供给我.

I have some lambda functions in a VPC, some of them need Internet to work so I added a NAT instance (t2.micro) and the problem is that I have some functions sometimes work and sometimes timeout. For example a function that call FB API 80% of the time work and 20% timeout. Another function is using boto3 to create a spot instance 50% of the time timeout and the logs give me.

2018-07-16T06:35:55.909Z 421f98dd-88c2-11e8-913a-63c8d6f276f3任务在100.10秒后超时

2018-07-16T06:35:55.909Z 421f98dd-88c2-11e8-913a-63c8d6f276f3 Task timed out after 100.10 seconds

每当我重新部署无服务器项目时,我都会遇到此问题.

Whenever I redeploy my serverless project I face this problem.

我增加了超时限制和内存,但是我遇到了同样的问题,我确定可以访问Internet,但是某些lambda函数超时了.

I increased the timeout limit and the memory but I have the same problem I'm sure that there is access to Internet but some of the lambda functions timeout.

您认为问题出在哪里? 谢谢

What do you think the problem is ? Thanks

推荐答案

在VPC中使用Lambda的地方,我已经有了这个功能(因此有一个NAT网关和Internet网关).

I've had this where I am using the Lambda in a VPC (and therefor have a NAT Gateway and Internet Gateway in place).

我无意中选择了Lambda的所有子网(包括公共子网)来运行,而它只能从私有子网访问Internet.

I had inadvertently selected all subnets (including the public one) for the Lambda to run in, whereas it will only have access to the internet from the private subnets.

取消选择公共子网并保存,您应该解决问题.

Deselect the public subnet and save and you should solve your problem.

这是我使用的知识库文章的链接- https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/

Here's a link to the knowledgebase article I used - https://aws.amazon.com/premiumsupport/knowledge-center/internet-access-lambda-function/

这篇关于为什么AWS Lambda在VPC中起作用有时会超时,有时会正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆