How to save costs on your API Gateway solution using Cloudflare Workers

Guest Author
8 min readadvanced
--
View Original

Overview

This article discusses how Speedchecker transitioned their API gateway from the Kong open-source solution to Cloudflare Workers, achieving a tenfold reduction in costs. It highlights the challenges faced with the original setup and the benefits of using Cloudflare Workers for API management, including cost-effectiveness and enhanced security.

What You'll Learn

1

How to reduce API gateway costs using Cloudflare Workers

2

Why migrating from an open-source API gateway to a serverless solution can improve reliability

3

When to consider using Cloudflare Workers for API management

Prerequisites & Requirements

  • Understanding of API management concepts
  • Familiarity with Cloudflare platform(optional)

Key Questions Answered

How did Speedchecker reduce their API gateway costs?
Speedchecker transitioned from using the Kong open-source API gateway to Cloudflare Workers, which allowed them to reduce their costs from $300 for Azure API management to just $25 for Cloudflare Workers, achieving a tenfold reduction in expenses.
What challenges did Speedchecker face with their original API gateway solution?
Speedchecker encountered several challenges with Kong, including scalability issues, complex replication setups, vulnerability to DDoS attacks, and increased administrative overhead, which prompted their migration to Cloudflare Workers for a more robust solution.
What are the benefits of using Cloudflare Workers for API management?
Cloudflare Workers offer attractive per-request pricing, powerful DDoS protection, and eliminate the need for separate DNS failover and health monitoring, making it a cost-effective and reliable option for API management.
What is the migration process to Cloudflare Workers?
The migration process involved enabling Cloudflare Workers on a staging domain, testing API behavior, and gradually bringing API calls online while monitoring for errors, ensuring a seamless transition without requiring users to change their API code.

Key Statistics & Figures

Cost of API management
$25
Cost for 30 million API requests per month using Cloudflare Workers, compared to $300 for Azure API management and $2500 for Apigee.
Cost reduction factor
10
Speedchecker reduced their API gateway costs by a factor of 10 by switching to Cloudflare Workers.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Backend
Cloudflare Workers
Used for managing API requests and providing a cost-effective solution for API gateway functionality.
Backend
Kong
Originally used as the open-source API gateway before transitioning to Cloudflare Workers.
Backend
Azure API
Used for API management and authentication logic in conjunction with Cloudflare Workers.
Database
Postgresql
Used for better support of replication in the original Kong setup.

Key Actionable Insights

1
Consider transitioning to Cloudflare Workers if your API management costs are high.
If you're currently using a commercial API gateway or an open-source solution that requires extensive management, Cloudflare Workers can provide a more cost-effective and reliable alternative.
2
Implement a phased migration strategy to minimize disruption during API gateway transitions.
By enabling new solutions on staging environments and gradually rolling out changes, you can ensure that existing users experience minimal impact during the migration process.
3
Leverage existing vendor relationships to streamline your infrastructure.
Using Cloudflare for multiple aspects of your infrastructure can enhance performance and reliability while reducing the learning curve associated with adopting new technologies.

Common Pitfalls

1
Underestimating the complexity of API management when using open-source solutions.
Many developers may choose open-source solutions like Kong for cost reasons but may not account for the increased administrative overhead and complexity that can arise, leading to higher overall costs.
2
Failing to account for rate limits during migration.
During the migration to Cloudflare Workers, Speedchecker encountered issues with the Cloudflare firewall rate limiting API requests from the same IP, which could have been avoided with better planning and testing.

Related Concepts

API Management Strategies
Cost-effective Cloud Solutions
Serverless Architecture Benefits
Ddos Protection Mechanisms