public class Gradient2Limit
extends com.netflix.concurrency.limits.limit.AbstractLimit
The core algorithm re-calculates the limit every sampling window (ex. 1 second) using the formula
// Calculate the gradient limiting to the range [0.5, 1.0] to filter outliers gradient = max(0.5, min(1.0, longtermRtt / currentRtt));
// Calculate the new limit by applying the gradient and allowing for some queuing newLimit = gradient * currentLimit + queueSize;
// Update the limit using a smoothing factor (default 0.2) newLimit = currentLimit * (1-smoothing) + newLimit * smoothing
The limit can be in one of three main states
1. Steady state
In this state the average RTT is very stable and the current measurement whipsaws around this value, sometimes reducing the limit, sometimes increasing it.
2. Transition from steady state to load
In this state either the RPS to latency has spiked. The gradient is < 1.0 due to a growing request queue that cannot be handled by the system. Excessive requests and rejected due to the low limit. The baseline RTT grows using exponential decay but lags the current measurement, which keeps the gradient < 1.0 and limit low.
3. Transition from load to steady state
In this state the system goes back to steady state after a prolonged period of excessive load. Requests aren't rejected and the sample RTT remains low. During this state the long term RTT may take some time to go back to normal and could potentially be several multiples higher than the current RTT.
Refer to Gradient2Limit
| Modifier and Type | Class and Description |
|---|---|
static class |
Gradient2Limit.Builder |
| Modifier and Type | Method and Description |
|---|---|
int |
_update(long startTime,
long rtt,
int inflight,
boolean didDrop) |
long |
getLastRtt(TimeUnit units) |
long |
getRttNoLoad(TimeUnit units) |
static Gradient2Limit.Builder |
newBuilder() |
static Gradient2Limit |
newDefault() |
String |
toString() |
public static Gradient2Limit.Builder newBuilder()
public static Gradient2Limit newDefault()
public int _update(long startTime,
long rtt,
int inflight,
boolean didDrop)
_update in class com.netflix.concurrency.limits.limit.AbstractLimitpublic long getLastRtt(TimeUnit units)
public long getRttNoLoad(TimeUnit units)
Copyright © 2023. All rights reserved.