Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iis startup delay with aspx pages

Tags:

asp.net

iis

Environment: Windows Server 2003; IIS 6, ASP.NET 2.0.50727

I'm going crazy with a brand new web server that we set up (note that this problem doesn't happen on our other web servers which have the same configuration). When loading and asp.net app the first time, the page hangs for over a full minute before showing the page in the browser. After it loads the first page, everything runs very quickly.

Note 1: You will probably say that the application is being compiled for the first time. But I've ruled that out. I put trace messages EVERYWHERE in the app and all the trace messages run within a second of requesting the page. Thus, the app compiles and runs immediately. But when the app is finished rendering the page and my last trace message is printed, nothing happens. IIS is doing something behind the scenes for a full minute before transferring the finished page along http to the user's browser.

Note 2: We found that after hitting the app the first time and things run fine, if we wait an hour then we get the delay again. Thus, IIS has something in its cache that it clears out after an hour and causes our site to stall again.

Note 3: Between each test we stop/start IIS to force it to hang upon loading the app.

Note 4: We watched the Task Manager to see if IIS was spiking and taking up a lot of resources processing something. But that wasn't it. We did see a very quick spike to 50% immediately before the browser showed the page, but for the previous 60 seconds there was only 1% usage on the server.

Note 5: On another test I created a HelloWorld.html page and this does not cause IIS to hang. Thus, it has something to do with calling the ASP.NET library the very first time it sends a rendered page across http. Also, since the app has already been compiled and runs instantly, it's just the part of asp.net that sends the rendered page to the user's browser that causes the delay.

Any ideas? We are a a loss here. All of our other web servers are setup the same way and work fine, but this is a new install. So there must be a configuration setting that was missed or maybe something needs to be installed?

Thanks,

Brian

like image 679
user441058 Avatar asked Aug 30 '12 19:08

user441058


1 Answers

If you have access to the servers, then make sure that app pool recycling is actually logged to the event logs

cscript adsutil.vbs get w3svc/AppPools/DefaultAppPool/LogEventOnRecycle

you can set it to log everything with cscript adsutil.vbs Set w3svc/AppPools/DefaultAppPool/LogEventOnRecycle 255

See more here

Then check if there were any recycles.

App initialization, creation the worker process, threads, load the app domain and all the references dll's can take some time, that's normal, but that 1 minute delay is something else probably.

Try to precompile the app on the server and see if that helps aspnet_compiler -m /LM/W3SVC/[site id ]/Root/[your appname]

If you want to dig deeper, you can check the event trace ETW.

  1. logman query providers
  2. Save the IIS /ASP.NET related Guids to a file like iisproviders.txt
  3. logman start ExampleTrace -pf iisproviders.txt -ets -rt
  4. reproduce
  5. LogParser "SELECT * FROM ExampleTrace" -i:ETW
  6. logman stop ExampleTrace -ets

You can find more hereTroubleshooting appdomain restarts and other issues with ETW tracing

I would also check the w3wp.exe with procexp if it has a TCP connection time out or with Procmon for other clues.

If you have experience with windbg, then you can make a request to the app then quickly attach the debugger to the process

windbg -p [process id of the app pool]
.loadby sos mscorwks
g

and take it from there. If there are exceptions, process crash, etc you should be able to catch it...

Once we had a weird server issue like this and a .NET reinstall solved the problem, still not sure what was the culprit.

like image 63
CJ Harmath Avatar answered Oct 10 '22 02:10

CJ Harmath