These options control the size of the connection pool.
setMaxTotal(max) defines the connection limit for the connection pool.setMaxPerRoute(max) defines the connection restriction on one HTTP route. In simple cases, you can understand this as a limitation on the end host. Under the hood, everything looks a little more interesting: HttpClient supports a couple of HttpRoute objects that represent each host chain, for example proxy1 -> proxy2 -> targetHost . Connections are united according to the route principle. In simple cases, when you use the default route-building mechanism and do not support a proxy server, your routes will most likely include only the target host, so limiting the connection pool by route effectively becomes the limit for each node.
Example:
Suppose you have setMaxPerRoute(5) and setMaxTotal(20) . This means that you can use up to 5 connections for each target host at the same time: 5 connections to google.com, 5 more connections to oracle.com, etc. The total amount of open connections cannot exceed 20, regardless of the number of hosts with which you communicate.
Jk1
source share