views:

775

answers:

6

I am developping a (relatively small) website in ASP.Net 2.0. I am also using nAnt to perform some easy tweaking on my project before delivering executables. In its current state, the website is "precompiled" using

aspnet_compiler.exe -nologo -v ${Appname} -u ${target}

I have noticed that after the IIS pool is restarted (after a idle shutdown or a recycle), the application takes up to 20 seconds before it is back online (and Application_start is reached).

I don't have the same issue when I am debugging directly within Visual Studio (it takes 2 seconds to start) so I am wondering if the aspnet_compiler is really such a good idea.

I couldn't find much on MSDN. How do you compile your websites for production?

+3  A: 

Make sure that:

  1. You are using a Web Application project rather than a Web Site project, this will result in a precompiled binary for your code behind
  2. You have turned off debug code generation in the web.config file - I guess if this is different to when you used aspnet_compiler the code may be recompiled

If you've tried those, you could maybe try running ngen over your assembly thus saving the JIT time?

Simon Steele
A: 

Make sure this is set in web.config <compilation debug=false>. In my case, I also have a batch file which issue Get requests for all the main pages before giving to users (page loading simulation).

Gulzar
A: 

@Simon:

  • The project is a Web Application. Websites are then slower to startup (I had no idea it had an incidence, beside the different code organization)?
  • I checked, and while I edit the web.config after aspnet_compiler is called, I don't touch the debug value (I will however check the website is not faster to startup if I don't touch the web.config, just to make sure)

(And I will definitely have a look at ngen, I was not aware of that tool.)

Luk
I think the web applications vs. sites thing may actually be to do with the updatable bit as Will mentions - my apps are not marked updatable. I think you're probably right about the organisation thing, I'd need to have a bit more of a play to confirm.
Simon Steele
+1  A: 

If your website is compiled as updatable, you'll see a bunch of .ASPX files in your virtual directory. These must be compiled on startup. That's so you can come in and alter the web UI itself. This is default for both websites and web applications.

Will
+2  A: 

For ultimate reponsiveness, don't allow your app to be shutdown.

The first method is to make sure that it's incredibly popular so that there's always someone using it.

Alternatively, fetching a tiny keep-alive page from somewhere else as a scheduled activity can be used to keep your site 'hot'.

Steve Morgan
I find it interesting that two people have voted my answer down without comment, despite the fact that it's a realistic approach used by some very big systems. Note that DotNetNuke includes keepalive.aspx for precisely this purpose.
Steve Morgan
A: 

Gonna accept the first as answer, unfortunately the application is still quite slow. I couldn't use the ngen option so feedback is appreciated :)

Luk