Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm developing sites based on .NET platform. I usually deploy these sites on my local IIS, so that I can test them and see their functionality before going live. However, each time I restart windows, it seems that sites take a long time to run for the first time.

I know about JIT and I'm also aware of this question, but it doesn't answer my question.

Does JIT happens every time you restart windows? Is it related to creation of w3wp.exe process? Why sites are so slow for the first request after each restart?

share|improve this question

closed as off-topic by GlenH7, gnat, Kilian Foth, Dan Pichelman, Bart van Ingen Schenau Mar 24 at 15:29

  • This question does not appear to be about software development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
This is known as "cold start" or something. The system has to load the w3wp into memory, which also needs all related dlls, probably JIT stuff, process import tables, read data from disk, as it's not in RAM cache, etc. –  Coder Aug 1 '11 at 10:15
    
@Coder, +1 for your comment. But could you please explain more in an answer, so that I and other developer would use benefit. :) –  Saeed Neamati Aug 1 '11 at 10:19
    
IIS is not my speciality, so I hope someone will give a better answer. Here is a similar topic I started a while ago stackoverflow.com/questions/3807791/cold-startup-optimization Maybe it'll help some more. –  Coder Aug 1 '11 at 10:32
4  
This question appears to be off-topic because it is about an implementation issue and not a conceptual programming problem. –  GlenH7 Mar 24 at 11:20
add comment

4 Answers 4

up vote 17 down vote accepted

This problem is the JIT compile. The application pool needs time to build the libraries before it can begin processing them. This can be sped up by using a warmup script, but it's something that needs to happen. It also depends on whether you're using a website or a web application project. A website is JIT for every page so the very first hit is slow and each new page hit has an extra compile time as well. Web application projects are precompiled so should not suffer this hit as badly, but the libraries still need to be loaded up. The more libraries/tools you have the worse this hit tends to be. Here are some links that discuss the warm up:

http://weblogs.asp.net/gunnarpeipman/archive/2010/01/22/iis-application-warm-up-module.aspx http://blogs.iis.net/steveschofield/archive/2009/05/30/application-pool-warm-up.aspx http://stackoverflow.com/questions/2063461/iis-web-applications-warmup http://sharepoint.smayes.com/2011/06/application-pool-specific-warm-up-scripts/

share|improve this answer
5  
This is mostly correct but there's a difference between compiling and jitting that isn't clear in this answer. Jitting is compiling the .NET bytecode to machine code. ASP.NET is actually compiling those web pages, even in a Web Application Project (unless you use the aspnet_compiler). All that compile/build time, plus the jitting and library load time, is why it's so slow. –  Aaronaught Aug 1 '11 at 12:37
add comment

The slow reaction on your first request is because IIS only starts/loads a site or application pool on it's first incoming request. And after a fixed amount of time no new incoming requests arrive at the server IIS stops the site again (app pool recycling).

ASP.NET 4.0 has a new feature called auto-start. With this feature you can set an application pool or individual site to start itself before any requests. This is triggered on boot time (when IIS starts) or when you update an ASP.NET site (which stops the site).

<applicationPools>
    <add name="MyAppPool" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />
</applicationPools>

<sites>
    <site name="MySite" id="1">
        <application path="/" serviceAutoStartEnabled="true" />
    </site>
</sites>

You need IIS 7.5 to use this.

There's also an option to perform certain extra tasks when the auto-start kicks in, ex. to preload data into cache.

share|improve this answer
    
Normally you compile your full site before you put it on the web server, so the code doesn't need to been compiled any more on the first request. JIT is only used for sites using the App_code folder where you publish your source code with the website. –  Stief Aug 19 '11 at 13:31
add comment

Part of the problem is also the GAC. Libraries places there will need to be security checked everytime they are loaded up - that means a whole load of encryption type work being carried out, and this slows things down a lot. There was a talk about WPF performance a while back from MS that described this problem - their answer was "don't put stuff in the GAC if you can't help it"

share|improve this answer
    
That should be "can help it" to avoid a double negative –  Richard Szalay Mar 18 at 21:03
add comment

IIS has an annoying (sometimes) feature for low traffic websites. It recycles unused worker processes – which cause the first user to the site; sometimes extremely long delay (30+ seconds). http://dotnettimes.wordpress.com/2014/03/24/fixing-slow-initial-load-for-iis-web-site/

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.