@@ -78,10 +78,37 @@ public static Builder newBuilder() {
7878 return new Builder ();
7979 }
8080
81+ /**
82+ * The HttpClient will use this setting to throttle requests.
83+ *
84+ * If the client gets a request, but the max connections are already in use,
85+ * the client will block indefinitely until it has a free connection for the request,
86+ * then make the request once it's able.
87+ *
88+ * The default value is 100.
89+ */
8190 public int getMaxConnections () {
8291 return maxConnections ;
8392 }
8493
94+ /**
95+ * Unlike {@link #getMaxConnections()}, the HttpClient will use this per-host setting to IMMEDIATELY FAIL any requests
96+ * that would cause it to exceed the connections per host limit.
97+ * The client does NOT block / wait for any amount of time if it gets a request when the max connections per host are already used up;
98+ * instead, a {@link org.asynchttpclient.shaded.exception.TooManyConnectionsPerHostException} is thrown from the client immediately.
99+ *
100+ * Note, {@link #getConnectTimeoutMillis()} doesn't come into play in this connection limiting.
101+ * Instead, the internal `acquireTimeout` is the timeout for acquiring a connection permit;
102+ * this setting isn't exposed and the default is 0.
103+ *
104+ * If you want to use the client to throttle requests indefinitely without throwing exceptions for connection limits,
105+ * use {@link Builder#setMaxConnectionsPerHost(int)} to a higher number than {@link #getMaxConnections()} works
106+ * most of the time (except there's some race condition that can be hit when the client is being totally overwhelmed).
107+ * If possible, it can be better to limit requests to the client.
108+ * For example, it might be possible to limit a thread pool that uses the client accordingly.
109+ *
110+ * The default value is 25.
111+ */
85112 public int getMaxConnectionsPerHost () {
86113 return maxConnectionsPerHost ;
87114 }
0 commit comments