6

I am right now in the middle of creating a new web application for Azure.

I've noticed that if I do not visit the site for a while (30+ minutes) that it will take a while to load (20+ seconds) on my first visit. I presume this is because Azure has to go though and compile the application. Is there a way to either prevent the application from having to be complied after idling for an extend amount of time. Or somehow pre-complie the web application locally - and then deploy it to Azure, so it does not need to be complied on the server?

I am using VS 2012, Web Application (Web Forms) and Web Deploy

You can access my Web Site Here.

bAN
  • 13,375
  • 16
  • 60
  • 93

3 Answers3

1

Unfortunately there is no way round this with Azure websites. As you said it is due to the fact that IIS is a demand driven web server and so only does things when it is asked to. So an IIS worker process only spins up when a request arrives for the site that is hosted in this worker process.

If you're using VS2012 and web deploy then you are most probably already compiling the code. In .Net this compile step only takes it part way though into IL (intermediate language) which is CPU independent, the worker process then needs to take this and convert it into native code that can be run on that machine. That is why your site is taking a while to load.

They did start shipping a warm up module (Application initialisation) with IIS 7.5 which was included in IIS 8 to solve this problem for initialisation heavy sites unfortunately it's not available with Azure web sites as it's a native module. If you want to use it then you would have to switch to Azure cloud services or virtual machine to run your site.

The other alternative which I've known people to use is to use a cloud monitoring service such as pingdom which obviously continuously makes request to a page on your site which keeps the worker process alive. One last alternative which is far from ideal is to have a simple script somewhere that makes a request to the page to keep it alive.

If your website becomes popular, however, there is no need for any of these steps as the mere fact that people are visiting your website will keep the worker process alive.

whudson05
  • 469
  • 1
  • 3
  • 9
  • Thanks, I planed on doing a cloud monitoring system so that looks like the fix for now well until I get consistant traffic to my site again. –  Jan 24 '13 at 00:22
0

I just ran your site through Google Page Speed: https://developers.google.com/speed/pagespeed/insights#url=http_3A_2F_2Fffinfo.azurewebsites.net_2F&mobile=false

If you are concerned about speed/performance on a "shared" WebSite instance you should fix some of the items listed in there. Having a huge background of 375kb is probably not the best idea...and its not even compressed.

If you can, move to an "extra small" instance of a cloud service and you can optimize a lot of additional things (turn off ASP.NET modules, remove headers, control compression, client caching). Your goal is to have a popular site, correct?...start it off right :)

Bart Czernicki
  • 3,663
  • 1
  • 21
  • 19
  • Thanks for your input, I am not really concerned with the speed/perf of the site after the first load, at this time. I was more concerned with the recylcing of the app pool causing a re-compliation of the site. –  Jan 24 '13 at 19:46
0

It's not out of the box, but one easy way to keep your cloud service warm by having a scheduled ping is to use Windows Azure Mobile Services as described here

It's basically a small script that is scheduled to hit your website every 15 minutes.

function KeepAlive() 
{     
    KeepSiteAlive("http://www.yousayhello.co.uk");     
}

function KeepSiteAlive (siteurl) 
{
     console.info("Warming up "+siteurl);
     var httpRequest = require('request');
     httpRequest(siteurl, function(err, response, body)         
     {             
        if (err)
        {
                 console.warn("Couldn't retrieve site");                             
        }
        else if (response.statusCode !== 200)
        {
              console.warn("Bad response");             
        }
        else             
        {              
            console.info("Site Warmed Up!");             
        }                         
      });
}
ozz
  • 5,098
  • 1
  • 50
  • 73