.net core 2.2 IHttpClientFactory 高并发请求 报错The opera

2019-06-03 16:55发布

var httpclient = _httpClientFactory.CreateClient();
var url = "https://www.baidu.com/";
var rlt = await httpclient.PostAsync(url, new JsonContent(new { a = 1, b = 2 }));
var bts = await rlt.Content.ReadAsByteArrayAsync();

就是简单的post 百度网址 压测1000并发 单节点服务器
查看日志 有一部分出现
PostJson Error>>The operation was canceled. at System.Net.Http.HttpConnection.ContentLengthReadStream.CompleteCopyToAsync(Task copyTask, CancellationToken cancellationToken)
at System.Net.Http.HttpConnection.HttpConnectionResponseContent.SerializeToStreamAsync(Stream stream, TransportContext context, CancellationToken cancellationToken)
at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)

压测报告上平均响应时间快三秒 想问各位大佬是什么原因

3条回答
叼着烟拽天下
2楼-- · 2019-06-03 17:09

后续发现百度自身也不是每次都是有效response 换了同机房的接口测试 无异常

查看更多
3楼-- · 2019-06-03 17:12

在压测的时候,看看你本地的TCP连接到达了多少。

查看更多
女痞
4楼-- · 2019-06-03 17:15
登录 后发表回答