Thursday, November 29, 2018

Slow start up time of Sitecore 9 in Azure

Not that long ago we were launching a new Sitecore 9 site in Azure and ran into a big issue with start up time. It was taking over 20 minutes for the application to start from an application pool recycle or a hard stop/start. After countless hours of debugging and running traces, we figured it out. So if you are running into a similar situation, maybe this post will help.

MVC 5

It turns out MVC 5 is mostly to blame for this slowness. There is a very good article written by David De Sloovere that you can read at http://blog.deltacode.be/2017/01/08/fix-slow-startup-of-asp-net-mvc-5-on-azure-app-services/. It covers all configurations and parameters that are needed to make your build pre-compile the views.

In case of Sitecore application, we ended up compiling all views including the Sitecore ones. We have several modules installed in our solution, so the views from those had to be pre-compiled as well. We used aspnet_compiler.exe tool to do that.

Technically, it is really good when you pre-compile the views even for catching the missing references or other problems in the Views before the code gets to target environment. However precompiling the views in local environment will take much longer that a developer would want to work efficiently.

Application Initialization

Another thing that was discovered that might not affact the start up time, but it does affect the moment when application is considered fully loaded. 
<system.webServer>
    <applicationInitialization doAppInitAfterRestart="true">         
        <add initializationPage="/sitecore/service/heartbeat.aspx" />
        <add initializationPage="/"  />  <!-- home page must load --> 
        <!-- put here all urls that must be loaded before the application is considered 
 to be fully loaded: landing pages, etc. -->
    </applicationInitialization>

This is more important for the Auto-scaling in Azure.


No comments:

Post a Comment