alibaba / Sentinel

A powerful flow control component enabling reliability, resilience and monitoring for microservices. (面向云原生微服务的高可用流控防护组件)
https://sentinelguard.io/
Apache License 2.0
22.31k stars 8k forks source link

[BUG] Flow control by related resource leads to the failure of origin flow limit #3315

Open Daydreamer-ia opened 7 months ago

Daydreamer-ia commented 7 months ago

Issue Description

Version: V1.8.7 I use the dashboard to raise a related resource flow control as follow. 我使用dashboard创建了一个关联规则如下:

1706101221512

As user, we will think the base control of "hello" will limit the qps under 1. And flow limit of the resource "helloAnother" will cause the limit to "hello". But the fact seems to be different. The flow control rule with QPS limit of 1 does not seem to be in effect. 作为用户,我们会认为hello资源会被限制在QPS为1和之下,以及helloAnother的限流也会导致hello资源的限流。但是实际情况貌似不是这样的,对QPS限制为1的规则似乎并没有生效。

I follow with the debug to find FlowRuleChecker#passLocalCheck. It gets ClusterNode of "helloAnother" when visit resource "hello". The qps of "hello" is ignored. 我跟随了代码找到 FlowSlot,以及 FlowRuleChecker#passLocalCheck,在访问资源hello时,它获取的数据统计节点是资源helloAnother的,对于资源hello的qps并没有参与计算,导致hello的qps被忽略了。

1706101314108

Describe what happened

The flow control rule with QPS limit of 1 does not seem to be in effect.

Describe what you expected to happen

QPS higher than 1 and flow limit of "helloAnother" resources can both lead to flow limit of "hello" resource.

How to reproduce it (as minimally and precisely as possible)

  1. Start the sentinel-demo-annotation-spring-aop.
  2. Create a related resource rule for "hello" resource in demo. Limit the qps under 1 and link with resource "helloAnother".
  3. Try to visit /foo in brower.

Tell us your environment

Anything else we need to know?

sczyh30 commented 7 months ago

“关联”的实际效果就是参考关联资源的指标来限制当前 resource 的流量,而与当前 resource 的指标无关,具体的生效方式可以参考 https://sentinelguard.io/zh-cn/docs/flow-control.html

Daydreamer-ia commented 7 months ago

“关联”的实际效果就是参考关联资源的指标来限制当前 resource 的流量,而与当前 resource 的指标无关,具体的生效方式可以参考 https://sentinelguard.io/zh-cn/docs/flow-control.html

感谢,明白了。不过在dashboard的ui上,建议是在选择到"关联"的时候,把阈值输入那些给隐藏了,不然可能存在误导