Does AsyncHttpClient knows how many threads to allocate for all the HTTP requests Does AsyncHttpClient knows how many threads to allocate for all the HTTP requests multithreading multithreading

Does AsyncHttpClient knows how many threads to allocate for all the HTTP requests


The AsyncHttpClient client (and other non-blocking IO clients for the matter), don't need to allocate a thread per request, and the client need not resize its thread pool even if you bombard it with requests. You do initiate many connections if you don't use HTTP keep-alive, or call multiple hosts, but it can all be handled by a single threaded client (there may be more than one IO thread, depending on the implementation).

However, it's always a good idea to limit the max requests per host, and max requests per domain, to avoid overloading a service on a specific host, or a site, and avoid getting blocked. This is why HTTP clients add a maxConnectionsPerXxx setting.


AHC has two types of threads:

  1. For I/O operation. On your screen, it's AsyncHttpClient-x-x threads. AHC creates 2*core_number of those.
  2. For timeouts. On your screen, it's AsyncHttpClient-timer-1-1 thread. Should be only one.

And as you mentioned:

maxConnections just means number of open connections which does not directly affect the number of threads

Source: issue on GitHub: https://github.com/AsyncHttpClient/async-http-client/issues/1658