Cost optimization
Infrastructure cost is an important factor when choosing application architectures. For application use cases that require REST or HTTP APIs, HTTP APIs offer lower pricing tiers. For existing REST APIs, consider migrating to HTTP APIs. When planning for migration, refer to Choosing between HTTP APIs and REST APIs to compare HTTP API and REST API supported features.
For serverless API cost optimization, Serverless Application Lens covers cost optimization best practices such as cost-effective resources, matching supply and demand, expenditure awareness, and optimizing over time in Cost Optimization Pillar section.
For REST and HTTP API pricing, refer to
Amazon API Gateway pricing
Table 4 – REST and HTTP API pricing
Endpoint type | Pricing |
---|---|
REST |
Free tier: one million API calls per month for up to 12 months. API calls:
Caching: Billed per hour based on the cache memory size (not eligible for free tier) |
HTTP |
Free tier: one million API calls per month for up to 12 months. API calls (us-east-1);
HTTP APIs are metered in 512 KB increments. |
For private integration with REST and WebSocket APIs, a Network Load
Balancer is required. The NLB cost is billed per hour, so while a
VPC link remains active, you pay for the NLB. For a use case where
requests to a REST or HTTP API are made infrequently, such as five
requests per day, a VPC-enabled Lambda function can be a more
cost-effective option. VPC-enabled Lambda functions can access VPC
resources. Because Lambda bills per request and code execution
duration, using a VPC-enabled Lambda function can cost less. Refer
to
Elastic Load Balancing pricing
Table 5 – Private integration vs. Lambda pricing
Integration/Lambda | Cost | Use cases |
---|---|---|
Private integration (NLB) | Billed per hour regardless of use. | If there is a backend service hosted in ECS or other target such as EC2 instances that can be directly integrated with NLB, using an NLB to route traffic simplifies the architecture. |
VPC-enabled Lambda | Lambda pricing is billed on-demand, so if a Lambda function is not used, there is no charge. | If there is any private resource like RDS which cannot be directly accessed by NLB, using a VPC-enabled Lambda function is a good alternative. |