anders
CDCloudflare Developers
•Created by anders on 10/2/2024 in #workers-help
Best way to count own SaaS API limits/usage
Calculations look correct, so should be good! 🙌
13 replies
CDCloudflare Developers
•Created by anders on 10/2/2024 in #workers-help
Best way to count own SaaS API limits/usage
13 replies
CDCloudflare Developers
•Created by anders on 10/2/2024 in #workers-help
Best way to count own SaaS API limits/usage
yeah, that's what I thought. since I don't want to just charge afterwards, but rather limit requests, and give a hint in the API response to how many requests they have left, I think I'll do the following:
GET /?auth=1234
my worker asks KV for "requests_remaining" for id=1234, gets 1000
I allow the call, and log to Analytics Engine
Then, every ~10 minutes, I call analytics engine for each customer, check how many requests was made by id=1234, and reduce that number from requests_remaining in KV
13 replies
CDCloudflare Developers
•Created by anders on 10/2/2024 in #workers-help
Best way to count own SaaS API limits/usage
But if it’s limited to 60 seconds I would have to have another worker checking it every 60 seconds (for each customer) to see how many were used (if any)
13 replies