Spring cloud security services combat -6-10sentinel of micro hotspots and system rules

Hot rule
hotspot is frequently accessed data. Many times we want to compete on some of the hot data, and then limit. For example, information about the products of this service, we do give it a current-limiting, qps 100, one day I want to be a spike activity, there may be a lot of traffic, this time a qps goods reached 100, and this time traffic will put him under control. Other commodities have not read it.
I hope this commodity spike, only to spike this commodity id to the request, it's qps limited to 50, but also leaving the remaining 50 to my other commodities. This is the scenario we encounter.
This time we need to do that we can limit the flow according to the parameters of the request. My argument is with a hot argument, it gives you a special application of the rules. I did not bring a hot argument, there is another non-limiting hotspots rule. But they call is the same service.
It means, for the same resources, do different rules for different flow parameters.

sentinel inside this rule how to achieve

GetInfo method to annotate the sentinel. Made a Resource, before it can be developed according to some rules getInfo

we do according to the rules of the different parameters limiting the id

so I declared a new resource.

Start orderAPI



return is a back order information.

Such service is called through, had after some traffic.

qps id 1 is qps 1, 1 is not 10





now pass 2 qps problem is how points are not 10 limited stream.




Id is replaced by 1, if once the point fast. 500 returned it shows the current limited.

id is 1 when thrown ParamFlowException exception

id is not current limited 2.

System rules

和其他的规则不太一样,它是争对应用来设的。前面设置的都是争对某一个资源。某一个方法来设置的。
系统规则是争对当前这个orderAPI应用整天来设置的。

load是负载,只有在linux机器上才会生效。根据当前系统的负载来决定是不是触发保护。
RT:这个应用上所有的流量的平均的相应时间,也就是我orderAPi上有好多服务,这些所有服务的平均响应时间超过一个值,那么我就停止接收新的请求,
线程数:所有服务访问的线程数加起来
入口qps:所有服务的qps加起来达到一个值
cpu使用率:cpu的使用率超过一个百分比,
发生这些情况的时候把你整个应用给你断掉。所有服务都不提供了,所有请求都被挡住了。这个设置很少用,因为它太粗了。一般都是做细粒度的流控啊、熔断降级。如果设置了 很可能你都不知道怎么回事 ,你的服务就访问不了。 所以一般很少去这么设置。

系统规则简单了解下就可以了。
 

结束

 

Guess you like

Origin www.cnblogs.com/wangjunwei/p/11991490.html