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

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则