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
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 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
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. |