-
Notifications
You must be signed in to change notification settings - Fork 868
fix: Optimization of Rate Limiting Logic for Cluster, AI Token and WASM Plugin #2997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Optimization of Rate Limiting Logic for Cluster, AI Token and WASM Plugin #2997
Conversation
优化集群限流和AI Token限流逻辑以支持阈值动态调整变更概述
变更文件
💡 小贴士与 lingma-agents 交流的方式📜 直接回复评论
📜 在代码行处标记
📜 在讨论中提问
Summary of changes
Change files
💡 TipsHow to communicate with lingma-agents📜Reply directly to comments
📜 mark the line of code
📜Ask a question in the discussion
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2997 +/- ##
==========================================
+ Coverage 35.91% 44.97% +9.06%
==========================================
Files 69 82 +13
Lines 11576 13378 +1802
==========================================
+ Hits 4157 6017 +1860
+ Misses 7104 7014 -90
- Partials 315 347 +32 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ⅰ. Describe what this PR did
集群限流和AI Token限流限流逻辑优化:限流统计调整为累加方式,保证限流值修改时不会重置请求次数和token使用量
目前实现有个小弊端,但应该没有更好的解决方式:集群限流场景下,再修改限制阈值时,实际请求次数会比限流阈值少一次,参考cluster-key-rate-limit测试用例中根据key限流模式
Ⅱ. Does this pull request fix one issue?
fixes #2996
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
1) cluster-key-rate-limit
全局限流模式:
请求3次后:

修改限流阈值为50,阈值变更为50:

根据key限流模式:
curl -kvv -X GET 'http://localhost:8082/foo?apikey=9a342114-ba8a-11ec-b1bf-00163e1250b5'可以请求三次,触发限流后,这里的请求数不会一直累加了:

修改阈值为6,还是可以再请求两次:
2)ai-token-ratelimit
触发限流:

修改阈值为300,可以继续请求:

Ⅴ. Special notes for reviews