单例HttpClient会因大量请求而变慢吗?

时间:2016-05-18 19:25:35

标签: c# asp.net async-await

我有HttpClientWrapper,名为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
    }
}

我正在将它注册为Windsor的单身人士

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

由于HttpClient应该在对同一主机的调用中重复使用,如果大量客户端同时调用GetCarInfoAsync,因为只有一个实例,这个单例实现会减慢速度HttpClient的?我见过this question,但它并没有完全回答我的问题。

0 个答案:

没有答案