API网关+ Lambda + VPC超时问题 [英] API Gateway+Lambda+VPC timeout issue

查看:57
本文介绍了API网关+ Lambda + VPC超时问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,能否请您解决下一个问题:我有一个API网关+ Java Lambda处理程序.此Lambda使用httpconnection获取一些Internet REST API.

Good morning, Could you please help us with next problem: I have an API Gateway + Java Lambda Handler. this Lambda uses httpconnection to get some Internet REST API.

当我们在不使用VPC的情况下使用此Lambda时,效果很好.但是当我们将VPC与已配置的Internet访问一起使用时-有时Lambda会因超时错误而失败.它在所有请求的20%(80%的请求工作正常)中失败,并在日志中显示下一个错误.

when we use this Lambda without VPC it works fine. but when we are using VPC with configured internet access - sometimes Lambda fails with timeout errors. it fails in 20% of all requests (80% requests works fine) with next errors at log.

REPORT RequestId: 16214561-b09a-11e6-a762-7546f12e61bd Duration: 15000.26 ms Billed Duration: 15000 ms Memory Size: 512 MB Max Memory Used: 47 MB

09:57:49
2016-11-22T09:57:49.245Z 16214561-b09a-11e6-a762-7546f12e61bd Task timed out after 15.00 seconds

根据我的日志,lambda无法发送GET请求.我不确定问题出在哪里.是Lambda问题,VPC问题还是某些配置问题.另外,我确实尝试了许多不同的REST Api端点,因此,这绝对不是端点问题.

According to my logs lambda cannot send GET request. I'm not sure where the problem at. Is this Lambda issue, VPC issue or some cofiguration issue. Also I did try many different REST Api endpoints, so it's definetly not an endpoint issue.

感谢任何帮助.

推荐答案

将Lambda函数放入VPC时,将无法访问VPC之外的任何内容.为了使Lambda功能能够访问VPC之外的资源,您必须向VPC添加NAT网关.

When you place a Lambda function inside your VPC it will not have access to anything outside the VPC. To enable your Lambda function to access resources outside the VPC you have to add a NAT Gateway to your VPC.

这篇关于API网关+ Lambda + VPC超时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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