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.
| Modifier and Type | Field and Description |
|---|---|
| private double | |
| private int | |
| private final Clock | |
| private final ConnPoolControl | |
| private long | |
| private final Map | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| public | AIMDBackoffManager(final ConnPoolControl<HttpRoute>
per-host routing maximums to
be managed connPerRoute)Creates an |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | backOff(final HttpRoute route)
Implements org. |
| private int | |
| private Long | |
| public void | probe(final HttpRoute route)
Implements org. |
| public void | setBackoffFactor(final double
must be between 0.0 and 1.0, exclusive. d)Sets the factor to use when backing off; the new per-host limit will be roughly the current max times this factor. |
| public void | setCooldownMillis(final long
must be positive l)Sets the amount of time, in milliseconds, to wait between adjustments in pool sizes for a given host, to allow enough time for the adjustments to take effect. |
| public void | setPerHostConnectionCap(final int
must be >= 1 cap)Sets the absolute maximum per-host connection pool size to probe up to; defaults to 2 (the default per-host max). |
| backoffFactor | back to summary |
|---|---|
| private double backoffFactor | |
| cap | back to summary |
|---|---|
| private int cap | |
| clock | back to summary |
|---|---|
| private final Clock clock | |
| connPerRoute | back to summary |
|---|---|
| private final ConnPoolControl<HttpRoute> connPerRoute | |
| coolDown | back to summary |
|---|---|
| private long coolDown | |
| lastRouteBackoffs | back to summary |
|---|---|
| private final Map<HttpRoute, Long> lastRouteBackoffs | |
| lastRouteProbes | back to summary |
|---|---|
| private final Map<HttpRoute, Long> lastRouteProbes | |
| AIMDBackoffManager | back to summary |
|---|---|
| public AIMDBackoffManager(final ConnPoolControl<HttpRoute> connPerRoute) Creates an
| |
| AIMDBackoffManager | back to summary |
|---|---|
| pack-priv AIMDBackoffManager(final ConnPoolControl<HttpRoute> connPerRoute, final Clock clock) | |
| backOff | back to summary |
|---|---|
| public void backOff(final HttpRoute route) Implements org. Doc from org. Called when we have decided that the result of using a connection should be interpreted as a backoff signal.
| |
| getBackedOffPoolSize | back to summary |
|---|---|
| private int getBackedOffPoolSize(final int curr) | |
| getLastUpdate | back to summary |
|---|---|
| private Long getLastUpdate(final Map<HttpRoute, Long> updates, final HttpRoute route) | |
| probe | back to summary |
|---|---|
| public void probe(final HttpRoute route) Implements org. Doc from org. Called when we have determined that the result of using a connection has succeeded and that we may probe for more connections.
| |
| setBackoffFactor | back to summary |
|---|---|
| public void setBackoffFactor(final double d) Sets the factor to use when backing off; the new
per-host limit will be roughly the current max times
this factor.
| |
| setCooldownMillis | back to summary |
|---|---|
| public void setCooldownMillis(final long l) Sets the amount of time, in milliseconds, to wait between adjustments in pool sizes for a given host, to allow enough time for the adjustments to take effect. Defaults to 5000L (5 seconds).
| |
| setPerHostConnectionCap | back to summary |
|---|---|
| public void setPerHostConnectionCap(final int cap) Sets the absolute maximum per-host connection pool size to probe up to; defaults to 2 (the default per-host max).
| |