Distributing Traffic to Lambda equally to multiple NAT gateways

0

We have a use case where we need multiple NAT gateways so that the we call some external world api with multiple public IPs(because a single use of IP can be blocked due to high traffic). I have created a vpc with private subnets and public subnet associated with each AZ, and a unique NAT gateway for each AZ. so i have 3 private subnet, 3 public subnet and 3 NAT Gateways.

I have created a lambda and associated all 3 private subnets to that. As per AWS documentation: "When an Amazon VPC-connected Lambda function makes requests, it randomly selects an associated subnet.". Can we somehow force some thing like load balancer which will distribute the request equally to each subnet. So that it would go through each public IP equally.

1개 답변
1
수락된 답변

Hi,

No, you cannot control how to balance traffic natively with lambda.

I have seen cases where for instance, an API Gateway would have an Application Load balancer behind it. Then the ALB would have target groups pointing to lambdas, but at least you can have ALB deciding the load (round robin, https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/how-elastic-load-balancing-works.html).

With that approach you get some kinda of control, thought at subnet level lambda May still select randomly the subnet.

Hope it helps ;)

profile picture
전문가
답변함 일 년 전
  • Even if you use an ALB, when ALB invokes the Lambda function, the Lambda service will choose the subnet and you have no control over that.

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

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

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

관련 콘텐츠