Tuesday, 23 February 2016

Sitecore Zero DownTime Deployment..................Possible?

In Sitecore deployment its alway a issue of downtime may be couple minutes to few miute as both content delivery share same Web Database and content package installed on CM and just code drop on CDs so you alway come in situation  where you need to wait  until template/ layout deploy and then publish and site back on track. Its is Chicken and Egg situation which should deploy first and some times you need to apply some manual steps on some content before you published it.

There are couple of Ways you can deploy without down time one of the way is show in Sitecore Scaling guide for Disaster recovery servers used as temporary/ permanent switch to  live traffic for user after deployment. Which increase servers cost and lots of over heads.

My client do not wants add new servers to infrastructure  as they don't have enough resources to manage all servers and achieve No down time while deployment.

Following Diagram is very common across Sitecore deployment.
Standard Sitecore architecture  is two or more Content Delivery servers one Content Management Server one  Solr with Zookeper to sync Solr Node, Sql Cluster for Load balacing Sql. like below. I assume Core Database is required and all of us know.

There is option for solr and Lucene to switch index while rebuild index no down time for solr content. We can't use that feature as we are having Nutch for site search.




We have automated lots of  step using Teamcity and octopus steps like Sanity Check after deployment complited and generate report of any broken link or page error. I am going in to details but I am showing some basing settings  how to achive. 

There are few steps you need to do

Add new Web Publishing Target. 


Visit John West Blog or Nehemiah Jeyakumar

Add new Web Index or Any costom Index Core.

Copy existing Web Index Named "Sitecore_Web_Index or any custom and got Sitecore_web2_index
folder and find core.properties Open and change Name property  with "Sitecore_Web2_index

Update Index Update Strategies

Go to Sitecore.ContentSearch.DefaultConfigurations.config
Add following new Strategy Which allow to update index to both Solr index same time  while  normal operation of cm. So we hare update content on both solr index.

<onPublishEndAsyncWeb2 type="Sitecore.ContentSearch.Maintenance.Strategies.OnPublishEndAsynchronousStrategy, Sitecore.ContentSearch">
<param desc="database">web2</param>
<!-- Whether or not a full index rebuild should be triggered when the number of items in the EventQueue exceeds the number specified
in ContentSearch.FullRebuildItemCountThreshold. -->
<CheckForThreshold>true</CheckForThreshold>
 </onPublishEndAsyncWeb2>


 Configure Solr Index.config

Add following or as per your need

<!-- WEB INDEX configuration -->
          <index id="sitecore_web2_index" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
            <param desc="name">$(id)</param>
            <param desc="core">$(id)</param>
            <param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" />
            <configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration" />
            <strategies hint="list:AddStrategy">
              <strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsyncWeb2" />
            </strategies>
            <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>web</Database>
                <Root>/sitecore/content/home</Root>
              </crawler>
            </locations>
           <!-- <locations hint="list:AddCrawler">
              <crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
                <Database>web</Database>
                <Root>/sitecore/content/demo</Root>
              </crawler>
            </locations>-->
          </index>


Change Code  to switch index  

In our case Searcm manager configure based on one of App setting value  so we can chagne index to search content from that index.

Nutch Feeding to both Index Sitecore_Web_Index and Sitecore_Web2_Index.




Now configuration is ready All you need to run deployment in following order. We are using octopus deploy so we have lots of flexibility to chagne configuration using powershellshell script.

1. Remove one Content delivery Server from Load Balancer its depend on load balancer software API.
2. Stop Nutch for feeding index
2. Change App Setting to for Site Search TO Sitecore_Web2_Index on CM and CD both.
3. Set Default publishing target On CM only to Web2 Database. Instead of Web|Web2 in DefaultPublishingTargets in web.config file, you can set mutliple target separated by pipe
4. Set Site Definition Database Attribute to Web2 (CM and one CD)
4. Deploy Sitecore Item to  cm and code to CM and CD
5. Publish content to  Web2 Publishing target
6. Run test script to regression check of you site.


If successful  all above steps run second part of deployment.

1. Add back first server and remove other server from load balancer.

2. Change configuration for search
3. Set Site definition to Web2
3. Deploy code package to content delivery.
4. Add server To Load balancer.

Finally steps
Set DefaultPublishingTargets to Back to web|web2 on CM so manual publish sync content and update index correctly.


In Next deployment just switch web2 to web and deploy to server.

Enjoy No downtime deployment....

I have test this and with Solr index....Not tested with Lucene.













No comments:

Post a Comment