How to only flow control on some origin when total QPS up to the rule's setting
Issue Description
Type: feature request
Describe what happened (or what feature you want)
It's about Flow Control. Thinking of the following case:
One resource A could accept 10 QPS, it has three origin: B, C, D. If A receives B request in QPS 20 at one moment, and at the same time the QPS of C and D is just low, such as 1. This case, we want to limit B's request, because B's requests are not normal, but not limit C and D's requests cause they are normal requests, if we just add a rule about resource A that limit QPS to 10, we may limit C and D's requests, that's not we expect.
Maybe we could add more rules: rule1: A with limitApp='default' to limit QPS to 10 rule2: A with limitApp='B' to limit QPS to suitable value, such as 6 rule3: A with limitApp='C' to limit QPS to 5 rule4: A with limitApp='D' to limit QPS to 4
According the above rules, when B,C,D's QPS are seperately 20, 1, 1, sentinel will limit B,C,D's QPS to 6, 1, 1, and this total is 8 that will low the system load(beacase the resource's limit is QPS 10). Maybe we could modify rule2's QPS to 8, thus the resource's load could be QPS 10. But consider this case: B,C,D's QPS are seperately 7, 2, 2, they are greater than total QPS 10, and not satisfy rule2-4, so sentinel will just using the total limit 10, and limit B,C,D's QPS to 7, 1, 2 or 6, 2, 2 or so on, and this limitation is not in our expectation, our expections are when some origin's QPS up to some value, sentinel should only limit this origin, and after limitation, the tatol QPS should as high as possible.
I mean if we use the above method, the value of QPS in rule2 may very hard to set, if set too low, the total QPS may not up to highest, if set too high, maybe the requirement that only limits some unnormal origin may not satisfy.
Anyone has a good idea?
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?
要实现你的想法的话可以增加一个QPS资源调度者,负责分配B、C、D访问A的QPS资源。 假设A总的QPS是30,B、C、D的初始分配比例是一样,每个是10 QPS。当B已经超过10 QPS时,此时B可以询问谁还剩余资源?如果没有,B超过的QPS直接blocked掉。如果有,假设C:2 、D:5。这时B就偷D的资源,因为D剩余资源最多,访问量少,可以充分利用。这样可以实现资源利用的最大化。
反过来当D的QPS升上来了,发现自己还没到10QPS。但是自己的资源没了,也没有其它资源可借(总QPS已经饱和)。这时D向QPS资源调度者投诉说有人抢了我的资源。这时QPS资源调度者就把占用最高的家伙揪出来,把超出额外的请求blocked掉一段时间,把资源还回给D。实现资源均衡