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

查看:41
本文介绍了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 和配置的互联网访问时 - 有时 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天全站免登陆