Prevent warming up instances to serve requests when scaling out Azure App Service

Viewed 71

We host our Asp.Net app as Azure App Service and using scaling-out capabilities. The issue is that when we add new instances these new instances start to server requests almost immediately - before warming up process is done. I am using application initialization module with the following configuration:

  <applicationInitialization remapManagedRequestsTo="/warmup.html">  
     <add initializationPage="/start.ashx" />  
  </applicationInitialization> 

And once we scale-out the plan e.g. from 3 instances to 4 and requesting the site, approximately 1 of 4 times I see my warmup.html - therefore I assume that newly created instance considered by the balancer before it is actually warmed up.

Please note: our site does not require HTTPS, so this should not be an issue.

The question: how can we prevent warming up instances from being requested until the are ready to serve requests?

1 Answers

You may add add a section to your web.config that tells IIS to ping this route (initializationPage) for status, this should help in making the instance available until the warm-up is completed.

<system.webServer>  
  <applicationInitialization remapManagedRequestsTo="/warmup.html">  
    <add initializationPage="/wait-for-init.php" hostName="appinit-site.azurewebsites.net"/>  
  </applicationInitialization>  
<system.webServer>

Check this blog link: https://ruslany.net/2015/09/how-to-warm-up-azure-web-app-during-deployment-slots-swap/

See: https://www.iis.net/downloads/microsoft/application-initialization

Also, you may use a external cache provider like Azure Cache for Redis, your new instance can just point to this external cache without having to reload the data.

Also check this blog might be helpful.

Related