Super Morris
Super Morris
CDCloudflare Developers
Created by Super Morris on 7/19/2024 in #workers-help
How to handle API rate limits accross Workers on the edge?
Hey everyone. We have a tricky case, but I am sure there are also people out there that have figured their own solutions to this. We build a flow builder that runs on cloudflare workes. The flows are really time critical and get triggered from clients frontendside around the word. Within the flows a customer can make api calls to a variety of API endpoints. Each endpoint has their own rate limit. Some have very strict limits that for example only allow 5 API calls per second, and when you overhit the api, you get a 30 second timeout. We also have some API's that when you overhit a lot of times, they kill your access to the API for days. So we need to handle he rate limit globally across all workers destinations. The only solution I can imagine at the moment is use DO/D1 or an other DB to check the current rate limit status, make the call, update the status. This is f*cking expansive both in time and $$$. A read to planetscale costs us 30-200ms, a write about 80-250ms (depending from where, D1 is even slower). We can't lose 200-400ms just to keep track of the rate limit :/ How did/would you handle this?
1 replies
CDCloudflare Developers
Created by Super Morris on 5/17/2023 in #workers-help
execute customer code without "workers for platforms"
Hey, we are building a flow builder based on cf infrastructure/workers. On part of the flows should be custom functions the user can write. simple example: "const sum = 1 + 1; return sum;" best practice for sure would be workers for platforms with cf enterprise. However as you can imagine we are a small startup and 3-5k per month would be a very hard bill to swallow. as code evaluation is not allowed in workers, does anyone have an other idea to run custom code for customers (securely) without workers for platforms and without an external server/service? Thankful for every hint and idea! Best Regards, Moritz
1 replies