Replies: 4 comments 2 replies
-
I believe it's suggested to reuse a single HttpClient as long as possible. Initilizing a HttpClient and its connection pool is quite heavy. |
Beta Was this translation helpful? Give feedback.
-
Yep. The HttpClient uses message handlers under the covers, and these take care of the HTTP connections, etc. So just re-use the one instance. |
Beta Was this translation helpful? Give feedback.
-
yes, you all are right according to the specification perspective. however, our observation using real world usecases seems not so obvious. first - it looks like linux and windows behave differently. that is why we rised such question to get deep and confident answers/explanaitions |
Beta Was this translation helpful? Give feedback.
-
Use a single instance unless you actually need multiple (e.g. you need different HttpClient settings per host).
How so? There shouldn't be any differences between platforms when comparing a shared HttpClient instance to one per host.
It shouldn't. How did you determine this? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
We know that Microsoft recommends using one HttpClient per application to get best performance and stabillity.
But it is not obvious if we should use single HttpClient for all different URLs or single HttpClient per each different URL.
Is anyone from developers or Microsoft can explain this?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions