Kentico 8 Technology – Web farm synchronization

This article is going to show you more details about web farm synchronization methods available in Kentico. Understanding the way these methods work can be a critical aspect in choosing an appropriate synchronization method to achieve the required performance for your web farms. At the end of the article, we will focus on a new way of registering custom web farm task in Kentico 8.
Website performance and availability has become one of the key success factors for most present-day web projects. Even short unavailability or performance degradation affects user website satisfaction and can cause thousands or millions of dollars in revenue losses. More and more often, companies decide to scale their website horizontally by building a server farm to fulfill high availability and performance requirements, bringing whole new challenges such as synchronization of content or physical file changes across website servers.

To help developers and system administrators deal with these challenges, Kentico contains the web farm module, which offers different types of synchronizations. In Kentico 8, part of the web farm module was rewritten to offer even better performance and reliability.

Configuring web farm synchronization to fit your needs

When an editor make a change in web site content or physical files used by a web site on any particular web farm server, this web farm server logs information into the database about these changes in a form of web farm tasks, and notifies other web farm servers about these changes. You can easily change the type of changes you want to log and synchronize across web farm servers as well as the way in which web farm servers will be notified about these changes in the Settings application.

While setting of synchronized changes is really simple, choosing the appropriate method of web farm synchronization can be more difficult and often differs according to your particular application. Kentico 8 offers these three types of web farm synchronization:

  • By request using URL notifications
  • Using scheduled task
  • Using database updater
Each of these methods has its pros and cons, so let’s take a look at these methods in more detail.

Synchronization by request

Synchronization by request is the default method used by Kentico when you enable the web farm module and is represented by the Update within request setting. This method uses the Server URL value stored in the web farm server object to notify other web farm servers about new web farm task.

For each generated web farm task, an HTTP request is issued to the synchronization page located on the target web farm server to synchronize changes. For this method it is required that every server in the web farm must be able to access each other. In some cases, this may cause issues for a few network infrastructures, especially when addresses of the servers can change in time or there is no simple way to determine them.

Synchronization by request is more suitable for projects that aren’t heavily edited because quite a few requests can be issued in a short time period, causing unwanted traffic to target servers and clearing cache too often (especially under heavy load).   

Synchronization using scheduled task

To use a scheduled task to process web farm tasks, you must ensure that neither Update within request nor Use web farm database updater settings are checked, and that the Synchronize web farm changes scheduled task is enabled.

In comparison with synchronization by request, you have the opportunity to set periodicity of synchronization, allowing you to process generated web farm tasks in a batch. You can even set scheduled task to run in a separate thread; together with a configuring scheduler to run as an external service, you can transfer the processing of web farm tasks out of the website, reducing possible overhead.

Synchronization using a scheduled task offers enhanced performance and wider possibilities of configuration at the cost of enabling scheduler. Also, in some cases, configuring the scheduler to run in an external application can be difficult, thereby losing the biggest benefit of this synchronization method.

Synchronization using the database updater

Using the database updater is recommended for most of the projects. Synchronization is achieved by long running thread, which periodically checks for new web farm server tasks available for synchronization. It is ensured one thread is always running on the web farm server, and even if the thread was terminated, a new one is created to ensure proper synchronization.

Same as synchronization using a scheduled task, the database updater is working in every environment. In addition to that, it doesn’t require any special configuration or technology to work. Database updater is also the only available synchronization method for automatically generated web farm servers and is often used on Microsoft Azure.

Web farms on Microsoft Azure

Microsoft Azure offers multiple tiers of cloud computing services as Virtual machine, Cloud service or website you can run Kentico on. The web farm module is supported on every one of them, requiring a slightly different configuration in each case.

Virtual Machines

Azure virtual machines offer the most complex and extensive web farm configuration options. You can choose any of the web farm synchronization mechanisms presented as well as decide if you will configure web farm servers manually or generate them automatically.

Cloud Services

You will find that this situation is quite the opposite when you are running Kentico on a cloud service. Independent of your settings, web farms are always enabled together with automatically generated web farm servers, forcing the database updater as a synchronization mechanism. This allows you to easily add or remove computing instances, thereby keeping the web farm synchronized.  


The same automatic configuration is set when you use Kentico from an application gallery on Azure web sites.

But in case you decide to deploy your standard Kentico installation to the Azure website, you mustn’t forget to enable automatic servers’ generation and restart application to ensure the creation of web farm servers. In case you are using multiple instances already, it is recommended to downscale to one instance, restart the application, and then upscale back to the desired number of instances.

Defining the custom web farm task

Apart from the standard customizations, the web farm module offers the ability to define custom web farm tasks. This comes in handy when you extend Kentico with your own functionality or module, directly working with the application's memory or file storage. In Kentico 8 we have simplified this task to call one simple method - WebFarmHelper.RegisterTask(…).
So, defining your own custom task within your module can look like the following code:

using CMS; using CMS.Core; using CMS.DataEngine; using CMS.EventLog; using CMS.Helpers; [assembly: RegisterModule(typeof(MyCustomModule))] /// <summary> /// Represents the custom module /// </summary> public class MyCustomModule : Module { /// <summary> /// Defining custom module /// </summary> public MyCustomModule() : base("MyCustomModule") { } /// <summary> /// Initializes the module /// </summary> protected override void OnInit() { base.OnInit(); WebFarmHelper.RegisterTask("MyCustomTask", ProcessMyCustomTask, MyCustomTaskCondition); } /// <summary> /// Indicates if customer web farm task MyCustomTask should be processed /// </summary> private bool MyCustomTaskCondition() { return true; } /// <summary> /// Handlers 'MyCustomTask' web farm task processing /// </summary> private void ProcessMyCustomTask(string taskTarget, string taskData, BinaryData binaryData) { // Logs a record into the system's event log, with 'Processing task' as the event code and task target and data as description EventLogProvider.LogInformation("MyCustomTask", "Processing task", string.Format("Task target: {0} \nTask data:{1}", taskTarget, taskData)); } }

Wrap up

Now you should know all about web farm synchronization methods available in Kentico, and the method in particular that you should choose for your project. You are also able to define your own custom web farm tasks.

If you are still hesitating with your choice of a suitable web farm synchronization method for your project or have other questions about web farms module, let us know! You can always leave us a comment below.
Share this article on   LinkedIn

Zbysek Nemec

Hi, I'm Technical Leader here in Kentico primarily responsible for cloud technologies (Microsoft Azure, Amazon, etc.) and Kentico+.


kentico_zbysekn commented on

Hi Laurin,
please contact our support department using email and we will try to help you resolve the issue you are facing now.
Best Regards,

Laurin commented on

Hi Zbysek
Thanks for this interesting blog.
We configured everything according your description. it worked well on a azure website. yesterday we scaled up to 3 instances - everything still worked great. now we needed to downscale again. Since then we are unable to login to the administration and kentico throws multiple errors. do you have an idea what could happend??
It means:

System error

An error occurred processing your request at URL /CMSPages/logon.aspx.

Click here to go back to the home page

This is really really critical to us, since we can not manage the system anymore.
Do you have any idea?