Hide menu Last updated: Feb 06 2017
Area: Episerver DXC Service Applies to versions: Not applicable

Warming up sites

This topic explains how to perform a "warmup" of your DXC site when it scales up or out and before new code is deployed into production. Warmup is the process where the web app gets hit with requests to for example pre-populate the in-memory cache before it starts to receive production traffic. This is needed to make new code deployments to production and scaling up/out as seamless as possible. 

How it works

To issue the warmup request you can utilize application initialization (built-in feature in IIS).

Specify an <applicationInitialization> section in Web.config that contains all the different paths you need to warm up. The <applicationInitialization> section should be put inside the <system.webServer> configuration section.

You can also specify which hostname should be used for the request, which is useful when you need to warmup different paths for different domains/languages. The request will always hit the "local" app instance.

The example below shows how you can use this feature to warm up the root and an "About us" page for two different languages.

Note: You are not allowed to add duplicate values for the initializationPage attribute. However, you can add a query-string as a workaround if the paths are the same for the different hostnames, like the root-page link in the example below. Make sure you do not use anything your application will interact with.

<system.webServer>
  <applicationInitialization>
    <add initializationPage="/" hostName="www.episerver.com"/>
    <add initializationPage="/?HostnameToWarmup=www.episerver.se" hostName="www.episerver.se"/>
    <add initializationPage="/about-us" hostName="www.episerver.com"/>
    <add initializationPage="/om-oss" hostName="www.episerver.se"/>
  </applicationInitialization>
<system.webServer>

The requests are sent in a sequential manner starting from the top, it will wait on each request until it receives a response.

Since you probably want to specify a hostname for the warmup requests, we recommend that you use configuration transform to set this for the different environments.

Also be aware that Episerver will add this section automatically during deployments if you haven't added it yourself. Therefore, always clear the <applicationInitialization> section before you add your links, if you only add the section to your production environment through configuration transform (see below).

Sample configuration transform file content based on the example above, note the "Remove" transform for the <applicationInitialization> section (row 3):

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.webServer xdt:Transform="InsertIfMissing">
    <applicationInitialization xdt:Transform="Remove" />
    <applicationInitialization xdt:Transform="InsertIfMissing">
      <add initializationPage="/" hostName="www.episerver.com" xdt:Transform="InsertIfMissing" />
      <add initializationPage="/?HostnameToWarmup=www.episerver.se" hostName="www.episerver.se" xdt:Transform="InsertIfMissing" />
      <add initializationPage="/about-us" hostName="www.episerver.com" xdt:Transform="InsertIfMissing" />
      <add initializationPage="/om-oss" hostName="www.episerver.se" xdt:Transform="InsertIfMissing" />
    </applicationInitialization>
  </system.webServer>
</configuration>

This will remove any <applicationInitialization> section from the Integration/Preproduction environments, if it exists, and then add the new one.

Default behavior in DXC Service

Episerver's deployment automation engine will attempt to create this section automatically during deployments. This is done by issuing a web request to the start page and parse the resulting html output to find all the relative links that exist on the start page of the site, and automatically transform Web.config to include these links in the <applicationInitialization> section. This is done for each unique hostname that has been bound to the site.

The automatic creation of the <applicationInitialization> section will only occur if the section does not already exist in the Web.config file (through transformation or otherwise).

If you need more control over the warmup behavior, for example have other pages that you need to warmup or if it needs to be done in a specific order, we recommend that you create your own custom <applicationInitialization> section. Ensure to add this in all your environments, or at least Preproduction and Production.

Related topics

 

Comments