类 SystemRuleManager
Sentinel System Rule makes the inbound traffic and capacity meet. It takes average rt, qps, thread count of incoming requests into account. And it also provides a measurement of system's load, but only available on Linux.
rt, qps, thread count is easy to understand. If the incoming requests' rt,qps, thread count exceeds its threshold, the requests will be rejected.however, we use a different method to calculate the load.
Consider the system as a pipeline,transitions between constraints result in
three different regions (traffic-limited, capacity-limited and danger area)
with qualitatively different behavior. When there isn’t enough request in
flight to fill the pipe, RTprop determines behavior; otherwise, the system
capacity dominates. Constraint lines intersect at inflight = Capacity ×
RTprop. Since the pipe is full past this point, the inflight –capacity excess
creates a queue, which results in the linear dependence of RTT on inflight
traffic and an increase in system load.In danger area, system will stop
responding.
Referring to BBR algorithm to learn more.
Note that SystemRule only effect on inbound requests, outbound traffic
will not limit by SystemRule
- 作者:
- jialiang.linjl, leyou
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static voidcheckSystem(ResourceWrapper resourceWrapper, int count) ApplySystemRuleto the resource.static Booleanstatic doublestatic doublestatic doublestatic doublestatic longstatic longstatic List<SystemRule>getRules()Get a copy of the rules.static doublestatic voidloadRules(List<SystemRule> rules) LoadSystemRules, former rules will be replaced.static voidloadSystemConf(SystemRule rule) static voidregister2Property(SentinelProperty<List<SystemRule>> property) Listen to theSentinelPropertyforSystemRules.
-
构造器详细资料
-
SystemRuleManager
public SystemRuleManager()
-
-
方法详细资料
-
register2Property
Listen to theSentinelPropertyforSystemRules. The property is the source ofSystemRules. System rules can also be set byloadRules(List)directly.- 参数:
property- the property to listen.
-
loadRules
LoadSystemRules, former rules will be replaced.- 参数:
rules- new rules to load.
-
getRules
Get a copy of the rules.- 返回:
- a new copy of the rules.
-
getInboundQpsThreshold
public static double getInboundQpsThreshold() -
getRtThreshold
public static long getRtThreshold() -
getMaxThreadThreshold
public static long getMaxThreadThreshold() -
getCheckSystemStatus
-
getSystemLoadThreshold
public static double getSystemLoadThreshold() -
getCpuUsageThreshold
public static double getCpuUsageThreshold() -
loadSystemConf
-
checkSystem
ApplySystemRuleto the resource. Only inbound traffic will be checked.- 参数:
resourceWrapper- the resource.- 抛出:
BlockException- when any system rule's threshold is exceeded.
-
getCurrentSystemAvgLoad
public static double getCurrentSystemAvgLoad() -
getCurrentCpuUsage
public static double getCurrentCpuUsage()
-