This article is a machine translation of the contents of the following URL, which I wrote in Japanese:

CloudFront Freeプランを〇しかけた日 〜Route 53 ヘルスチェックが月100万リクエストを食いつぶす〜 #AWS - Qiita

はじめに こんにちは、ほうき星 @H0ukiStar です。 皆さんは、外部に公開しているサイトの監視をしていますでしょうか? 個人で公開しているサイトであっても、エンジニアなら監視したくなるものです。私もその一人で、Route 53 のヘルスチェックでサイトの死活監視を...

favicon qiita.com

Introduction

Hi, I'm Houkiboshi @H0ukiStar.

Do you monitor the websites you publish?

Even for a personal site, most engineers want to know when it goes down. I'm one of them, and I was monitoring my site's availability with a Route 53 health check.

Then one day, CloudFront sent me a notification saying my usage had reached 50% of the Free plan, and shortly after, another one for 80%.
And no, the site hadn't gone viral.

When I investigated, the culprit was my own monitoring setup (the Route 53 health check).
In this article, I'll walk through the cause, the fix, and what to keep in mind when designing monitoring on a flat-rate plan.

About CloudFront flat-rate pricing plans

First, a quick overview of the CloudFront flat-rate pricing plans, which are the setting for this story.

A flat-rate plan bundles CloudFront, AWS WAF, Route 53 DNS, CloudWatch Logs ingestion, and more into a single fixed monthly price. There are four tiers: Free, Pro, Business, and Premium. The Free plan is positioned for hobbyists, learners, and developers who are just getting started.

The monthly usage allowances are as follows.

Free Pro Business Premium
Requests 1 M 10 M 125 M 500 M
Data transfer 100 GB 50 TB 50 TB 50 TB

The one that matters here is the Free plan's 1 million requests per month.

What happens when you exceed the allowance

According to the official documentation, usage allowances are not hard limits.

Usage allowances are not hard limits—they represent the baseline usage your plan is designed to support. You can track your usage in the CloudFront console at any time and will receive automatic email notifications when you reach 50%, 80%, and 100% of your allowance.

You also won't be charged for exceeding it.

Most importantly: you will not incur overage charges, regardless of how much you exceed your allowance.

However, if you keep exceeding the allowance by a wide margin, the documentation says your traffic delivery might be adjusted (for example, served from fewer or more distant edge locations).

So while you don't have to worry about a surprise bill, you may end up with a performance impact without noticing. Ideally, you should operate within your plan's allowance, and consider changing plans if you consistently exceed it.

Note: Email notifications are sent when usage reaches 50% / 80% / 100%. That's how I noticed this issue.

What happened

My setup looked like this.

  • A site published through CloudFront on the Free plan
  • A Route 53 health check monitoring the site through CloudFront

The health check settings were as follows.

Item Value
Protocol HTTPS
Method GET
Path Site root (/)
Request interval 30 seconds

I had chosen 30 seconds, the longest of the standard options, thinking "once every 30 seconds can't be that much."

Before long, though, I received a 50% notification, and then an 80% notification, which I hadn't expected at all.
That's an unusual pace for a personal site that hasn't gone viral.

Here is the notification email I received.

80% usage notification email

The cause: health checkers send requests from multiple regions

The cause was in how Route 53 health checks work.

If you choose an interval of 30 seconds, each of the Route 53 health checkers in data centers around the world will send your endpoint a health check request every 30 seconds. On average, your endpoint will receive a health check request about every two seconds.

The "30 second interval" is the interval per health checker. Route 53 sends requests from health checkers in data centers around the world, so from the endpoint's point of view, a request arrives about every two seconds.

By default, health checkers exist in 8 regions. Each region has 2 health checkers, so a total of 16 of them send requests every 30 seconds.

Calculating the number of requests

With the default settings (8 regions), the endpoint receives 16 requests every 30 seconds (8 regions × 2 health checkers), which comes to 1,920 requests per hour.
Calculating the monthly total gives about 1.405 million requests, as shown below.

Period Calculation Requests
1 hour 16 × 120 1,920
1 day 1,920 × 24 46,080
About 22 days 46,080 × 22 About 1.01 million
30.5 days 46,080 × 30.5 About 1.405 million

Monitoring alone was on track to use up the Free plan's 1 million requests in about 22 days...

The fix: narrow the health checker regions to 3

Route 53 health checks let you specify the regions that the health checkers run in. Fewer regions means fewer requests reaching your endpoint.

According to the official documentation, you must choose at least 3 regions.

If you choose Customize, choose the x for a Region to remove it. Choose the space at the bottom of the list to add a Region back to the list. You must specify at least three Regions.

Any regions will do, but I narrowed it down to the following 3 so that the checks are spread evenly around the world.

  • Asia Pacific (Tokyo)
  • Europe (Ireland)
  • US East (N. Virginia)

Requests after the change

Each region has 2 health checkers, so 3 regions send 6 requests every 30 seconds.

Period Calculation Requests
Per 30 seconds 3 regions × 2 health checkers 6
1 hour 6 × 120 720
1 day 720 × 24 17,280
30.5 days 17,280 × 30.5 About 527,000

That's about 527,000 requests per month, or about 53% of the Free plan's allowance. Compared with about 1.405 million requests with 8 regions, this is a reduction of a bit over 60% (62.5%).

The actual metrics

Here is how the request count changed when I went from 8 regions to 3.

Change in request count after reducing health checker regions from 8 to 3

You can see that the request count dropped significantly after the change.

Note: I couldn't retrieve the metrics from when I originally fixed this. To show the change, I switched the setting back to 8 regions to generate more requests, and then changed it to 3 regions again. This graph is from that second change, so the dates on it differ from the actual date I made the fix.

What to keep in mind when designing monitoring

When designing monitoring, we tend to focus on "what to monitor," "how to monitor it," and "what action to take."
Based on this experience, I think it's worth also considering the following, especially on a flat-rate plan.

  • Monitoring requests count toward your usage: Requests from health checks, synthetic monitoring, uptime monitoring tools, and so on are counted toward your usage just like regular traffic. Estimate the request volume your monitoring will generate in advance.
  • Don't miss the usage notifications: CloudFront automatically emails you at 50% / 80% / 100%. That's how I caught this one.
  • Exceeding the allowance doesn't increase your bill: However, if you keep exceeding it by a wide margin, your delivery performance might be adjusted.

Also, the request interval can't be changed after a health check is created. If you want to change it, you need to recreate the health check.

Conclusion

In this article, I described how using a Route 53 health check on the CloudFront Free plan nearly used up the request allowance in about 22 days through monitoring alone, and how narrowing the health checker regions from 8 to 3 brought it down to about 53%.

A flat-rate plan lets you use CloudFront without worrying about your bill, but you do need to design with its usage allowance in mind.
When you add monitoring, it's a good idea to estimate how many requests the monitoring itself will generate beforehand.

I hope this article helps anyone considering monitoring on a CloudFront flat-rate plan.