async-http-client icon indicating copy to clipboard operation
async-http-client copied to clipboard

Thread pool using memory

Open diemol opened this issue 4 years ago • 1 comments

Hi,

We are using this http client at the Selenium project, we switched to Netty and we found this client's implementation suitable for what we want to do.

When doing requests, we block on the future because that is the nature of WebDriver commands, they basically follow a request-response pattern before the client sending requests can move to the next step.

We saw that memory usage went up and we identified several AsyncHttpClient threads using memory.

After checking the README and some messages in the Google group, we saw that it is better to use a single client instance and reuse it, so we did that. This improved things a little.

However, the thread pool grows until # of processors * 2, and still the memory is never released. To be more detailed, memory is used up to the point where the thread pool is full, after that it kind of stays stable.

Nevertheless, when the application using the http client is idle, one would expect to see the memory being claimed by the garbage collector, and this does not happen.

Do you have any advice to reclaim the used memory by the thread pool? Or is this a matter of finding the right pool size through setIoThreadsCount()?

Thanks in advance for your help,

Diego

diemol avatar Apr 06 '21 08:04 diemol

There is a property io.netty.allocator.useCacheForAllThreads which is default true. You might take a look at it.

jilen avatar May 06 '21 04:05 jilen