简体   繁体   English

AspNetCore(Kestrel)请求超时

[英]AspNetCore (Kestrel) request timed out

I am having the following setup: a web api running in a couple of linux containers (built on aspnetcore 2.0.5) behind a application loadbalancer (AWS) 我有以下设置:在应用程序负载均衡器(AWS)后面的几个Linux容器(构建在aspnetcore 2.0.5上)中运行的web api

A client that is making request to this api using HttpClient. 使用HttpClient向此api发出请求的客户端。 The client is running the calls on multiple tasks in parallel. 客户端并行运行多个任务的调用。 If the number of parallel tasks increases, the api starts throwing exceptions with the message "Request timed out." 如果并行任务的数量增加,则api开始抛出异常并显示消息“请求超时”。

The call stack is: 调用堆栈是:

at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.PipeCompletion.ThrowFailed() at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.Pipe.GetResult(ReadResult& result) at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.Pipe.Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.IReadableBufferAwaiter.GetResult() at Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.ReadableBufferAwaitable.GetResult() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.d__24.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.d__2.MoveNext() 在Microsoft.AspNetCore的Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.PipeCompletion.ThrowFailed()在Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.Pipe.GetResult(ReadResult&result)上Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO中的.Server.Kestrel.Internal.System.IO.Pipelines.Pipe.Microsoft.AspNetCore.Server.Kestrel.Internal.System.IO.Pipelines.IReadableBufferAwaiter.GetResult() .Pipelines.ReadableBufferAwaitable.GetResult()at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.MessageBody.d__24.MoveNext()---从抛出异常的上一个位置的堆栈跟踪结束---在System。 Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Frame`1.d__2.MoveNext()中的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中的Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

What can cause this error, who is setting a timeout, how can I investigate this further? 什么可能导致此错误,谁设置超时,我该如何进一步调查?

Edit: If I tried fiddler to capture the failing request, the error is not thrown anymore (maybe fiddler is opening the connections with a lesser degree of parallelism). 编辑:如果我尝试使用fiddler来捕获失败的请求,则不再抛出错误(也许fiddler正在以较低程度的并行性打开连接)。

One possible cause is due to I/O bound operation, you are blocking asp.net threads. 一个可能的原因是由于I / O绑定操作,您正在阻止asp.net线程。 From the problem description it seems that your server is handling requests upto certain point. 从问题描述看来,您的服务器似乎正在处理请求到某一点。 Beyond that it is not able to do that. 除此之外,它无法做到这一点。

I think if you use Async/Await correctly, then you can serve more no of concurrent requests than your current limit. 我认为如果您正确使用Async / Await,那么您可以提供比当前限制更多的并发请求。

Also check that, by configuration if you can increase no of Asp.Net threads. 如果可以增加Asp.Net线程的数量,还可以通过配置检查。 Traditional Asp.Net supports this. 传统的Asp.Net支持这一点。 Not sure if Asp.Net Core has this facility or not. 不确定Asp.Net Core是否具有此功能。

Finally, since you are running in cloud, check the feasibility of upgrading your server configuration. 最后,由于您在云中运行,请检查升级服务器配置的可行性。 May be upgraded configuration will help you to server more no of requests. 可能是升级配置将帮助您更多的服务器请求。 Obviously this should be the last choice. 显然这应该是最后的选择。 First focus on improving the performance your application with the existing hardware. 首先关注使用现有硬件提高应用程序的性能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM