Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iis 7.5 ASP.net hanging requests

I am having some performance issues with my iis webserver. It is hanging randomly and I am trying to figure out how to speed up the server. I enabled Failed request tracing on the server and set it to generate a log when the request is over 3 seconds.

The resulting logs(xml) dont show much but there is a point in the compact performance log that indicates what part of the log the server is hanging on. Below is the part of the log where the large time loss is occurring.

65. i GENERAL_GET_URL_METADATA PhysicalPath="", AccessPerms="513" 17:46:32.577

66. i HANDLER_CHANGED OldHandlerName="", NewHandlerName="ExtensionlessUrlHandler-Integrated-4.0", NewHandlerModules="ManagedPipelineHandler", NewHandlerScriptProcessor="", NewHandlerType="System.Web.Handlers.TransferRequestHandler" 17:46:32.577

67. i VIRTUAL_MODULE_UNRESOLVED Name="FormsAuthentication", Type="System.Web.Security.FormsAuthenticationModule" 17:46:47.771

I am not sure what Handler changed is but it is taking a long time, any tips would be great on where to start looking.

like image 860
bischoffingston Avatar asked Jan 11 '23 10:01

bischoffingston


1 Answers

It is hard to come up with a solution without having any piece of code in sight. Here are some general hints/tips you can follow in order to have great performances with an ASP.NET application.

  • The fastest way to do a request is to not do it in the first place. Try caching everything that can be cached. There are server-side caches and client-side caches. Each have their own uses, but you are not limited to only one type.
  • Make sure you do not cache and/or keep references of any request-related objects into memory. ASP.NET have a limited number of concurrent requests and keeping a request reference in memory will hang your server if it runs out of threads
  • Close the request as soon as you are done with it
  • Everything that is not needed by the client at the time of the request should be done in the background
  • Make sure you have no memory leak in your application. Garbage Collections are often the cause of hangs in ASP.NET application. When garbage collecting, all running threads are paused. This is especially true for Gen 2 garbage collections. You can enable background generation 2 garbage collections.
  • Isolate the problematic code. Use a profiler and see which type of request is CPU-intensive. Then dig deeper and see what inside that request makes it slow.
  • In any well-balanced application, objects should either be short-lived and live forever. In the case of an ASP.NET application, the objects created during the course of a request should ideally die within that request or during the next GC gen 0.
  • Consider object pooling for large objects and objects that are long to initialize
  • Make sure your app pool doesn't totally crash and restarts (look the IIS logs and/or the Windows Events)

Some useful debugging tools you can use:

  • LeanSentry. Great for diagnosing ASP.NET server hangs
  • windbg. High learning curve but by far the most powerful debugging tool you can use
  • PerfView. Useful for analyzing ETW events like I/O or CPU usage
like image 133
slvnperron Avatar answered Jan 18 '23 09:01

slvnperron