Lambda+ALB vs Lambda+API GW

0

Lambda can be invoked by http endpoint via ALB as per the links pasted below. On the other hand, API GW can also be used to invoke the lambda (this approach is recommended widely over online). When to use ALB and when to use API GW ? Are there any recommendation on this ? Are there any key differentiating factors to pick one over the other ?

Please find the few below differences that could figure out. (Pls correct me if i am wrong)

  1. API GW aggregates multiple service end points or multiple lambdas whereas one ALB can point to only one lambda.
  2. All requests through that ALB will go the same lambda and the code inside the lambda need to identify which functionality to execute.

ALB Links

  1. https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html
  2. https://aws.amazon.com/blogs/networking-and-content-delivery/lambda-functions-as-targets-for-application-load-balancers/
1개 답변
4
수락된 답변

In case of relative low traffic (around 5 million requests per month), I would discourage the use of ALB + Lambda for services that are more normal REST API and when you don't need any of functionalities offered by ALB (like the openID authentication, etc), as the cost of having ALB+Lambda is much higher for .

Anyway, you could use ALB + Lambda, when you are already using ALB for your EC2 instances. For example you have a domain for your application "www.myapp.com" pointing to your ALB, and you want to extend some of the functionalities of your domain using lambda. You can create new ALB targets pointing to lambda. For example you can create the target "/billing" to point to lambda, and the rest of the request to go to EC2, doing this you spread the traffic of your domain between different backends.

Major differences between API GW and ALB

API GWALB
Request/secondsLimited to 10000virtually unlimited
IntegrationLambda and many others AWS servicesEC2, ECS, private IP addresses, Lambda
RoutingOnly on path basedPath base and others like Requesters IP, Http Headers, Http method, etc
CostPay per requestPay by time + Request (LCU)
Access LoggingCloudwatchS3 bucket
Miki
답변함 2년 전
profile picture
전문가
검토됨 4달 전
  • I'd argue that, from a cost optimization perspective, there is a break-even point when one will cost more than the other based on # of requests.

  • Thanks mreferre, you are right, I updated the response

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

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

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

관련 콘텐츠