Class AIMDBackoffManager
- All Implemented Interfaces:
BackoffManager
The AIMDBackoffManager applies an additive increase,
multiplicative decrease (AIMD) to managing a dynamic limit to
the number of connections allowed to a given host. You may want
to experiment with the settings for the cooldown periods and the
backoff factor to get the adaptive behavior you want.
Generally speaking, shorter cooldowns will lead to more steady-state variability but faster reaction times, while longer cooldowns will lead to more stable equilibrium behavior but slower reaction times.
Similarly, higher backoff factors promote greater utilization of available capacity at the expense of fairness among clients. Lower backoff factors allow equal distribution of capacity among clients (fairness) to happen faster, at the expense of having more server capacity unused in the short term.
- Since:
- 4.2
-
Constructor Summary
ConstructorsConstructorDescriptionAIMDBackoffManager(org.apache.hc.core5.pool.ConnPoolControl<HttpRoute> connPerRoute) Constructs anAIMDBackoffManagerwith the specifiedConnPoolControlandClock. -
Method Summary
Modifier and TypeMethodDescriptionprotected intgetBackedOffPoolSize(int curr) Returns the backed-off pool size based on the current pool size.voidsetBackoffFactor(double d) Sets the factor to use when backing off; the new per-host limit will be roughly the current max times this factor.Methods inherited from class AbstractBackoff
backOff, getBackoffFactor, getCap, getConnPerRoute, getCoolDown, getLastRouteBackoffs, getLastRouteProbes, getLastUpdate, getTimeInterval, probe, setCoolDown, setPerHostConnectionCap
-
Constructor Details
-
AIMDBackoffManager
Constructs anAIMDBackoffManagerwith the specifiedConnPoolControlandClock.This constructor is primarily used for testing purposes, allowing the injection of a custom
Clockimplementation.- Parameters:
connPerRoute- theConnPoolControlthat manages per-host routing maximums
-
-
Method Details
-
getBackedOffPoolSize
protected int getBackedOffPoolSize(int curr) Returns the backed-off pool size based on the current pool size. The new pool size is calculated as the floor of (backoffFactor * curr).- Specified by:
getBackedOffPoolSizein classAbstractBackoff- Parameters:
curr- the current pool size- Returns:
- the backed-off pool size, with a minimum value of 1
-
setBackoffFactor
public void setBackoffFactor(double d) Sets the factor to use when backing off; the new per-host limit will be roughly the current max times this factor.Math.flooris applied in the case of non-integer outcomes to ensure we actually decrease the pool size. Pool sizes are never decreased below 1, however. Defaults to 0.5.- Parameters:
d- must be between 0.0 and 1.0, exclusive.
-