Connection pooling - AsyncHttpClient/async-http-client Wiki

async-http-client supports HTTP persistent connections. Connections are stored in a ChannelPool.

The default ChannelPool is DefaultChannelPool.

Optionally, connection pool behaviour can be configured via AsyncHttpClientConfig:

import static org.asynchttpclient.Dsl.*;

AsyncHttpClient http = asyncHttpClient(config()

Default values can found in

Per-implementation configuration


By default, DefaultChannelPool will lease connections on a Last In, First Out basis. This has a few advantages:

Alternatively, some users may prefer to keep an artificially large number of connections, for example, to be able to handle bursty load. This can be achieved by configuring DefaultChannelPool to lease connections on a First In, First Out basis:

import static org.asynchttpclient.Dsl.*;

HashedWheelTimer timer = new HashedWheelTimer();
ChannelPool pool =
  new DefaultChannelPool(60000, -1, DefaultChannelPool.PoolLeaseStrategy.FIFO, timer);
AsyncHttpClient httpClient = asyncHttpClient(config()