Sitecore WarmUp Azure for Outscaling

Outscaling on Azure without traffic loss

In a previous post on warming-up your environment, I talked about warming up the cm environment via a powershell script on the build server.

This script is usefull because it logs in to your environment before making subsequent calls.

In this post, I want to talk about initializing your azure web application before allowing traffic to it. This is especially useful if you want to use (auto)out scaling.

Why?

When you out scale an application in Azure, all new sessions tend to arrive on the new added servers. If these servers are not warmed up, all those new sessions take the “application booting” hit, which results in a big loss of traffic.

By enabling the Web App Application Initilization, you can make sure, your application is well booted and warmed up on the new server before traffic is allowed to it.

Azure Web App Application Initialization

In the web.config file you can define which pages that needs to be visited before the application becomes available. You can also define a page that needs to be shown during this startup phase.

The applicationInitialization config is added in the <system.webServer> node.

    <applicationInitialization remapManagedRequestsTo="Booting.html" doAppInitAfterRestart="true" skipManagedModules="true">
      <add initializationPage="/warmup-message.aspx?message=Warming up instance" hostName="test.onelittlespark.be"/>
      <add initializationPage="/?t=1" hostName="test.onelittlespark.be"/>
      <add initializationPage="/?t=2" hostName="test.onelittlespark.be"/>
      <add initializationPage="/warmup-message.aspx?message=Privacy loaded, loading hub" hostName="test.onelittlespark.be"/>
      <add initializationPage="/api/taxonomy/postalcodes" hostName="test.onelittlespark.be"/>
      <add initializationPage="/warmup-message.aspx?message=Warm up completed" hostName="test.onelittlespark.be"/>
    </applicationInitialization>

The warmup-message.aspx file is just a page that make an entry into the logs for debugging.

If you want to learn more on the Azure Web App Intialization, please read the very nice post by Zan Kavtaskin.

Adding HTTPS support

By design, all calls of the application initialization are made to http on port 80.

When you host your website only on https, and the http just performs the redirect, than the redirect is interpreted as a valid response and the server thinks your application is up and running.

Microsoft has written a post on how to by pass this.

The solution comes down to, detecting the application initialization in the rewriting rules config, and allow it to make its call on http.

This can be achieved by adding this rewrite rule:

  <rule name="No redirect on warmup request" stopProcessing="true">
    <match url=".*" />
    <conditions>
      <add input="{HTTP_USER_AGENT}" pattern="Initialization" />
    </conditions>
    <action type="Rewrite" url="{URL}" />
  </rule>

Leave a Reply