Stop Paying $3.5/million requests for AWS API Gateway v1 or v2. Use Lambda Function URL instead

Phạm Văn Trung
4 min readNov 21, 2023

For businesses and developers utilizing Amazon Web Services (AWS), API Gateway has been a go-to choice for creating and deploying serverless HTTP applications. However, with charges of up to $3.5 per million requests for API Gateway v1 and still a considerable $1 per million requests for API Gateway v2, it’s important to evaluate cost-effective alternatives. Enter the world of Lambda Function URLs, a game-changer for those looking to optimize their costs without losing out on functionality.

Understanding Lambda Function URL

What Is Lambda Function URL?

AWS Lambda Function URLs are a newer feature from AWS that provides a straightforward and naturally integrated way to invoke your Lambda functions over HTTPS. It eliminates the need for a separate API management layer, like API Gateway, for certain use cases.

The Cost-Avantage

Unlike traditional API Gateway setups, Lambda Function URLs are free of extra costs, meaning no charges per million requests. This can lead to substantial savings, especially for applications with a high volume of traffic.

The cost reduces after using Lambda Function URLs.

Simplifying Architecture

Not only does this simplify your architecture by removing an additional component from the equation (and thus potentially reducing latency), but it also makes it more cost-efficient, especially since you’re no longer limited by the more expensive request fees associated with API Gateway v1 REST or the slightly cheaper API Gateway v2 HTTP endpoints.

Diving Into Pricing Models

When it comes to AWS services, understanding the pricing models is crucial. Here’s a deeper dive into the costs associated with API Gateway v1 REST, v2 HTTP, and Lambda Function URL:

  • API Gateway v1 REST: Charged at $3.5 per million requests, a major cost component for many applications.
  • API Gateway v2 HTTP: Offers a reduced cost at $1 per million requests, yet still presents a fee that can stack up with traffic.
  • Lambda Function URL: No additional charges per request. You only pay for the Lambda executions as per the usual pricing, which includes a generous free tier of 1 million requests and 400,000 GB-seconds of compute time per month.

When to Choose Lambda Function URLs

While the appeal of cost-saving is undeniable, Lambda Function URL isn’t always the perfect choice for every scenario. Here are a few situations where it shines:

  • Simple APIs or Background Processes: When your API is straightforward, with no need for extensive API management like throttling, key authentication, or Swagger support.
  • Microservices: If you’re running microservices that require direct invocation without the overhead of API Gateway.
  • Cost-Sensitive Projects: Ideal for projects where minimizing operational costs is a priority, such as startups and proof-of-concept applications.

However, keep in mind that some advanced features provided by API Gateway, like custom authorizers, request/response validation, and caching, are currently not available with Lambda Function URLs.

How to Get Started with Lambda Function URLs

Setting Up

Getting started with Lambda Function URLs is simple:

  1. Go to the AWS Management Console and navigate to your Lambda function.
  2. In the function’s configuration, enable the Function URL feature.
  3. Set the desired method (GET, POST, etc.) and CORS configuration if needed.
  4. Deploy the function, and you’ll receive a unique Function URL that’s ready to be used.

Deployment and Management

Management of Lambda Function URLs is straightforward. Update your functions as you would normally, and the URL stays the same, ensuring a seamless deployment process.

Performance Considerations

When comparing Lambda Function URL to API Gateway, bear in mind the performance implications:

  • Maximum HTTP Response Timeout: While API Gateway v1 and v2 have maximum timeouts of 29s and 30s respectively, Lambda Function URL supports up to a 15-minute timeout.
  • Latency: AWS documentation suggests added latency for API Gateway v1 and v2 (around 25ms and 15ms, respectively), whereas Lambda Function URLs tend to have a lower added latency.

Making the Switch

Are you ready to say goodbye to high costs per million requests and hello to savings with Lambda Function URL? Here’s your action plan:

  1. Evaluate: Assess your current use of API Gateway v1 or v2, and determine if Lambda Function URLs meet your needs.
  2. Forecast: Estimate the savings based on your current traffic patterns.
  3. Migrate: Follow the steps outlined above to transition to Lambda Function URLs.
  4. Monitor: Keep a close eye on your application’s performance to ensure it meets your standards.

Conclusion

Lambda Function URLs present a compelling alternative to the traditional API Gateway setups for specific scenarios. By embracing this innovation, you can Stop Paying $3.5/million requests for AWS API Gateway v1 or v2 and enjoy the benefits of a cost-effective, simplified serverless architecture with AWS Lambda Function URL.

For more detailed information, refer to the official AWS documentation and consider reaching out to AWS support or consulting with AWS professionals to ensure this transition suits your operational requirements.

(Disclaimer: The provided costs in this blog post may vary based on AWS pricing updates or changes post-2023 and are meant to be illustrative. Please check the latest AWS pricing for the most accurate information.)

--

--