How to Calculate the Cost of Deploying Open-Source API Gateway on AWS?

Yilia LinYilia Lin
4 min read

Choosing Between Open-Source API Gateway and Amazon API Gateway

When developers are faced with the decision of whether to use a fully managed service like Amazon API Gateway or an open-source API gateway solution, several crucial factors come into play. This article examines these considerations to assist engineering professionals in making an informed choice.

  • Multi-Cloud and Hybrid Environments: Amazon API Gateway excels in integrating with other AWS services like Lambda but is tightly coupled with the AWS ecosystem. Conversely, open-source gateways offer greater flexibility, enabling deployment across GCP, Azure, private clouds, or hybrid environments of these environments.

  • Extensive Customization Needs: For projects requiring highly customized API functionality beyond the scope of Amazon API Gateway, open-source solutions provide greater control and the ability to customize gateways to meet specific requirements.

  • High API Request Volume and Cost: As API traffic grows, the cost of Amazon API Gateway may become significant. In contrast, open-source gateways can be a more cost-effective option, especially for high-traffic scenarios.

  • Optimizing Performance and Latency: Open-source options provide greater control over performance and latency. Engineers can directly benchmark and select optimized open-source gateways (e.g., Apache APISIX, Kong, Envoy, Tyk) to suit their applications.

While Amazon API Gateway offers a convenient and well-integrated solution within the AWS ecosystem, open-source alternatives provide greater flexibility, customization, and lower costs, particularly suitable for complex or high-traffic use cases.

Factors to Consider in Calculating Costs

API gateway plays a crucial role in managing traffic between client applications and backend services, serving as middleware with two main components: the data plane and the control plane.

Data Plane: Scaling with Traffic

The data plane, responsible for handling incoming API requests, performs tasks like routing, authentication, and data transformation critical for ensuring smooth system operation. As API call volumes increase, the data plane requires more computing resources to maintain optimal performance. Therefore, accurately estimating API call volume is crucial for determining the number of data plane instances needed to ensure the system can effectively handle requests and maintain high availability.

Control Plane: Planning for High Availability

The control plane acts as the central hub of the API gateway, managing configurations and policies, and guiding how the data plane processes requests. Unlike the data plane, the resource requirements of the control plane are not directly related to API call volume. However, ensuring the high availability of the control plane is crucial. Therefore, users need to plan control plane resource allocation based on desired redundancy levels and uptime requirements.

Monitoring and Logging costs

  • Amazon API Gateway: Integrated with AWS CloudWatch, providing monitoring and logging functionalities incurring additional costs. When considering the overall cost of Amazon API Gateway, evaluating monitoring and logging requirements is essential.

  • Open-Source API Gateway: Monitoring and logging solutions typically need separate consideration. Cost-effective options like Prometheus and Grafana can be considered, or users can opt for managed log management services offered by cloud providers.

Cost Estimation Example: Estimating Costs for Handling 10 Billion API Requests

Using Amazon API Gateway

Let’s estimate the monthly cost of handling 10 billion API requests with Amazon API Gateway. Please note that the following are estimations, and actual costs may vary based on specific configurations and usage patterns.

Assumptions:

  • Number of API requests per month: 10 billion

  • Average request/response payload size: 1 KB (1,024 bytes)

In the above scenario, the monthly cost is $9,030.

Using Open Source API Gateway Apache APISIX

Assuming 20 days per month, with 12 hours of runtime per day, let’s calculate the number of requests the API gateway needs to handle these 10 billion API calls.

10000000000 / 20.0 / 12 / 3600 = 11574.074074074073

The calculation shows that approximately 11,000 API requests need to be processed per second. We can employ two data planes, each configured with 4 vCPUs.

11574.074074074073 / 4 / 2 = 1446.7592592592591

In this scenario, each CPU processes approximately 1400 API requests per second, which is an effortless task for an API gateway like Apache APISIX that can handle tens of thousands of requests per second.

In addition, the same computing resources are allocated to the control plane.

The monthly cost is $195.06.

By comparing the costs of handling 10 billion requests between Amazon API Gateway and open-source API gateway, the ratio is 9030 / 195.06 = 46.29344816979391, indicating that Amazon API Gateway’s cloud resource cost is approximately 46 times higher than that of the open-source API gateway.

However, using an open-source API gateway does not eliminate software costs. Engineers also need to consider the costs of upgrades, and maintenance, as well as purchasing technical support and commercial products.

Conclusion

By comparing Amazon API Gateway and open-source API gateway Apache APISIX through practical examples, we find that open-source API gateways can significantly reduce enterprise software costs. Although Amazon API Gateway offers a convenient and well-integrated solution within the AWS ecosystem, open-source alternatives excel in flexibility, customization, and cost-effectiveness, particularly suitable for complex or high-traffic usage scenarios.

1
Subscribe to my newsletter

Read articles from Yilia Lin directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Yilia Lin
Yilia Lin

Technical Writer at API7.ai