The rate limit policy has some limitations when configured to use Redis.
For example:
- Create a
fixed window limit for a key, with a given count and window.
- Restart the gateway with the same config, just changing the
window.
- The policy ignores the change and will not adapt the TTL of the limiting keys to the new
window.
or
- Start Apicast with a limit in the config.
- Restart the gateway without that limit.
- Add the same limit again and restart the gateway.
- Apicast will apply limits using the keys created in the first step. That means that for example, the count and the ttl are not reset.
In order to solve this problems, we need to store more information in Redis and perform some checks every time Apicast boots with the rate limit policy config. For example, the policy needs to check the existing limits and see if it needs to increase the TTL of the limiting keys, decrease it, remove them, etc.