Amazon API Gateway is the ultimate AWS solution for connecting AWS services to the public web. Since it’s an essentially piece of the Serverless stack, it’s important to understand and plan the associated costs. The calculator and tips below will help you get started.
Amazon API Gateway Cost Calculator
Number of Requests (per month):
Average Response Size (in KB):
Number of Messages (per month):
Connection Hours (per month):
AWS Free TierApply Free Tier
Average Monthly Spent
Additional Costs Associated with API Gateway
API Gateway is probably the most commonly used piece of infrastructure used alongside Lambda in AWS Serverless Architectures.
Here’s a breakdown of the most popular services it’s used alongside and brief notes around what you need to know in terms of effectively managing your costs:
- AWS Lambda
- AWS CloudWatch
- AWS PrivateLink
- Data transfer
AWS API Gateway Cost Optimization Tips – Best Practices
1. The number one thing you can do to optimize your API Gateway costs is to choose the right type of API Gateway. AWS offers both REST APIs and HTTP APIs. The HTTP API has more limited functionality but is also much cheaper. If it suits your needs you can save a lot of money by using it over the REST API.
2. Another great tip to save on your API Gateway bill is to use AWS service proxy integrations instead of combining a Lambda function to transfer/transform input data from the client. You can integrate API Gateway with other AWS services directly (e.g. Kinesis, DynamoDB, SQS, SNS, etc.) by using API Gateway integration features. The Serverless APIGateway Service Proxy plugin for the Serveless Framework makes this dead simple.
3. Remove any unnecessary API calls and optimize your application to prevent them. As our application evolve we often end up with redundant and unnecessary API calls and these can add significantly to our costs.
4. As your application scales, consider replacing API Gateway with ALB (Application Load Balancer). Since ALB supports triggering Lambda function, ALB could be a better choice for cost savings unless you’re using API Gateway’s unique features.
API Gateway Costs Monitoring
Costless provides granular cost management for API Gateway as well as other parts of your AWS stack. In addition to monitoring, Costless provides intelligent cost savings recommendations. You can try Costless for free on AWS Marketplace.
Frequently Asked Questions
- Is Amazon API Gateway free?
API Gateway is a paid service from AWS with a relatively generous free tier. The free tier includes:
- 1 million REST API calls
- 1 million HTTP API calls
- 1 million messages
- 750,000 connection minutes
While this isn’t enough for most production use cases, it is enough to try to the product out and for many use cases in which the endpoint does not get hit very often.
- Is API Gateway expensive?
API Gateway is often the most expensive piece on infrastructure in a Serverless Architecture, though depending on the way in which it is used it can still be very inexpensive. HTTP API calls are priced at $1 per million for the first 300 million requests, and then $.90 per million after that. REST API calls are considerably more expensive at $3.50 per million for the first 333 million requests (there are price breaks after that).
Is API Gateway the most cost-effective HTTP solution for a serverless app?
For basic HTTP endpoints powered by Lambda, API Gateway in the HTTP mode os the most cost-effective solution. You only pay for what you use and overall it’s quite inexpensive.