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:
Open the Kentico administration interface of your web app.
Open the Settings application and select the Versioning & Synchronization -> Web farm category.
Set the Web farm mode to 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.
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"/>
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:
- Enable the automatic web farms feature (enabled by default on new installations)
- Set up shared storage for physical files
- 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.
- Open the Kentico administration interface.
- Open the Settings application and select the Versioning & Synchronization -> Web farm category.
- Set the Web farm mode to 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:
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.
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.
The Azure Resource Manager template (recommended to use when preparing a deployment environment for your projects in Azure) creates two separate App Service hosting plans – one for each application – for specifically this reason. This setup allows you to scale each application independently, ensuring no wasted compute allocation.
To scale out a Web App:
- Open the Azure portal and navigate to your Web App.
- Open the Scale out (App Service plan) tab.
- Manually set the required instance count or create a custom autoscale configuration.
- Repeat the process for the other application, if required.
- Configure how session data is stored.
You have configured instance scaling for your Web Apps. Learn more about Web App scaling in Microsoft Azure on Get started with Autoscale in Azure.