Enabling web farms on Azure Web Apps

Microsoft Azure Web Apps allow you to scale the computing power (scale up) and the number of instances your application is replicated on (scale out), enabling you to increase the performance and throughput as necessary. Learn more about web app scaling in Microsoft Azure on Get started with Autoscale in Azure.

We only support this functionality for web hosting plans with a Basic or higher pricing tier.

Continue depending on your site’s development model:

Portal Engine

For the scale out functionality to work with Kentico Portal Engine sites, you need to enable automatic Web farms.

To enable and configure Web farms in your Kentico application:

  1. Open the Kentico administration interface of your web app.

  2. Open the Settings application and select the Versioning & Synchronization -> Web farm category.

  3. Set the Web farm modeto Automatic.

    • This setting allows the system to generate and delete web farm servers dynamically according to the allocated computing instances.
    • See Setting up web farms for more information.
  4. Add the CMSSharedFileSystem key to the web.config file of your application. The key disables the generation of web farm tasks related to synchronization of physical files (media library items, smart search indexes, etc.). This is required since scaled App Services share physical storage. By default when synchronizing file system changes, the system creates a web farm task for every known web farm instance. For example, this occurs every time an image is uploaded or modified – an instance needs to relay information about the change to every other instance. In shared file system environments, such as the one provided when scaling Azure App Services, this can lead to deadlocks (when multiple instances attempt to concurrently access the same physical file while processing a web farm task).

    
    
    
     <add key="CMSSharedFileSystem" value="true"/>
    
    
     
  5. Configure storing of session state data.

You can now increase or decrease the number of computing instances for your web app (in the Windows Azure Management Portal on the Scale out (App service plan) tab of your App service). The system generates web farm servers and synchronization tasks automatically.

MVC

For the scale-out functionality to work with Kentico MVC environments, you need to:

  1. Enable the automatic web farms feature (enabled by default on new installations)
  2. Set up shared storage for physical files
  3. Scale-out the deployed web apps using Azure

Enabling automatic web farms

To run a Kentico MVC environment in Microsoft Azure, your projects need to use the Automatic web farm functionality. It is not possible to manually set up static web farm servers since server names in Azure change every time the application is recycled or a new instance spins up. Newly installed projects have automatic web farm server detection enabled by default.

  1. Open the Kentico administration interface.
  2. Open the Settings application and select the Versioning & Synchronization -> Web farm category.
  3. Set the Web farm modeto Automatic.

The automatic web farm feature is enabled. The system now dynamically generates and removes web farm servers according to the number of detected active instances and generates synchronization tasks automatically.

Setting up shared storage for physical files

Scaled out app service instances share the file system of the original application, which can cause issues with the synchronization of files in Kentico web farm environments. By default when synchronizing file system changes, the system creates a web farm task for every known web farm instance. For example, this occurs every time an image is uploaded or modified – an instance needs to relay information about the change to every other instance. In shared file system environments, such as the one provided when scaling Azure App Services, this can lead to deadlocks (when multiple instances attempt to concurrently access the same physical file while processing a web farm task).

To avoid any potential synchronization issues, we strongly recommend you:

  1. Map the following folders from both projects to storage shared by both web apps (to ensure files are accessible from both the administration and MVC sites):

    • ~/App_Data/CMSModules/SmartSearch – Contains smart search index files.
    • ~/##SiteFolder## – named after the site’s code name. Contains primarily media library files and documents.These folders contain all files Kentico synchronizes via web farms.
  2. Add the CMSSharedFileSystemkey to the web.config of both applications. The key disables the generation of web farm tasks related to synchronization of physical files (media library items, smart search indexes, etc.).

    
    
    
     <add key="CMSSharedFileSystem" value="true"/>
    
    
     

With this configuration, the system does not need to create web farm synchronization tasks for physical files as they are available to both instances from dedicated shared storage. This neutralizes any potential issues with web farm synchronization. 

Scaling out deployed web apps

Kentico uses a dual-application environment where the front-end application serves content and receives the bulk of visitor traffic. The administration application manages and stores content and generally experiences lesser load. Therefore, when deciding how to scale-out your deployment environment, consider prioritizing the front-end application.

To scale out a Web App:

  1. Open the Azure portal and navigate to your Web App.
  2. Open the Scale out (App Service plan) tab.
  3. Manually set the required instance count or create a custom autoscale configuration.
  4. Repeat the process for the other application, if required.
  5. Configure how session data is stored.

You have configured instance scaling for your Web Apps. Learn more about Web App scaling in Microsoft Azure in Get started with Autoscale in Azure.