Recommendations: Sitecore tuning in Azure

Current version: 10.0

Contributors:

Kate Orlova

Kate Orlova

The following recommendations describe how to enable Microsoft Azure features and improve the performance of Sitecore in Azure.

Improve server performance by IO tuning

To optimize the disk read and write operations on the file system:

  • Cache a file after the first request. For example, critical CSS or JavaScript files.

  • Reduce the total number of operations on the disk by assigning the log level. The log level (Priority) limits the messages that are written to the log. For example, on a production server you might only be interested in errors: <priority value="ERROR" />

  • Subscribe to the Premium App Service plan in Azure and start using SSD disks for better availability and latency.

Boost the cold start

To reduce any cold start delays after a force node restart or after moving to a new worker process, you can specify an Application Initialization configuration in the web.config file. For example, by adding the key pages such as homepage, search-specific pages, and section landing pages:

RequestResponse
<system.webServer>

<applicationInitialization doAppInitAfterRestart="true">

<add initializationPage="/" />

<add initializationPage="/key-page1/" />

<add initializationPage="/key-section/page2/" />

</applicationInitialization>

</system.webServer>

The Application Initialization module is designed to send the warm-up requests over HTTP protocol, not HTTPS, therefore, it does not work if your website is configured to redirect all HTTP requests to the relevant HTTPS ones. You can add the following to the web.config file to exclude the Application Initialization from a rewrite rule:

RequestResponse
<rewrite>

<rules>

<rule name="No redirect on warmup request" stopProcessing="true">

<match url=".*" />

<conditions>

<add input="{HTTP_HOST}" pattern="localhost" />

<add input="{HTTP_USER_AGENT}" pattern="Initialization" />

</conditions>

<action type="Rewrite" url="{URL}" />

</rule>

<rule name="HTTP to HTTPS redirect for all requests" stopProcessing="true">

<match url="(.*)" />

<conditions>

<add input="{HTTPS}" pattern="off" />

</conditions>

<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />

</rule>

</rules>

</rewrite>

Enable reverse proxy

You can set up a reverse proxy to allow a particular URL on your website to fetch its content from an external site without unnecessary redirects. You can enable a reverse proxy function by adding an applicationHost.xdt transformation to the site folder of the app service. For example, you can override requests starting with "/blog/” or legacy files by using transformation rules.

To enable reverse proxy in Sitecore on Azure:

  1. Enable the reverse proxy functionality using the applicationHost.xdt file:

    RequestResponse
    <?xml version="1.0"?>
    
    <configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
    
    <system.webServer>
    
    <proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" reverseRewriteHostInResponseHeaders="false"/>
    
    </system.webServer>
    
    </configuration>
  2. Add a proxy rewrite rule to the web.config file:

    RequestResponse
    <rewrite>
    
    <rules>
    
    <rule name="Proxy" stopprocessing="true">
    
    <match url="^blog/?(.*)" />
    
    <action type="Rewrite" url="http://www.yourblogdomain.com/{R:1}"/>
    
    </rule>
    
    </rules>
    
    </rewrite>
  3. To make sure that Sitecore does not intercept proxy requests, add a Sitecore config patch file:

    RequestResponse
    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
    
    <sitecore>
    
    <settings>
    
    <setting name="IgnoreUrlPrefixes" value="/health/explore|/sitecore/default.aspx|..." patch:instead="setting[@name='IgnoreUrlPrefixes']"/>
    
    </settings>
    
    </sitecore>
    
    </configuration>

Prevent unexpected application pool recycling

There are multiple reasons for abrupt application pool recycling to occur. For example, the recycling can be triggered by changes of DDLs and configuration of any other files. By default, the application creates an object that monitors it for each subdirectory and initiates a recycle notification for every changed file.

To minimize the risk of an Overwhelming File Change Notifications error leading to application pool recycling, turn off the File Change Notification (FCN) setting.

To turn off FCN:

  • Add fcnMode="Disabled" to the httpRuntime section in the web.config file:

    RequestResponse
    <system.web>
            <httpRuntime fcnMode="Disabled" />
     </system.web>

Do you have some feedback for us?

If you have suggestions for improving this article,