类 WarmUpController
- 所有已实现的接口:
TrafficShapingController
- 直接已知子类:
WarmUpRateLimiterController
The principle idea comes from Guava. However, the calculation of Guava is rate-based, which means that we need to translate rate to QPS.
Requests arriving at the pulse may drag down long idle systems even though it has a much larger handling capability in stable period. It usually happens in scenarios that require extra time for initialization, e.g. DB establishes a connection, connects to a remote service, and so on. That’s why we need “warm up”.
Sentinel's "warm-up" implementation is based on the Guava's algorithm. However, Guava’s implementation focuses on adjusting the request interval, which is similar to leaky bucket. Sentinel pays more attention to controlling the count of incoming requests per second without calculating its interval, which resembles token bucket algorithm.
The remaining tokens in the bucket is used to measure the system utility. Suppose a system can handle b requests per second. Every second b tokens will be added into the bucket until the bucket is full. And when system processes a request, it takes a token from the bucket. The more tokens left in the bucket, the lower the utilization of the system; when the token in the token bucket is above a certain threshold, we call it in a "saturation" state.
Base on Guava’s theory, there is a linear equation we can write this in the form y = m * x + b where y (a.k.a y(x)), or qps(q)), is our expected QPS given a saturated period (e.g. 3 minutes in), m is the rate of change from our cold (minimum) rate to our stable (maximum) rate, x (or q) is the occupied token.
- 作者:
- jialiang.linjl
-
字段概要
字段修饰符和类型字段说明protected doubleprotected AtomicLongprotected doubleprotected AtomicLongprotected int -
构造器概要
构造器构造器说明WarmUpController(double count, int warmUpPeriodInSec) WarmUpController(double count, int warmUpPeriodInSec, int coldFactor) -
方法概要
-
字段详细资料
-
count
protected double count -
warningToken
protected int warningToken -
slope
protected double slope -
storedTokens
-
lastFilledTime
-
-
构造器详细资料
-
WarmUpController
public WarmUpController(double count, int warmUpPeriodInSec, int coldFactor) -
WarmUpController
public WarmUpController(double count, int warmUpPeriodInSec)
-
-
方法详细资料
-
canPass
从接口复制的说明:TrafficShapingControllerCheck whether given resource entry can pass with provided count.- 指定者:
canPass在接口中TrafficShapingController- 参数:
node- resource nodeacquireCount- count to acquire- 返回:
- true if the resource entry can pass; false if it should be blocked
-
canPass
从接口复制的说明:TrafficShapingControllerCheck whether given resource entry can pass with provided count.- 指定者:
canPass在接口中TrafficShapingController- 参数:
node- resource nodeacquireCount- count to acquireprioritized- whether the request is prioritized- 返回:
- true if the resource entry can pass; false if it should be blocked
-
syncToken
protected void syncToken(long passQps)
-