类 SystemRuleManager

java.lang.Object
com.alibaba.csp.sentinel.slots.system.SystemRuleManager

public final class SystemRuleManager extends Object

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
  • 构造器详细资料

    • SystemRuleManager

      public SystemRuleManager()
  • 方法详细资料

    • register2Property

      public static void register2Property(SentinelProperty<List<SystemRule>> property)
      Listen to the SentinelProperty for SystemRules. The property is the source of SystemRules. System rules can also be set by loadRules(List) directly.
      参数:
      property - the property to listen.
    • loadRules

      public static void loadRules(List<SystemRule> rules)
      Load SystemRules, former rules will be replaced.
      参数:
      rules - new rules to load.
    • getRules

      public static List<SystemRule> 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

      public static Boolean getCheckSystemStatus()
    • getSystemLoadThreshold

      public static double getSystemLoadThreshold()
    • getCpuUsageThreshold

      public static double getCpuUsageThreshold()
    • loadSystemConf

      public static void loadSystemConf(SystemRule rule)
    • checkSystem

      public static void checkSystem(ResourceWrapper resourceWrapper, int count) throws BlockException
      Apply SystemRule to 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()