Scooletz / QueueBatch

WebJobs/Azure Functions trigger providing batches of Azure Storage Queues messages directly to your function
Apache License 2.0
41 stars 4 forks source link

Why not use singleton of the HttpClient object? #12

Closed jeremy001181 closed 5 years ago

jeremy001181 commented 5 years ago

Would it have better performance by having a shared HttpClient object so that it reuses port for getting messages instead of allocate and dispose each time?

https://github.com/Scooletz/QueueBatch/blob/107e2f6447bd32203698cff9dd8a1aec7c2e0e21/src/QueueBatch/Impl/Queues/FastCloudQueue.cs#L118

Scooletz commented 5 years ago

This is by design. The pooling is done on the handler level, in a way similar to the HttpClientFactory. The client itself, is disposed similarly to package I mentioned.

Http handlers are cached for a specific amount of time using a concurrent friendly cache, so the costs of creation etc should be amortized in time.

Does it answer the question? If yes, please close, if not - please provide more evidence and/or background for this issue.

jeremy001181 commented 5 years ago

yes it does thank you