Search code examples
javaapachefeign

What is the difference beetween max connections per route and max connections total in apache HttpClient?


I'm trying to understand what is the difference between them. I tried to read the documentation but it does not help alot.

HttpClientBuilder
                    .create()
                    .setMaxConnPerRoute(maxConnectionsPerRoute)
                    .setMaxConnTotal(maxConnectionTotal)
                    .build();

It's the same of setDefaultMaxPerRoute and setMaxTotal from PoolingHttpClientConnectionManager:

final PoolingHttpClientConnectionManager poolingmgr = new PoolingHttpClientConnectionManager();
poolingmgr.setDefaultMaxPerRoute(max);
poolingmgr.setMaxTotal(2 * max);

Solution

  • setMaxConnTotal is the total maximum connections available in the connection pool. setMaxConnPerRoute is the total number of connections limit to a single port or url.

    Hope it is clear now