View a markdown version of this page

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

Cost optimization

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, see Amazon API Gateway pricing. You might 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 APIs, the original approach required a Network Load Balancer (VPC link V1). With VPC links V2, you can now use either an ALB or an NLB. The NLB cost is billed per hour, so while a VPC link remains active, you pay for the NLB. The ALB cost is billed per ALB running per hour and per Load Balancer Capacity Units (LCU) used per hour. For a use case where requests to a REST 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. See 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 NLB running per hour and Network Load Balancer Capacity Units (NLCU) used per hour. 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.
Private integration (ALB) Billed per ALB running per hour and Load Balancer Capacity Units (LCU) used per hour. If there is a backend service hosted in ECS or other target such as EC2 instances that can be directly integrated with ALB according to the architecture patterns.
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.