4 ways of executing Lambda function via HTTP endpoint - a comparison
Pawel Zubkiewicz
Posted on April 8, 2022
Recent release of Lambda Function URLs is a great reason to write up a small summary describing possible ways of executing Lambda functions over HTTP endpoints.
There are four ways to invoke a Lambda function over HTTP:
- API Gateway REST API
- API Gateway HTTP API
- Application Load Balancer
- NEW Lambda Function URLs
Once again, AWS released new functionality, but it's up to us how, and more importantly, when we are going to use it. I hope this brief comparison will give you a head start, and make it easier to decided which option to select.
Comparison table
API GW REST | API GW HTTP | ALB | Lambda URL | |
---|---|---|---|---|
Authentication | AWS_IAM, Custom authorizers | AWS_IAM, Custom authorizers, JWT | Social and corporate Identity Providers | AWS_IAM |
CORS | ✅ | ✅ | CORS headers need to be provided in a response from Lambda function. | ✅ |
Custom domain names | ✅ | ✅ | ✅ | ❌ |
Timeout [seconds] | 29 | 30 | 60 default, max 4000 (The load balancer waits until your Lambda function responds or times out.) | Equal to Lambda's timeout, max 900 |
Throttle quota | 10,000 requests per second (RPS) per region shared among other resources | 10,000 requests per second (RPS) per region shared among other resources | ||
Pricing | First 333 million = $3.5 | First 300 million = $1.0 | Complex to explain, cheaper than API GW over 500,000 requests per day | Free, CloudFront proxying to Lambda URL = ~ $1.0 to $1.2 |
Payload size | API GW 10 MB, but Lambda's is 6 MB. | API GW 10 MB, but Lambda's is 6 MB | 1 MB | 6 MB |
Validation | ✅ | ❌ | ❌ | ❌ |
Data transformations | ✅ | ❌ | ❌ | ❌ |
API Proxy | ✅ | ✅ | ❌ | ✅ |
API caching | ✅ | ❌ | ❌ | ❌ |
Private endpoints | ✅ | ❌ | ❌ | ❌ |
Lambda alias support | ✅ | ✅ | ✅ (via target groups) | ✅ |
Additional info | Not serverless. AWS WAF supported | Custom domain are not supported but can be mapped via CloudFront | ||
Short summary | Expensive but feature-rich | Cheaper and faster. Probably you should use that in enterprise software. | Makes sense for huge scale because of pricing. | Free, simple and easy. Tiny projects & automations. |
Disclaimer
This summary was created to the best of my knowledge. If you found some mistakes, or think that something important should be added that to it, please let me know.
Sources
- https://aws.amazon.com/blogs/aws/announcing-aws-lambda-function-urls-built-in-https-endpoints-for-single-function-microservices/
- https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout
- https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html
- https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html
- https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html
- https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-authenticate-users.html
- https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html
- https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-http.html
- https://www.serverless.com/guides/aws-http-apis
- https://www.learnaws.org/2020/09/12/rest-api-vs-http-api/
- https://blog.tinystacks.com/aws-api-gateway-rest-http
- https://www.linkedin.com/feed/update/urn:li:activity:6917825431224090624/
- https://blog.tinystacks.com/battle-of-the-serverless-api-routers-alb-vs-api-gateway-pricing
💖 💪 🙅 🚩
Pawel Zubkiewicz
Posted on April 8, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.