Sitecore implementation strategies to mitigate production environment issues

I’ve found the following techniques proves to be very handy in ensuring a smooth website operation, especially if you’re running a mission critical site for example an online shopping site or other high traffic site.

Feature Toggles

Feature toggles is a software design pattern which enables you to modify the behavior of the software without modifying the code – https://martinfowler.com/articles/feature-toggles.html

It’s a simple technique yet ridiculously powerful if used correctly.

We’ve used feature toggles for different reasons:

Release toggles

You have a shiny new feature that you are working on in the current release that’s half finished and not yet ready to be included in the next deployment schedule but you don’t want to keep it in a long lived feature branch? – merge it in the main branch and use feature toggle to make it dormant.

Got to deploy that new header components but it’s not a 100% done yet? – use feature toggle.

Got a cool new Sitecore renderings which displays different look and feel and defined in a custom Sitecore device? – use feature toggle to control the roll out.

Ops toggles

Got a sudden spike in server resources grinding the server to a halt due to a sudden spike in traffic ? Ideally you should plan this out with the client to mitigate the sudden traffic increase which could come from a marketing department campaign activity – if not, turn off some of the non critical and resource intensive operation in the site using feature toggle to reduce the load.

Got a poor performing functionality in the site? I hope you’re doing some sort of performance test before deploying it in the first place so you can caught it earlier  🙂 – if not, then I hope you implemented feature toggle to turn it off.

Implementation

no code example here, it’s very basic – didn’t I mention this is a very simple technique?

The core implementation that I’ve used is using Sitecore content item and item publish.

  • I have a multi site implementation
  • Each site has a feature toggles folder
  • Feature toggles folder contains different types of feature toggle Sitecore items, for example:
    • Enable new Header layout
    • Enable site notifications
    • Enable contact us email forwarding

Every feature toggles, contains the basic functionality, a single checkbox to define whether the functionality should be enabled/disabled. that’s it.

You can extend the functionality to also include IP white-listing, Country detection etc go nuts 😀

 

Sitecore Site Snippet

Another simple technique for mitigation is using Sitecore site snippet.

The site snippet I’m referring here is javascript and css hacks to modify the behavior or look and feel of the site on the browser. A sticky plaster fix if you like, it gives you the ability to fix the issue quickly without requiring file deployment and give you time to focus on doing a proper fix to be included in the next deployment schedule.

You can of course deploy a hotfix which contains js or css files which also works of course, if you have multiple Content Delivery servers make sure you have easy deployment process where you can just press a single button to get it done.. or use site snippet

Implementation

Site snippet that I’ve done is just a custom API endpoint which returns a js or css syntax

  • Define the API controller endpoints
    • /api/sitesnippet/js
    • /api/sitesnippet/css
  • I have multi site implementation
  • Each site has a Site Snippets folder
  • Site Snippets folder contains different types of snippet Sitecore items, for example
    • Hide newsletter component from footer (css)
    • Override click event from the subnav component (js)
  • Those site snippets would then be managed through a Site Snippet Configuration where admin can select which site snippet to be activated

 

CDN Cache Rules

If you’re using CDN such as CloudFlare, it can act as an Application Gateway where you can define custom rules to mitigate certain issues which occurs on your site.

Have you encountered some of these issues?

  • You have a public API endpoint which suddenly gets abused by malicious hacker
  • Certain API endpoints of your site is responding poorly and it’s affecting all the sites in the same server instance
  • etc

with CloudFlare you can block those endpoints using CF rules to prevent the issues from becoming a major disaster, providing you time to come up with proper planning to tackle the issue.

That’s all for now, let me know if you have some other techniques which you’d like to share.

Leave a Reply

Your email address will not be published. Required fields are marked *