集群限流服务端返回too many request时为什么回退到本地限流模式
- Dominant language
- Java
- Stars
- 23.1k
- Forks
- 8.1k
- PR merge metrics
- No merged PRs in 30d
Description
代码如下,既然token server返回too many request了,再回退到本地模式,那么又会有一部分请求能放行,这怎么限流,甚至说当配置的集群限流阈值很大时,这就限制不住吧。
版本:1.8.8
class:FlowRuleChecker,
方法如下:
```java
private static boolean applyTokenResult(/*@NonNull*/ TokenResult result, FlowRule rule, Context context,
DefaultNode node,
int acquireCount, boolean prioritized) {
switch (result.getStatus()) {
case TokenResultStatus.OK:
return true;
case TokenResultStatus.SHOULD_WAIT:
// Wait for next tick.
try {
Thread.sleep(result.getWaitInMs());
} catch (InterruptedException e) {
e.printStackTrace();
}
return true;
case TokenResultStatus.NO_RULE_EXISTS:
case TokenResultStatus.BAD_REQUEST:
case TokenResultStatus.FAIL:
case TokenResultStatus.TOO_MANY_REQUEST:
return fallbackToLocalOrPass(rule, context, node, acquireCount, prioritized);
case TokenResultStatus.BLOCKED:
default:
return false;
}
}
```
Contributor guide
Research direction
Start with FlowRuleChecker.applyTokenResult in the 1.8.8 code and trace fallbackToLocalOrPass for TokenResultStatus.TOO_MANY_REQUEST. Reproduce the cluster rate-limiting behavior described in the issue, then determine and verify the expected handling when the token server returns too many requests. Done means the behavior no longer unexpectedly bypasses the configured cluster threshold, with coverage for this result status.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100