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)
A client that is making request to this api using HttpClient. 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."
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()
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).
One possible cause is due to I/O bound operation, you are blocking asp.net threads. 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.
Also check that, by configuration if you can increase no of Asp.Net threads. Traditional Asp.Net supports this. Not sure if Asp.Net Core has this facility or not.
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.