3

I am suffering from very slow speed on initial loading of my MVC3 .NET4.5 application on Cloud Services, then of course when the pool recycles every 20 mins.

Now I could extend the recycling, but to my mind it would be a far better solution to simply precompile everything locally, then package it up and publish to Cloud Services.

How can I precompile locally, and then package up the precompiled code for publish?

Thanks

SamJolly
  • 6,347
  • 13
  • 59
  • 125

1 Answers1

4

The problem is that the default MSBuild scripts that ship with Azure SDK do not include the precompilation results into the service package. So it's not a problem to precompile the application but it's a problem to have the precompilation results packaged. One possible solution is to precompile the application in-place as described here.

The 20 minutes idle timeout makes little sense for web roles so it's worth simply disabling it. The next thing you'll face is that starting the web application when the first request arrives still takes some time because a lot of code has to be loaded from disk and JIT-compiled and the workaround is to either use "warmup" features of IIS or simply send a request to "localhost" from inside role OnStart().

Community
  • 1
  • 1
sharptooth
  • 167,383
  • 100
  • 513
  • 979
  • Thanks for this. Amazing that precompilation is not simpler, seems so logical to me. Perhaps MS believes that a local precompilation would be against a local OS which would not necessarily be the same as the deployment "osFamily", so best leave it as IL code. At present I have implemented a keep alive monitor, from an external monitor site, on the relevant action, seems to be working. Can you enlighten me more on the "warmup"/OnStart() stuff.... not something I know much about. Thanks again. – SamJolly Mar 28 '14 at 15:26
  • 1
    @SamJolly: Never tried "warmup", it's described here http://blogs.iis.net/thomad/archive/2009/10/14/now-available-the-iis-7-5-application-warm-up-module.aspx in in gazillion of other posts. The part with `OnStart()` is pretty easy - you use `WebRequest` to send an HTTP request to IIS running on the same machine. – sharptooth Mar 31 '14 at 06:59