5

I have an ASP.NET Core MVC app running on a Windows Server 2016 machine. The problem I am experiencing is that after sitting idle for about 1 minute, the app is slow to respond to requests. If I use the app continuously everything is fine and snappy, but if I don't submit a request for a minute, the next request will take > 10 seconds to get a response.

I started out fiddling with IIS App Pool settings to keep it alive, but nothing changed. Finally I cut IIS out altogether and ran a build of the app using Http.Sys instead, the behavior was unchanged. I monitored the app logs in a cmd window as it was running in Http.Sys and after being idle for a minute, there was no output when the next request came in for about 10 seconds, so the app didn't even start doing anything until then. After the 10 seconds the app responded to the request in the normal amount of time.

Example app logs:

info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint 'XXXXXX (XXXX)' info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1] Route matched with {action = "xxx", controller = "xxx"}. Executing action XXXXXX (XXXX) info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2] Request finished in 6.2621ms 200 text/html; charset=utf-8

// Immediately refresh page:

info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint 'XXXXXX (XXXX)' info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1] Route matched with {action = "xxx", controller = "xxx"}. Executing action XXXXXX (XXXX) info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2] Request finished in 6.658ms 200 text/html; charset=utf-8

// Wait 1 minute, then refresh page (no activity in the log for ~10 seconds, then this:)

info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint 'XXXXXX (XXXX)' info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1] Route matched with {action = "xxx", controller = "xxx"}. Executing action XXXXXX (XXXX) info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2] Request finished in 7.1181ms 200 text/html; charset=utf-8

Is there something I can look for that is perhaps sleeping these processes on the server? I don't experience this running locally in Visual Studio or when testing on another test server, only on this demo server which is exposed to the Internet. I should also add that I use a DbContext with SQL Server 2017 that is injected as Middleware into every request pipeline, if perhaps that could be a cause.

Valuator
  • 3,262
  • 2
  • 29
  • 53
  • I am having a very very similar issue on an application that I am dealing with – Bob2Chiv Mar 26 '21 at 20:23
  • Found the answer (eventually) here: https://stackoverflow.com/questions/7341180/httpwebrequest-15-second-delay-performance-issue/44817377#44817377 – Bob2Chiv Mar 30 '21 at 17:42

0 Answers0