Sentinel
Sentinel copied to clipboard
同一个接口,如何针对不同请求方来进行不同规则的限流
Issue Description
Type: bug report or feature request
Describe what happened (or what feature you want)
Describe what you expected to happen
How to reproduce it (as minimally and precisely as possible)
Tell us your environment
Anything else we need to know?
可以为不同的调用方分配不同的channel,在参数中进行透传,然后按照channel进行限流 参考基于调用关系的流量控制
可以为不同的调用方分配不同的channel,在参数中进行透传,然后按照channel进行限流 参考基于调用关系的流量控制
我设定了origin,但是发现了一个问题:
假设我接口资源名为 testApi 现在配置3条规则: testApi default qps1 testApi user1 qps10 testapi user2 qps20
现在传参 origin=user1,发现受到了default的限流。 可是:官方的解释明明是:同一个资源名可以配置多条规则,规则的生效顺序为:{some_origin_name} > other > default
如果不配置default的话,user1和user2是分别生效的,只要加上default就会失效其他规则。

求解
default代表不区分调用者,首先匹配user1的规则,小于10qps,继续匹配到default qps1,触发限流。
官方:所有配置的规则都会走一遍(也就是app在check后,default也会check);自己可以修改,将app,other,default隔离开来,不需要相互依赖。