Cloudflare Unexpected High Usage of API Requests - How to Avoid Surprising Billing?

in cloudflare •  2 years ago 

I was a bit surprised to see the billing spikes this month for CloudFlare Worker. As one of the "Free" API has a huge number of requests.

Surprising CloudFlare Worker Billing

Everything comes at a price. The CloudFlare worker has the following pricing plans:

CloudFlare Worker Pricing Plan

I contacted the CloudFlare's Technical/Billing Team, and they provide me the details of Usage:

Cloudflare Worker Usage Details

And they added:

Workers Usage Review

We have reviewed your account records as well as the respective Workers charges linked to the usage period of 07/25/2022 - 08/24/2022.

When doing so, we are pulling the data for the usage period in a different system from the one that was used to collect data for invoice CFUSA5139857, which was issued on August 25th, 2022. We then pull the data and compare against the one on your invoice.

We consider what you have been invoiced correctly if:

The second data set shows the same usage amount as the data set you were invoiced for,
The second data set shows a usage amount that is slightly above the usage amount in the data set you were invoiced for,
The second data set shows a usage amount that is slightly below the usage amount in the data set you were invoiced for.
We consider that you have been invoiced incorrectly if:

The second data set shows a usage amount that is a lot or more than just slightly above the usage amount in the data set you were invoiced for;
The second data set shows a usage amount that is a lot or more than just slightly below the usage amount in the data set you were invoiced for.
Result:

The second data set shows the exact usage amount as the data set your invoice is based on.

Invoiced Usage Amount:106,342,195
Invoiced Usage Charge:$48.00

Second Data Set Usage Amount:106,342,195
Second Date Set Usage Charge:$48.00

Then after an investigation - we can find out the number of requests and subsequent requests for the last 30 days for each worker, I have to disable the "Free-tier" of one of my API.

I even renamed the API so that no more surprise.

Avoid Billing Surprise of CloudFlare Worker


Unfortunately, CloudFlare does not provide a Usage Cap on Paid Worker Plan, but here are things we can do to avoid a billing surprise:

  • Require Authentication e.g. Bearer Token, for your CloudFlare Worker
  • Rate Limit Your CloudFlare Worker
  • Disallow the Bots Access
  • set up billing usage notification email to report when the number of requests exceeds a threshold.
  • downgrade to Free Tier for free APIs. Free Tiers have a daily 100K requests and won't charge you if there is a spike. The APIs will get status code 1000+ to reflect the rate limited.
  • avoid exposing the API endpoint unless you have to (providing public APIs)

--EOF (The Ultimate Computing & Technology Blog) --

Reposted to Blog: Cloudflare Unexpected High Usage of API Requests - How to Avoid Surprising Billing?

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Thank you for reading ^^^^^^^^^^^^^^^

NEW! Following my Trail (Upvote or/and Downvote)

Follow me for topics of Algorithms, Blockchain and Cloud.
I am @justyy - a Steem Witness
https://steemyy.com

My contributions

Delegation Service

Voting Power Considered in Voting Schema and Important Update of Delegation Service!

  • Delegate 1000 to justyy: Link
  • Delegate 5000 to justyy: Link
  • Delegate 10000 to justyy: Link

Support me

If you like my work, please:

  1. Delegate SP: https://steemyy.com/sp-delegate-form/?delegatee=justyy
  2. Vote @justyy as Witness: https://steemyy.com/witness-voting/?witness=justyy&action=approve
  3. Set @justyy as Proxy: https://steemyy.com/witness-voting/?witness=justyy&action=proxy
    Alternatively, you can vote witness or set proxy here: https://steemit.com/~witnesses

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!
Sort Order:  

Hi, @justyy,

Thank you for your contribution to the Blurt ecosystem.

Your post was picked for curation by @onchain-curator.


Please consider voting for our Upkeep Proposal by Symbionts.