What is the best way to throttle api to

What is the best way to throttle api to another rest api endpoint in a worker? The rest end point has a 60 requests/sec hard stop
5 Replies
Socal
Socal10mo ago
Workers have no concept of time so this is where i'm running into issues
sathoro
sathoro10mo ago
"no concept of time"? that's just not true
Socal
Socal10mo ago
Security model · Cloudflare Workers docs
This article includes an overview of Cloudflare security architecture, and then addresses two frequently asked about issues: V8 bugs and Spectre.
sathoro
sathoro10mo ago
yes, I'm aware. that is completely different than "no concept of time" if you are calling a rest api the time will reset each time, as those docs you link clearly state. so you can do the rate limiting based on that or don't overcomplicate things and simply call the rest api and just handle 429 with exponential backoff
Erisa
Erisa10mo ago
Most rate limits will have a header with the amount of time you need to wait for in the 429 response, so you can typically wait for that much time and then try again
Want results from more Discord servers?
Add your server