How To Go Bankrupt Trying the New Cheap AWS HTTP API Service

Dennis Butovetsky
Mar 18 · 3 min read

I absolutely love AWS. Every “managed” service they offer is usually managed way better than I could ever manage myself.
Consider this article a guide on how to not get your heart broken and not let your love make you broke.

In this story I will briefly review the new HTTP API service that became generally available last week. It is particular useful if you need a simple proxy.

And often you do need a proxy. For whatever reasons. For example, you may need it temporary for a few days to shift traffic from one environment to another and have full control without relying on DNS propagation speed/caching. Or you may want to avoid CORS and not have to do the pre-flight/OPTIONS dance.

Proxying on AWS used be easy to setup but expensive.
The pricing of classic API Gateway is: you pay $3 for every million requests. Say you have 100 mil requests a day -> you pay 300 bucks.

If you have that amount of traffic you probably can afford it.
Still I find it too expensive for what it does. Apparently AWS thinks so too, which is why they anounced a whooping “up to 71%” cost decrease for proxy optimized HTTP APIs at the latest re:Invent.

Besides being cheaper and faster it‘s also more user-friendly now.
You go to the usual API gateway console, click “Create API” and make sure to select the new HTTP type.

After that it’s really a matter of few intuitve clicks and there you have it: a working production-ready proxy that should save you bucketloads of money in less than a minute. As usual I am pleasantly surprised, well done AWS.

BUT …

When doing the few clicks make sure to pay extra attention to this little toggle:

Detailed route metrics enabled
For per route metrics, you can enable detailed metrics (may incur CloudWatch Metrics charges).”

If you are a naive AWS customer like me you probably just go ahead and enable the thing thinking “sure, I want detailed metrics”. You’d think this setting will produce couple of separate metrics for /orders and /product routes so that you can troubleshoot if things go wrong, especially if it’s a temp high-load proxy. And even if you read the documentation you may still think that.
(Or may be it’s just me? Am I being stupid? Let me know in the comments)

I think the author of the phrase “Devil is in the details” was somehow exposed to the beta preview of the AWS HTTP API service

What “detailed” here actually means is that it will produce 6 separate Count/Latency/DataProcessed/5xx/4xx metrics for each unique URL being proxied. If you have unique parameters in your URLs they will all result in 6 metrics for each and every one of them, including query parameters. So /product/123/?session=abc will results in different metrics than /product/123/?session=xyz and so on.

Custom CloudWatch metrics are cheap but not free. If you have millions of them you only pay $0.02 for each. So every URL will cost you $0.02x6 = $0.12. But the number of unique URLs could be unlimited, right? If that’s the case you can calculate your spending using the simple formula below:

$0.12 * ∞ = GODZILLION UNITED STATES DOLLARS

Yes, you’ll see this charge in your AWS bill after trying this service for couple of days and may get a heart attack. I don’t know if this trap is there by design. If it is the designer probably looks something like this:

My advise: just turn the damn toggle off and screw the metrics. Couple of more advices that could help avoid similiar surprises with any AWS service:

  1. Before you try anything on AWS focus on billing.
    Setup billing alerts, alarms, budgets and CloudTrail.
  2. Create your resources with Cloudformation.
    This method forces you to think every setting through a bit more thoroughly than by clicking in the AWS console.

Good luck building AWSome stuff without unexpected charges!

Dennis Butovetsky

Written by

Experienced software architect and co-founder of https://www.eatellia.com

More From Medium

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade