AlinsRan opened a new pull request, #13434: URL: https://github.com/apache/apisix/pull/13434
## Summary This PR enhances the `limit-count` plugin with three new capabilities: ### 1. Redis Sentinel backend Adds a new `redis-sentinel` policy that connects to Redis through Sentinel for high-availability setups: - Automatic master discovery via Sentinel nodes - Supports all existing Redis configuration options (username, password, SSL, timeouts) - Falls back to local counting when Redis is unavailable ### 2. Sliding window algorithm Adds a `window_type` field (default: `fixed`) to choose between the existing fixed-window counter and a new sliding-window algorithm: - Fixed window: current behavior, resets at each window boundary - Sliding window: smoother rate limiting, avoids burst at window boundary - Sliding window is implemented in Redis using sorted sets; local sliding window uses a shared-dict implementation ### 3. Delayed sync (`sync_interval`) Adds a `sync_interval` field for `redis`, `redis-cluster`, and `redis-sentinel` policies: - Reduces Redis round-trips on high-traffic routes by syncing counts in batches - Falls back to local counting between syncs and reconciles with Redis at each sync interval - Set to `-1` to disable (default behavior: sync on every request) ## Changes - New files: `limit-count-redis-sentinel.lua`, `delayed-syncer.lua`, `util.lua`, `sliding-window/` - Updated: `init.lua`, `limit-count-redis.lua`, `limit-count-redis-cluster.lua`, `limit-count-local.lua` - New tests: `t/plugin/limit-count-redis-sentinel.t`, `t/plugin/limit-count-sliding.t`, `t/plugin/limit-count-redis-delayed-sync.t` - Updated docs: English and Chinese plugin reference ## Compatibility All existing configurations remain unchanged. New fields are optional with backward-compatible defaults. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
