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 réponse
4
Réponse acceptée

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
répondu il y a 2 ans
profile picture
EXPERT
vérifié il y a 3 mois
  • 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

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions