org.apache.http.impl.client
Class AIMDBackoffManager

java.lang.Object
  extended by org.apache.http.impl.client.AIMDBackoffManager
All Implemented Interfaces:
BackoffManager

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.

Since:
4.2

Constructor Summary
AIMDBackoffManager(org.apache.http.pool.ConnPoolControl<HttpRoute> connPerRoute)
          Creates an AIMDBackoffManager to manage per-host connection pool sizes represented by the given ConnPoolControl.
 
Method Summary
 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 setCooldownMillis(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.
 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).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AIMDBackoffManager

public AIMDBackoffManager(org.apache.http.pool.ConnPoolControl<HttpRoute> connPerRoute)
Creates an AIMDBackoffManager to manage per-host connection pool sizes represented by the given ConnPoolControl.

Parameters:
connPerRoute - per-host routing maximums to be managed
Method Detail

backOff

public void backOff(HttpRoute route)
Description copied from interface: BackoffManager
Called when we have decided that the result of using a connection should be interpreted as a backoff signal.

Specified by:
backOff in interface BackoffManager

probe

public void probe(HttpRoute route)
Description copied from interface: BackoffManager
Called when we have determined that the result of using a connection has succeeded and that we may probe for more connections.

Specified by:
probe in interface BackoffManager

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.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.

Parameters:
d - must be between 0.0 and 1.0, exclusive.

setCooldownMillis

public void setCooldownMillis(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).

Parameters:
l - must be positive

setPerHostConnectionCap

public 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).

Parameters:
cap - must be >= 1


Copyright © 1999–2019 The Apache Software Foundation. All rights reserved.