Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get the time spent in request queue in Kestrel/ASP.NET Core?

My understanding is that ASP.NET Core middleware is run when a request is ready to be processed. But if the app is under load and ASP.NET Core can not process all the requests as they come in, they are put in a "queue" somewhere? I don't know whether this is some managed queue inside Kestrel or whether it has something to do with libuv.

I would like to be able to know how long a given request is spent in this queue. Is there something on HttpContext that can tell me this?

Thanks in advance

like image 504
ChrisBellew Avatar asked Feb 10 '17 05:02

ChrisBellew


People also ask

How many connections can Kestrel handle?

Maximum client connections Limits. MaxConcurrentUpgradedConnections = 100; }); An upgraded connection is one that has been switched from HTTP to another protocol, such as WebSockets. After a connection is upgraded, it isn't counted against the MaxConcurrentConnections limit.

How many requests per second can ASP.NET Core handle?

7+ Million HTTP requests per second from a single server.

What is Httpsys?

HTTP. sys is a web server for ASP.NET Core that only runs on Windows. HTTP. sys is an alternative to Kestrel server and offers some features that Kestrel doesn't provide. Important.

Why is ASP.NET Core so fast?

One of the reasons ASP.NET Core is faster is its extensive use of asynchronous patterns within the new MVC and Kestrel frameworks.


1 Answers

This question is not that easy.

If you want to track all of the times, you have to do a lots of steps. At the beginning add a unique stamp or the ticks to the requests, so you can identify them one by one. Second, create a handler, which intercepts your requests and logs the times. Third, add a logging point to every request related method. Fourth - this will be a surprise - you can't do anything big to reduce this time expect the configuration of IIS regarding threading, parallel requests, session handling, etc. Fifth - if your browser measures 2000 ms, your server measures 200 ms, it's not the .NET core, its your code/architecture/config. Sorry to tell you bad news.

Use the System.Diagnostics.Stopwatch class to measure the time.

like image 187
Dexion Avatar answered Sep 20 '22 19:09

Dexion