@Experimental public class AIMDBackoffManager extends Object implements 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.
Constructor and Description |
---|
AIMDBackoffManager(ConnPoolControl<HttpRoute> connPerRoute)
Creates an
AIMDBackoffManager to manage
per-host connection pool sizes represented by the
given ConnPoolControl . |
Modifier and Type | Method and Description |
---|---|
void |
backOff(HttpRoute route)
Called when we have decided that the result of
using a connection should be interpreted as a
backoff signal.
|
void |
probe(HttpRoute route)
Called when we have determined that the result of
using a connection has succeeded and that we may
probe for more connections.
|
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.
|
void |
setCoolDown(TimeValue coolDown)
Sets the amount of time to wait between adjustments in
pool sizes for a given host, to allow enough time for
the adjustments to take effect.
|
void |
setPerHostConnectionCap(int cap)
Sets the absolute maximum per-host connection pool size to
probe up to; defaults to 2 (the default per-host max).
|
public AIMDBackoffManager(ConnPoolControl<HttpRoute> connPerRoute)
AIMDBackoffManager
to manage
per-host connection pool sizes represented by the
given ConnPoolControl
.connPerRoute
- per-host routing maximums to
be managedpublic void backOff(HttpRoute route)
BackoffManager
backOff
in interface BackoffManager
public void probe(HttpRoute route)
BackoffManager
probe
in interface BackoffManager
public void setBackoffFactor(double d)
Math.floor
is 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.d
- must be between 0.0 and 1.0, exclusive.public void setCoolDown(TimeValue coolDown)
coolDown
- must be positivepublic void setPerHostConnectionCap(int cap)
cap
- must be >= 1