July 15, 2014

Publishing to a Sitecore Failover Server

By: Craig Taylor
July 15, 2014

Failures happen. Source: https://flic.kr/p/aeZWUY
When designing the architecture for a highly-available website, you will want to have failover servers configured in case other servers start smoking.  This is where 'failover' servers come into play.

Failover Options

Failover configurations can either be 'cold', 'warm' or 'hot'.

These different levels of failover range from having to manually copy up data and web files when a failure happens to having the servers automatically switch over to your failover server that already has all the latest data and files in the case of a failure.  Sitecore has different licensing options depending on what you want to do, so ensure that you are licensed for your particular implementation.

A common approach would utilize SQL Server mirroring to synchronize the content, but there is another approach that can use basic Sitecore publishing to achieve the same results.

Configuring a Failover Server for Sitecore

In this example, we are assuming that the configuration being used is a 'hot' failover in which the failover system always maintains the most-recent Sitecore data.  We can utilize Publishing Targets in order to keep the failover server in sync with the production content for your site.

Create a Publishing Target in Sitecore
In the Sitecore Content Editor, simply navigate to "\sitecore\System\Publishing targets" and insert a new "Publishing target" item.  I have named my target database "Failover."

Sitecore Failover Server Publishing Target.

Now, we need to add the database reference to the web.config.  Instead of editing the web.config directly, I have created a patch include file in order to keep the config isolated.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <database id="failover" singleinstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">
        <param desc="name" />$(id)
        <dataproviders hint="list:AddDataProvider">
          <dataprovider param1="$(id)" ref="dataProviders/main">
            <prefetch hint="raw:AddPrefetch">
              <sc .include="" file="/App_Config/Prefetch/Common.config">
              <sc .include="" file="/App_Config/Prefetch/Web.config">
        <proxydataprovider param1="$(id)" ref="proxyDataProviders/main">
        <archives hint="raw:AddArchive">
          <archive name="archive">
          <archive name="recyclebin">
        <cachesizes hint="setting">

Don't forget that we need to specify a connection string for the failover database.  Edit your "connectionstrings.config" file and add the additional "failover" database connection string.  Ideally, this server/database is located in a different physical location from your other production databases.

To ensure that the data is always kept up-to-date, we need to ensure that the content authors always publish to the failover database.  Again, I include this functionality in a patch include file.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <setting name="DefaultPublishingTargets" value="Internet|Failover" />

Since the database is always selected via the "DefaultPublishingTargets" attribute and because the basic author roles of the site have no permissions to edit the publishing targets, there is no way for the content author to avoid publishing to this database.

Hopefully, you'll never need it, but now your failover environment will have all the latest content from your production website!

1 comment:

  1. Thanks for the tip here. The big disadvantage to forcing this through publishing is the impact on author that have to wait longer per publish. I like to opt for SQL mirroring or similar because it's transparent to the author. That's especially important if the failover DB is in another data center. Thanks again though!