doofus
doofus

Reputation: 334

AWS - why application load balance to target group of Lambda

I understand an AWS application load balancer can have either:

Since Lambda has their own system of concurrency (which already also has provisioned concurrency) why would you need to load balance to Lambda?

If the application load balancer can be used for routing by URL to different Lambda functions then wouldn't API Gateway be the better choice?

Upvotes: 3

Views: 2668

Answers (3)

Gregory
Gregory

Reputation: 195

For example in my architecture I have developed a chatbot making API calls to Azure ChatGPT-4, the API calls are made by 5 different Lambda functions load balanced by an Amazon ALB. Why am I using 5 different Lambda functions? Because each Lambda function is targeting a different Azure ChatGPT-4 endpoint, each in different Azure Regions.

Upvotes: 1

Marcin
Marcin

Reputation: 238727

The support of ALB for lambda is not for its concurrency. The support is to enable your lambda function to be available as a web service. Lambda function, by default, can't be invoked from the internet. To make it usable as a web application, one way is through ALB (other is API gateway).

Thus, often lambda with ALB will be used as part of your full web application, running along side your EC2 instances. But you can setup your ALB to have one its path handled by lambda function. Often such lamnda function are used as proxies, to fetch external API, or provide access which would be troublesome to implement in EC2 instances.

Upvotes: 4

Nicholas Rees
Nicholas Rees

Reputation: 753

Long answer:

https://serverless-training.com/articles/api-gateway-vs-application-load-balancer-technical-details/

Shorter answer:

“If you are building an API and want to leverage AuthN/Z, request validation, rate limiting, SDK generation, direct AWS service backend, use #APIGateway. If you want to add Lambda to an existing web app behind ALB you can now just add it to the needed route.”

Shortest answer:

You are correct. Generally API Gateway is a better choice.

Upvotes: 1

Related Questions