Cost optimization - Best Practices for Designing Amazon API Gateway Private APIs and Private Integration

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. You may incur additional charges if you use API Gateway in conjunction with other AWS services, or transfer data out of AWS.

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:

  1. First 333 million requests (per month): $3.50 (per million)

  2. Next 667 million requests (per month): $2.80 (per million)

  3. Next 19 billion requests (per month): $2.38 (per million)

  4. Over 20 billion requests (per month): $1.51 (per million)

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);

  1. First 300 million requests (per month): $1.00 (per million)

  2. 300+ million requests (per month): $0.90 (per million)

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 and AWS Lambda 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.