Replacing API Gateway with Application Load Balancer could save you thousands of dollars on your bill every month. API Gateway is a great product, and offers a generous free tier. For personal projects and small sites that need one or more serverless APIs, it may be all you ever need. But, if your site is larger and gets a lot of traffic to your APIs, API Gateway might be the least cost-effective serverless service you use.
At re:Invent 2018, AWS gave us a new way of using Lambda functions to power APIs or websites: an integration with their Elastic Load Balancing Application Load Balancer. Previously, the go-to way of powering an API with Lambda was with API Gateway. What are the differences in the two? Can you have one Lambda function that works for both API Gateway and Application Load Balancer? When should you choose one over the other?
In less than ten minutes you can have a Lambda-powered API that is integrated with both API Gateway and Application Load Balancer. How? I will walk you through deploying a set of example services that I built that demonstrate using Application Load Balancer with your Lambda functions. We’ll first create an API with API Gateway, and then create an application load balancer with all of its pre-requisites (a VPC, etc), enabling you to call the same function using either the API Gateway endpoint or the application load balancer.