AspNetWebStack icon indicating copy to clipboard operation
AspNetWebStack copied to clipboard

Owin throwing TaskCanceledException when selfhosted application receives more than 3k concurrent requests

Open arpitha-kp opened this issue 3 years ago • 2 comments

Hi, I'm new to OWIN, if I get some help on this issue, I really appreciate it. I'm trying to do scalability testing of ASP.net Web API which is self-hosted as a windows service. It works fine for concurrent API requests up to 70 (each request internally further creates around 50 requests approximately - out of which 24 are concurrent, once responses are received again 18 calls will be concurrent and the rest all are sequential). But, When I started to run 100 concurrent requests it starts to fail for a few requests and it threw the following error:-

"System.Threading.Tasks.TaskCanceledException: A task was canceled. at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Owin.HttpMessageHandlerAdapter.d__20.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Owin.HttpMessageHandlerAdapter.d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()"

When I look into the git repository for owin's SendResponseContentAsync Implementation (https://github.com/aspnet/AspNetWebStack/blob/cd0186268be4679be68295e42428d8b18d8e09a1/src/System.Web.Http.Owin/HttpMessageHandlerAdapter.cs#L567), I'm assuming it's throwing an exception at Ln578, which inturn returning a Task with canceled state at Ln596 via AbortResponseAsync() method. I'm guessing it's happening due to resource exhaust.

Is there any OWIN configuration available that I can use to handle multiple concurrent requests, Can I get any help, please?

arpitha-kp avatar Oct 11 '22 00:10 arpitha-kp

adding @Tratcher too

/fyi @mkArtakMSFT

dougbu avatar Oct 12 '22 00:10 dougbu

I've commented on the duplicate issue in Katana.

Tratcher avatar Oct 14 '22 22:10 Tratcher

Thanks @Tratcher. Closing this as a dupe in that case.

mkArtakMSFT avatar Nov 09 '22 21:11 mkArtakMSFT