Support multiples of units for rate limits
- Dominant language
- C++
- Stars
- 28.9k
- Forks
- 5.6k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 428
Description
*Title*: Support multiples of units for rate limits
*Description*:
We want to be able to specify rate limit intervals more flexibly than per-minute or per-second, for example per 30 seconds or per 10 minutes. Concretely, we have some bursts over 2-3 minutes that we want to restrict. We can only do this by rate limiting per-minute or per-hour, the former not reflecting continuous load and the latter not re-allowing traffic until a full hour has passed.
This is also described in https://github.com/envoyproxy/ratelimit/issues/190 and I planned to contribute this feature for envoyproxy/ratelimit but got stuck at the centralised protobuf definition, hence this issue.
My proposed solution would simply be to extend [RateLimit](https://github.com/envoyproxy/envoy/blob/main/api/envoy/service/ratelimit/v3/rls.proto#L75) with a new field:
```
uint32 unitMultiplier = 4;
```
*Relevant Links*:
The relevant call (for redis) is https://github.com/envoyproxy/ratelimit/blob/main/src/redis/fixed_cache_impl.go#L155. The ratelimit service iterates over a list of internal `limits []*config.RateLimit` objects, that each contain a `Limit` struct (https://github.com/envoyproxy/ratelimit/blob/3654bfd73dc728debfc280b2097664f595036197/src/config/config.go#L22), pointing to the generated pb.go file (https://github.com/envoyproxy/go-control-plane/blob/main/envoy/service/ratelimit/v3/rls.pb.go#L357-L367).
Contributor guide
Assessment
This issue has not been assessed yet.