Protect Cloudflare workers over overusage and abuse refresh

Let’s say i have a worker which can be accessed through mysite.com/api/route-abc/

If a user refresh 100 times => 100 worker calls.
If i have thousand of users doing this, the bill will quickly go up. Specially when i have lot of worker route.

It doesn’t seem there is any mechanism to auto-cache / protect / limit / throttle this from Cloudflare ?

In a monolitih app, there are so many server tool to do this.

But with Cloudflare Worker how would you do this?

I just don’t want to end up with a thousands dollars bill from workers usage

The simplest way is using Unmetered rate limiting: Back in 2017 we gave you Unmetered DDoS Mitigation, here's a birthday gift: Unmetered Rate Limiting
You can rate limit requests on a specific path to a certain amount of requests. Free only gets path and 10s periods, Pro gets a bit more fields (hostname, etc) and 1 minute periods.
Rate limiting rules · Cloudflare Web Application Firewall (WAF) docs
Other then that, you can implement something in your Worker itself, or just the fact that Workers are pretty cheap. For Bundled Workers, you get 10 million requests free + $0.50/per million.

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.