feat(plugin): add limit-req-global — cluster-wide rate limiting - #13759
Open
lovelock wants to merge 1 commit into
Open
feat(plugin): add limit-req-global — cluster-wide rate limiting#13759lovelock wants to merge 1 commit into
lovelock wants to merge 1 commit into
Conversation
Introduces a new plugin that distributes a cluster-wide global rate across N nodes using a shared metadata-driven instance_count. Behavior: local_rate = global_rate / instance_count local_burst = global_burst / instance_count instance_count is stored in plugin_metadata, refreshed every 10s by a per-worker background timer. Defaults to 1 when metadata is unset. Default rejected_code is 429 (Too Many Requests). ### Description Standard limit-req is per-node: N nodes each with rate=100 effectively allow N*100 req/s cluster-wide. This plugin solves this by accepting a global_rate at the route level and computing local_rate = global_rate / instance_count per node. instance_count is configured cluster-wide via plugin_metadata, and each node's timer picks it up every 10 seconds. The approach uses only local shared dicts (no cross-node coordination), making it efficient and avoiding single points of failure. #### Which issue(s) this PR fixes: N/A — new feature. ### Checklist - [x] I have explained the need for this PR and the problem it solves - [x] I have explained the changes or the new features added to this PR - [x] I have added tests corresponding to this change - [ ] I have updated the documentation to reflect this change - [ ] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Introduces a new plugin that distributes a cluster-wide global rate across N nodes using a shared metadata-driven instance_count.
Behavior:
local_rate = global_rate / instance_count
local_burst = global_burst / instance_count
instance_count is stored in plugin_metadata, refreshed every 10s by a per-worker background timer. Defaults to 1 when metadata is unset.
Default rejected_code is 429 (Too Many Requests).
Description
Standard limit-req is per-node: N nodes each with rate=100 effectively allow N*100 req/s cluster-wide.
This plugin solves this by accepting a global_rate at the route level and computing local_rate = global_rate / instance_count per node. instance_count is configured cluster-wide via plugin_metadata, and each node's timer picks it up every 10 seconds.
The approach uses only local shared dicts (no cross-node coordination), making it efficient and avoiding single points of failure.
Which issue(s) this PR fixes:
N/A — new feature.
Checklist