You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lambda Function URLs are great to replace API Gateway. However they don't have custom domains. That means you need CloudFront (for the custom domain). That works for websites right now (we already have CloudFront there), but not APIs (which don't use CloudFront).
How about dropping API Gateway entirely (for the docs/examples, Bref would still work with it of course) and go full Lambda Function URLs + CloudFront.
We would have 3 different scenarios:
No custom domain: Lambda Function URL
That would be super cheap for testing and deploying preview URLs.
Website: CloudFront -> Lambda Function URL
Same as today, no changes except API Gateway is removed.
API: CloudFront -> Lambda Function URL
graph LR;
CloudFront-->Lambda(Lambda Function URL);
Loading
Pros:
Slightly simpler serverless.yml config
Websites would be cheaper to host (no API Gateway)
Possibly slightly faster first deployments (no API Gateway to setup/deploy)
Slightly less HTTP latency as Function URLs are slightly faster than API Gateway
Simpler infrastructure, always the same regardless of the use case
CloudFront takes care of redirecting HTTP -> HTTPS (API Gateway doesn't), that's a win!
Longer HTTP timeouts!
Cons:
Longer deployment time when you want a custom domain on an API (for websites we already deploy CloudFront, so it wouldn't be slower)
The Lambda Function URL would be publicly (on top of the CloudFront URL), making it private would require some more effort (custom header or using Lambda@Edge)
Cannot use API Gateway features: that would still be possible, but be advanced, which makes sense to me. We don't use API Gateway features in Bref docs.
Is CloudFront more expensive than API Gateway for APIs?
I did rough calculations and it seems that it could be actually cheaper for 99% of use cases! CloudFront has a much bigger free tier (10 million HTTP requests, compared to 1 million for API Gateway). Beyond that, it seems to be about the same price, but even at this scale it can be optimized on a case by case basis.
Summary:
Running APIs and websites might be simpler, faster and cheaper!
Right now, Bref's docs/examples/defaults deploy:
For websites, it deploys:
Lambda Function URLs are great to replace API Gateway. However they don't have custom domains. That means you need CloudFront (for the custom domain). That works for websites right now (we already have CloudFront there), but not APIs (which don't use CloudFront).
How about dropping API Gateway entirely (for the docs/examples, Bref would still work with it of course) and go full Lambda Function URLs + CloudFront.
We would have 3 different scenarios:
That would be super cheap for testing and deploying preview URLs.
Same as today, no changes except API Gateway is removed.
Pros:
serverless.ymlconfigCons:
I did rough calculations and it seems that it could be actually cheaper for 99% of use cases! CloudFront has a much bigger free tier (10 million HTTP requests, compared to 1 million for API Gateway). Beyond that, it seems to be about the same price, but even at this scale it can be optimized on a case by case basis.
Summary:
Running APIs and websites might be simpler, faster and cheaper!
Am I missing anything? Feedback is welcome 🙏