Sentinel icon indicating copy to clipboard operation
Sentinel copied to clipboard

Sentinel-block.log Why are there multiple current limit logs in one second?

Open yehuali opened this issue 7 years ago • 3 comments

image 问题:从日志上看觉得一个请求同时被两个规则同时拦住 期望:一个请求只会被一个规则拦截住 重现:在ParamFlowQpsDemo的initParamFlowRules方法中加入一条流控规则 List rules = new ArrayList(); FlowRule rule1 = new FlowRule(); rule1.setResource(RESOURCE_KEY); // set limit qps to 20 rule1.setCount(8); rule1.setGrade(RuleConstant.FLOW_GRADE_QPS); rule1.setLimitApp("default"); rules.add(rule1); FlowRuleManager.loadRules(rules);

yehuali avatar Jul 09 '19 02:07 yehuali

Hi @yehuali, we detect non-English characters in the issue. This comment is an auto translation from @sentinel-bot to help other users to understand this issue. We encourage you to describe your issue in English which is more friendly to other users.

Sentinel-block.log Why are there multiple current limit logs in one second?

image Question: From the log, I feel that a request is blocked by both rules at the same time. Expectation: A request will only be blocked by a rule Reproduce: Add a flow control rule to the initParamFlowRules method of ParamFlowQpsDemo List rules = new ArrayList(); FlowRule rule1 = new FlowRule(); rule1.setResource(RESOURCE_KEY); // set limit qps to 20 rule1.setCount(8); rule1.setGrade(RuleConstant.FLOW_GRADE_QPS); rule1.setLimitApp("default"); rules.add(rule1); FlowRuleManager.loadRules(rules);

sentinel-bot avatar Jul 09 '19 02:07 sentinel-bot

推测是那个日志记录类,把限流的信息聚合后,按秒记录了

yehuali avatar Jul 09 '19 02:07 yehuali

参考:https://github.com/alibaba/Sentinel/wiki/Metrics#history-resource-metrics 如果有block出现,${home}\logs\csp\sentinel-block.log会按秒把不同的异常的block数等记录下来。

这里理解日志可能需要注意,它是聚合后的指标数据,不是每次请求同时被两个规则拦住产生了两个不同的异常。

cdfive avatar Jul 09 '19 02:07 cdfive