Case study

CategoryArticles

Amazon API Gateway Pricing: Six Tips to Control the Cost

In this article, you will learn:

Amazon API Gateway is the Amazon Web Services(AWS) solution for connecting an API to the public Internet or a private network. In a lot of cases, it’s an important piece of AWS architecture and it’s therefore equally important to understand its pricing. API Gateway is often also the most expensive piece of AWS serverless infrastructure, though depending on how it is used and optimized, costs can be kept very low.

In this blog post, we will cover AWS’s API Gateway pricing, the free tier, and how to optimize its costs.

Amazon API Gateway free tier

API Gateway is billed based on the usage:

  • A number of requests per month to your API.
  • Connection minutes for Websocket APIs.
  • Cache memory size and minutes of its actual usage.
  • Additional charges, such as Data transfer out (DTO).

API Gateway free-tier

API Gateway provides a free tier that is available for 12 months after the initial sign-up date. When this 12-month term expires or if your application use exceeds the tiers, you simply pay standard rates.

The monthly free tier includes:

  • 1 million REST API calls
  • 1 million HTTP API calls
  • 1 million messages
  • 750,000 connection minutes

Amazon API Gateway on-demand pricing

HTTP APIs

HTTP APIs are charged based on the number of API calls made. HTTP APIs calls are metered in 512 KB increments, so for example, 513 KB is metered as two requests.

This is the pricing in the Europe (Ireland) region:

REST APIs

REST APIs are also charged based on the number of API calls made. This is the current pricing in the Europe (Ireland) region.

Websocket APIs*

Websocket APIs are charged based on the number of messages sent and received as well as the total number of connection minutes. Messages are metered in 32 KB increments, so for example, 33 KB is metered as two requests.

The table below shows the current pricing for messages in Europe (Ireland):

Connection Minutes are charged at $0.25 per million connection minutes.

API gateway cache pricing

REST APIs provide the ability to provision a dedicated cache to improve performance. The pricing for the cache is based on the amount of memory provisioned.

Additional charges

There might also be other additional charges depending on how the API Gateway is being used such as:

  • Data transfer: If you transfer data to the public Internet, you will be charged at the EC2 data transfer rate(0.09$ per GB). Learn more about it in the cost optimization tip.
  • Cloudwatch: Includes pricing for metrics and dashboards.
  • AWS Lambda and other services.

Six Amazon API Gateway cost optimization tips

The costs of Amazon API Gateway are often higher than of a Lambda itself and while these costs are adequate for the specific features (e.g. authentication management, caching, request/response transformation, proxying), there are a couple of ways to generally save on its costs or even not use it at all and choose other services from AWS.

40_api-gateway-pricing-1.png

1. Right type of API gateway

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

For existing REST APIs, consider migrating to HTTP APIs. When planning for migration, see Choosing between HTTP APIs and REST APIs to compare HTTP API and REST API supported features.

2. API Gateway integration feature

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.

3. Cognito authentication

When your front-end is the only consumer of the backend APIs, you can leverage Cognito to obtain IAM credentials for your users. They can then invoke your Lambda functions safely using the AWS Javascript SDK and the temporary credentials. This solution allows you to achieve both authentication and authorization via IAM, avoiding the need for an API Gateway at the cost of reduced functionalities (you have to prepare your request on the frontend side, and also manage responses and errors in your Lambda code).

4. Replace API Gateway with ALB (Application Load Balancer)

As your application scales, consider replacing the API Gateway with an ALB (Application Load Balancer). Since ALB supports triggering the Lambda function, ALB could be a better choice for cost savings unless you’re using Amazon API Gateway’s unique features, such as authentication management, caching, and request/response transformation.

5. Reduce unnecessary API calls

Remove any unnecessary API calls and optimize your application to prevent them. As your application evolves we often end up with redundant and unnecessary API calls and these can add significantly to our costs.

6. Reduce data transfer costs

If you transfer data from API Gateway to the public Internet, you will be charged at the standard data transfer rate (0.09$ per GB).

40_api-gateway-pricing-2.png

At StormIT we have helped many customers to optimize their overall spending on data transfer (egress bandwidth) from different industries with a broad range of use cases from web applications and blogs to media streaming and gaming.

Using a content delivery network such as Amazon CloudFront is essential to keeping data transfer costs low. CloudFront moves your most accessed content to the “front” of the AWS network (i.e., PoPs), ensuring fast delivery to your end users. Data transfers into CloudFront from other AWS resources (S3, EC2, API Gateway) are free.

40_api-gateway-pricing-3.png

Obviously, every project/case is unique, but we are confident that by smartly using CloudFront it is possible to achieve overall lower costs and improved performance.

Conclusion

Amazon API Gateway is one of the most popular serverless services from AWS. Customers are charged based on a pay-as-you-go model which is very cost efficient for some customers. This blog post introduced Amazon API Gateway pricing and should help you with the cost optimization of this service.

Banner AWS Summit

Similar blog posts

See all posts
CategoryNews

StormIT Achieves AWS Service Delivery Designation for AWS WAF

StormIT is excited to announce that we have received AWS Web Application Firewall (WAF) Service Delivery designation.

Find out more
CategoryCase Studies

Windy - The Extraordinary Tool for Weather Forecast Visualization

StormIT helps Windy optimize their Amazon CloudFront CDN costs to accommodate for the rapid growth.

Find out more
CategoryCase Studies

AWS Well-Architected Review Series: Healthcare Industry Client

Transforming healthcare AWS operations with StormIT using our expertise and the AWS Well-Architected Framework. Learn more.

Find out more
CategoryCase Studies

Srovnejto.cz - Breaking the Legacy Monolith into Serverless Microservices in AWS Cloud

The StormIT team helps Srovnejto.cz with the creation of the AWS Cloud infrastructure with serverless services.

Find out more
CategoryCase Studies

Microsoft Windows in AWS - Enhancing Kemper Technology Client Solutions with StormIT

StormIT helped Kemper Technology Consulting enhance its technical capabilities in AWS.

Find out more
CategoryNews

Introducing FlashEdge: CDN from StormIT

Let’s look into some features of this new CDN created and recently launched by the StormIT team.

Find out more