Control Number of Threads spawned per HttpClient

160 views
Skip to first unread message

Prabhash Rathore

unread,
Feb 16, 2020, 1:07:05 PM2/16/20
to asynchttpclient
Hello,

I am using AsyncHttpClient version 2.10.1 in my application. I use one instance of Http Client for each data center (AWS region). At this time, I haven't configured the number of threads http clients are supposed to use. As a result I see, HttpClient created 100s of threads per httpclient.

Since AsyncHttpClient is Netty based and handles connections asynchronously, I don't think I need 100s of threads to handle a few thousand connections. My understand is HttpClient creates 2 times the number of OS threads per http client. I am looking to override this behavior. I looked at DefaultAsyncHttpClientConfig class and I see multiple configs related to threads. I need help on which setting is the most appropriate to control number of threads HttpClient uses. I saw following:

- setEventLoopGroup: I assume once  I set this, I don't need to set any other settings related to thread.
- setThreadFactory: My understanding is this is not needed if I set setEventLoopGroup.
- setIoThreadsCount: Not sure why is this needed. Isn't this implicit after setting EventLoopGroup. Is this used in conjunction with setThreadFactory?
- setThreadPoolName: I understand this is used for naming pool but again I believe setting EventLoopGroup makes this redundant.

When I look at thread dumps, I see 2 Timer threads per HttpClient. What are these used for and how are they different from threads set using above settings.

Thanks!
Prabhash Rathore

slan...@gatling.io

unread,
Feb 17, 2020, 5:23:41 AM2/17/20
to Prabhash Rathore, asynchttpclient
You have to pass your own EventLoopGroup.

> Le 16 févr. 2020 à 19:07, Prabhash Rathore <prabhas...@gmail.com> a écrit :
>

Prabhash Rathore

unread,
Feb 17, 2020, 12:27:42 PM2/17/20
to slan...@gatling.io, asynchttpclient
Thank you!
Reply all
Reply to author
Forward
0 new messages