public 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
| Constructor and Description |
|---|
SystemRuleManager() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkSystem(ResourceWrapper resourceWrapper)
Apply
SystemRule to the resource. |
static Boolean |
getCheckSystemStatus() |
static double |
getCpuUsageThreshold() |
static double |
getCurrentCpuUsage() |
static double |
getCurrentSystemAvgLoad() |
static double |
getHighestSystemLoad() |
static long |
getMaxRt() |
static long |
getMaxThread() |
static double |
getQps() |
static List<SystemRule> |
getRules()
Get a copy of the rules.
|
static void |
loadRules(List<SystemRule> rules)
Load
SystemRules, former rules will be replaced. |
static void |
loadSystemConf(SystemRule rule) |
static void |
register2Property(SentinelProperty<List<SystemRule>> property)
Listen to the
SentinelProperty for SystemRules. |
static void |
setHighestSystemLoad(double highestSystemLoad) |
static void |
setQps(double qps) |
public static void register2Property(SentinelProperty<List<SystemRule>> property)
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.public static void loadRules(List<SystemRule> rules)
SystemRules, former rules will be replaced.rules - new rules to load.public static List<SystemRule> getRules()
public static double getQps()
public static void setQps(double qps)
public static long getMaxRt()
public static long getMaxThread()
public static Boolean getCheckSystemStatus()
public static double getHighestSystemLoad()
public static void setHighestSystemLoad(double highestSystemLoad)
public static double getCpuUsageThreshold()
public static void loadSystemConf(SystemRule rule)
public static void checkSystem(ResourceWrapper resourceWrapper) throws BlockException
SystemRule to the resource. Only inbound traffic will be checked.resourceWrapper - the resource.BlockException - when any system rule's threshold is exceeded.public static double getCurrentSystemAvgLoad()
public static double getCurrentCpuUsage()
Copyright © 2019 Alibaba Group. All rights reserved.