-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat:Add bigkey fuse degration based on codis-proxy #2782
Conversation
Warning Review failedThe pull request is closed. WalkthroughThe changes introduce robust request-response checking mechanisms and a circuit breaker for the Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Proxy
participant Backend
Client->>Proxy: Send Redis Command
Proxy->>Proxy: Check Request Size
alt Request is Large
Proxy->>Proxy: Add to Blacklist
end
Proxy->>Backend: Forward Request
Backend-->>Proxy: Send Response
Proxy->>Proxy: Check Response Content
alt Response Exceeds Threshold
Proxy->>Proxy: Degrade Service
end
Proxy-->>Client: Forward Response
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
BigKey检测逻辑
BigKey检测分两个阶段,
第一阶段检测Request,若Request被检测为大请求则直接被熔断掉
第二阶段检测Response,主要是记录一些bigkey
CheckerBkv中的
CheckerRequest
首先会通过OpInfo的flag位调用CheckerRequest
若OpInfo中有特殊化检测(实现了CustomCheckFunc)则还会额外进行一次检测
CheckerCustumFunc
如果需要检测特定命令,则只需要在OpInfo中塞入对应结构体,并为其实现
CustomCheckFunc
接口即可熔断
首先需要开启
Checker
,通过命令xconfig set checker_enabled 1
此时每个命令对应的
session
将会开启检测,当检测到bigkey,将会存入黑名单keyblacklist
随后通过命令
xconfig set breaker_enabled 1
开启熔断通过
xconfig set breaker_degradation_probability %d
可以设置熔断概率,0-100当命令进入到
handleRequest()
时,会首先进行isBigRequest
检测,此处不会熔断,只是设置isBigRequest
标识除一些特殊命令以外,其他命令会进入到熔断检测
IfDegradateService()
ExecuteServiceDegradation(r, rd)
负责执行熔断策略并返回熔断信息Summary by CodeRabbit
New Features
SET
,MGET
,HSCAN
).Configuration Enhancements
Improved Handling
Testing Adjustments
getOpInfo
function.