- All Implemented Interfaces:
- Controller
public class WarmUpController
extends Object
implements Controller
The principle idea comes from guava. However, the calculation of guava is
rate-based, which means that we need to translate rate to qps.
https://github.com/google/guava/blob/master/guava/src/com/google/common/util/concurrent/SmoothRateLimiter.java
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, for example, 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 Guava's algorithm. However,
unlike Guava's scenario, which is a “leaky bucket”, and is mainly used to
adjust the request interval, Sentinel is more focus on controlling the count
of incoming requests per second without calculating its interval.
Sentinel's "warm-up" implementation is based on the guava-based algorithm.
However, Guava’s implementation focus on adjusting the request interval, in
other words, a Leaky bucket. Sentinel pays more attention to controlling the
count of incoming requests per second without calculating its interval, it is
more like a “Token bucket.”
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.
- Author:
- jialiang.linjl