API Calls from lambda in my VPC to external URL are 2 minutes long

0

When I call external API from lambda in my VPC it takes 2m10s to get the answer from the service, does not matter the memory configuration. I was performing those calls locally and there's no delay at all. Lambda is hooked up to the API Gateway so it times out. It's weird because subsequent calls to the same API are executed without that overhead.

2개 답변
0

When you say "perform those calls locally" I assume you put an EC2 instance on the same subnets that you have configured for Lambda? If not, that's the test you need to run.

The usual cause here is that the Lambda subnets (plural is important!) do not have the same connectivity as the rest of the VPC. Another common cause is that one Lambda subnet is correct and another is not. So for those subnets, check route tables, NACLs, DHCP and DNS settings.

For a first-call delay like that I'd highly suspect that DNS is an issue. Either the DNS server that the Lambda function is using is not responding correctly so it is falling back to a secondary (although that shouldn't take two minutes); or the endpoint that you're calling is trying to do a reverse DNS lookup on the Lambda IP (public IP - whatever is assigned to NAT Gateway or your NAT device) and it eventually times out and on the next call it has given up. So you might also look at setting a specific reverse IP lookup record.

profile pictureAWS
전문가
답변함 일 년 전
0

Are you working in an environment where network appliances inspect traffic routed to the internet? I've seen something similar, though not nearly as long when communicating with internal resources due to the amount of traffic inspection.

profile picture
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠