limit keys in redis to only configured rate limit values #13847
+2
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
As of now the response rate limit plugin creates and updates in redis all limit parameter keys(sec, min, hour, day and year) irrespective of whether they are defined.
This change aims to restrict keys in redis to only the configured rate limit parameters.
It will help:
Optimize redis key space. If only one rate limit parameter(f.e minute) is defined then we will have only 1 key instead of earlier 5 keys.
More importantly, since the key is only created in redis when the limit is defined, any past value will not be considered for new rate limit. For example, if we initially configured to limit at 10 req/min and now we add new limit of 50 req/hour then as per current plugin the if 50 req have been exhausted before the new limit is defined, then it will be considered and the rate limit will be immediately applied where as the expectation would be to consider the new limit from now on.
Checklist
changelog/unreleased/kong
orskip-changelog
label added on PR if changelog is unnecessary. README.mdIssue reference
Fix #[issue number]