1

I'm using ASP.NET MVC 5 and Azure Premium app services with AlwaysRunning option set "on".

I created a deployment slot for the web app, deployed my new version, opened the slot URL and everything was fast and stable. I swapped to the production environment and after the swap operation was complete the web app was slow, like if I had deployed manually to PROD. I had to wait more than a minute to have my app working again. Based on what I read I thought the app was going to be warmed up after swapping but it didn't work out.

Why after swapping it was so slow? even pages that don't hit the DB like the authentication form.

UPDATE: After switching to a V2 plan (SSD storage) the app gets restarted in less than 2 minutes :)

Francisco Goldenstein
  • 13,299
  • 7
  • 58
  • 74
  • We have been using the same process as you for a couple of years now. We previously had close to a 100% success rate using this method. We'd deploy to a pre-prod slot, warm it up, swap with production, and production was warm. Since late last year, it rarely works any more. We've tried just about everything and have been bashing our heads against the wall with Microsoft for months now but they assure us nothing has changed at their end. Needless to say its extremely frustrating. We have also tried the swap with preview, but the results are inconsistent. Sometimes working, sometimes not. – mikecamimo Feb 27 '19 at 05:41
  • It's working fine for us, after we swap it's running fine. Everything got better when we switched to a V2 plan because of the SSD storage. We are no longer using the applicationInitialization tag as our cache gets loaded when the app starts, even if nobody is using it. This is our deployment process: we first deploy to a pre-prod environment (deployment slot), we restart the deployment slot and after a minute we swap it to prod. Everything is good. – Francisco Goldenstein Feb 27 '19 at 12:32
  • 1
    Thanks heaps for the info Francisco. We will give this a try. – mikecamimo Feb 27 '19 at 21:17

1 Answers1

6

To warm up the site during a swap, you have to configure the routes to hit. You would need something like this in web.config (link):

<system.webServer>
  <applicationInitialization >
    <add initializationPage="/warmup-cache" hostName="appinit-warmup.azurewebsites.net"/>
  </applicationInitialization>
</system.webServer>

The app is most likely re-compiling Razor views, that's why it takes a while. You could pre-compile the Razor views, that would help tremendously (link). Also having a warm-up route like above registered that pre-populates caches would help.

Simon Opelt
  • 6,136
  • 2
  • 35
  • 66
juunas
  • 54,244
  • 13
  • 113
  • 149
  • Thanks for your information. I read about that configuration but it said it is executed after the swap is complete. I need to have the app running when it's in PROD right away. I have one more thing to try which is "swap with preview". I think that option combined with initializationPage will do the trick. Regarding compiled views, I don't like that approach so much because then you cannot update one view in PROD, you need to replace the DLL. – Francisco Goldenstein Jan 19 '17 at 17:28
  • Did you end up having any success @FranciscoGoldenstein ? See my reply to your original post. – mikecamimo Feb 27 '19 at 05:43
  • I replied to your comment above. – Francisco Goldenstein Feb 27 '19 at 12:32