Question

What can I do to ensure that when an application/app pool restart is triggered, that the application comes back online as fast as possible?

Better yet, is there a way to prevent the application restart when the usual triggers occur? Like modifying the web.config, global.asax, or machine.config?

Was it helpful?

Solution

There will be an "auto-start" feature in ASP.NET 4.0 (Scott Guthrie talks about it), but that won't help you now.

Please be sure that the Application Pool your website/application is running in, won't go to "sleep" automatically. A default AppPool is set to shut down after 20 minutes inactivty. As i recall this doesn't make the website rebuild, but makes the first request notably slower.

Small note, a website project can also be build, so your App_Code will be empty and your bin folder will contain a bunch of .dll's (just use Build > Build Website). This definitely will makes the first request to your site faster. I don't think a website application will kick in faster than a precompiled website project, but it is just easier to manage.

OTHER TIPS

Yes, moving to web apps will speed up the restart process. Another thing to do would be to make your global.asax as clean as absolutely possible.

Even with web apps, the site will do a restart if any of those config files are modified or if the assemblies in your bin directory change. You can't stop this.

Restart times should be pretty quick at around 2 to 3 seconds. However, I've seen some pretty complicated global.asax files which set up some domain level data that took up to 20 seconds. Of course, they were willing to pay that price because it reduced some of their normal page load times from 3 seconds to .1 second.

Mainly, we use website projects, so I assume that switching to web application projects would speed this up since all of the code files are pre-compiled into a .dll.

When using website projects, I would think that moving App_Code files into an external class library would also speed things up since the code would be pre-compiled.

For Web Application Projects, you can use a Web Deployment Project (VS2010 download link) to precompile the site into a DLL similar to a Website Project does. See the ScottGu article on how to use WDPs.

I've got a similar problem in that I'm running a very high traffic site that gets a good 300+ requests/second. A restart takes a good 90 seconds at least for it.

When I make a change that restarts the server, it appears that the restart stalls until all of the old requests (some of them very long running) close. I can make the restart happen much faster by killing the old w3wp.exe instance manually.

Is there some way to force IIS to close all the connections right away and do a hard restart? Some setting in IIS or asp.net to control this?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top