4

I have a HttpClientWrapper, called CarInformationClient

public class CarInformationClient
{
    private readonly HttpClient _httpClient;

    public CarInformationClient(HttpClient httpClient)
    {
        _httpClient = httpClient;
    }

    public async Task<CarInfoResponse> GetCarInfoAsync(string customerReference)
    {
        var request = new CarInfoRequest
        {
            CustomerReference = customerReference
        };

        var response = await _//send data with httpclient
        //do something with the response
    }
}

And I am registering it as a singleton with Windsor

Component.For<HttpClient>().LifestyleSingleton()

As HttpClient is supposed to be reused across calls to the same host, is this singleton implementationg going to slow things down if a large number of clients simulatenously call GetCarInfoAsync as there is only ever one instance of HttpClient? I have seen this question but it doesn't quite answer my question.

Community
  • 1
  • 1
iAteABug_And_iLiked_it
  • 3,725
  • 9
  • 36
  • 75
  • You'll definitely want to read this question: http://stackoverflow.com/questions/16194054/is-async-httpclient-from-net-4-5-a-bad-choice-for-intensive-load-applications, as it discusses some important things (like setting the default connection limit) – RB. May 18 '16 at 21:29

0 Answers0