There are so many use-cases where we need to rate-limit, like:
- E-mails like notifications/reminders, token requests etc.
- Sending requests to 3rd party services
- Uploading files of any type
However, due to the nature of workers we cannot do that reliably since state doesn’t persist - which enables DDOS attacks easily even with small amount of traffic.
If we could get a feature to count the total amount of requests on a specific route inside workers, this wouldn’t be a problem.
Something like requestCount('/mail')
and it could retrieve an object like:
{
lastSecond: 1,
lastMinute: 3,
lastHour: 423,
lastDay: 4325
}
Since you’re already counting requests, maybe this is possible?