How to manage website Failover using AWS Route 53 and a website hosted on an external domain


You have 2 websites:

  • “”, which is the primary website, is hosted on AWS EC2 Instance supported though an ELB(Elastic Load Balancer). Please keep in mind that is just the site registrar for the site name the site is not hosted there.
  • “”, which is the secondary/failover website is hosted on domain.
  • You are using Route 53 DNS service to resolve the domains.


  • “” should be the primary website and should run when the EC2 Instance is healthy.
  • In case of failover the external website “” becomes the failover website. The requests for “” should be routed to this external secondary website in case of the primary websites failure.


  • There can be various solutions. Let’s see them one by one.
  • Solution 1:
    • It is very primitive solution. Just write a domain forwarding rule on your registered websites domain manager panel. Any requests for “futureCloud.Technology” website will automatically be forwarded to “”
    • See snapshot below:
    • godaddy forwarding
    • Issue – this is a very basic solution and AWS Route 53 never comes into picture. It should be Amazon’s Route 53 which should dictate the failover logic not registrar.


  • Solution 2:
    • We will use AWS Route 53 to dictate the website failover from Primary to Secondary.
    • I am assuming the following:
      • That you created an AWS EC2 instance. (Ideally you create a couple of Instances hosting WordPress website and couple of MySQL Instances for your site to by highly available, fault tolerant and failover tolerant. But assuming that you have installed the WordPress website only on one LAMP server (Linux, Apache, MySQL and PHP). So that in case this primary website goes down then you can run the secondary from an external domain.)
      • That you already installed and configured ‘WordPress’ on the server.
      • That this site is configured behind an ELB (Elastic Load Balancer).
      • That your primary website is running on EC2 instance and failover secondary website (“”) is running on WordPress domain.
      • That you have registered a domain name ( say at any domain registrar. I did at
    • So now let’s take the things forward from here.
      • First you will have to create a hosted zone exactly matching your registered domain name “” for your primary website in Route 53.
      • As you create a hosted zone in Route 53, it creates a couple of NS(Name Server) records. A SOA(Start of Authority) record. You will have to add a ‘A’ record for your EC2 website configured behind the ELB and another ‘A’ record for a S3 bucket (exactly matching the name of the registered website and configured as a static website). We will use this bucket for redirection.
      • See snapshot:
      • AWS Hosted ZOne futureCloud for EC2
      • AWS Hosted ZOne futureCloud for S3
  • Note down the 4 name servers and login to your registrars domain manager control panel(mine was and add those 4 entries as Name Server records.
  • See snapshot:
  • godaddy nameservers
  • Now are configured to run your primary website, go ahead and open a browser and run the website – “”.
  • See snapshot:
  • AWS S3 buckets
  • Now you have to configure the failover so that when the EC2 instance is not healthy or not running your secondary failover website should run.
  • To do that first you have to create another bucket (exactly matching the name of the external failover website “”.
  • See snapshot:
  • S3 Redirect from futureCloud S3 to wordpress S3
  • In the bucket “” configure it as a website with a redirection rule to redirect to the other bucket “”.
  • See snapshot
  • S3 Redirect from futureCloud S3 to
  • In the bucket “” configure it as a website with a redirection rule to redirect to the external website “”.
  • See snapshot:
  • AWS S3 buckets
  • In case of EC2 is not healthy or not running the request will first reach “” bucket but it will redirect to the other bucket which is configured to redirect it to your external site.
  • Go to the Route 53 to configure another “hosted zone” which exactly matched the name of the external domain name (“”) and add an ‘A’ record as failover to the bucket by the same name.
  • As EC2 instance is down, the Route 53 first looks for s3 bucket “” but sees a redirection rule for bucket “” and which in turn has a redirection to the actual external website “”. The hosted zone entry thus maps this failover and redirects you to the external website.
  • Now go to the bowser and run “”, but this time you will see that the website is redirected to “”
  • See snapshot:
  • external website running
  • All these redirection setting are being done because the AWS Route 53 is still not a very powerful DNS tool.

Thanks for reading this article. Please contact me in case you need any help. Please go to “About Us” page to view my details.


CloudWatch – a service to do EC2 Instance Health Check/Monitoring , Troubleshooting, Metrics and Analysis

The Health Check/Monitoring , Troubleshooting, Metrics and Analysis of the EC2 instances and getting timely alerts to fix the problems to keep your cloud architecture highly available, auto-scaling and fault tolerant are one of the important roles and responsibilities of a cloud architect or SysOps admin. Let’s check how we can achieve this.

So lets first try to understand what CloudWatch is – Its is a AWS’s health monitoring service to monitor the AWS resources and the applications. It can monitor the following:
– Compute resources like Auto scaling groups, Load balancers, Route 53,
– Storage resources like EBS volumes, storage gateways, Cloud Front,
– Database services like relational RDS instances, non-relational services                   like DynamoDB,
– Analytics services like Elastic Map Reduce, Red Shift,
– In-memory cache services like Elastic Cache to name a few.

The CloudWatch can monitor the following metric:
 – CPU Utilization
 – Disk Reads
 – Network In and Outs
 – Status checks
But it can’t check a few other metrics like Memory Utilization for that we have to add custom metrics, which we will see later in this post.

The default monitoring checks these metrics every 5 minutes whereas the detailed monitoring is every 1 minute.

The status checks listed above can be of two type:
 – System Status Checks – checks related to the host on which the instance                  is virtualized. E.g Loss of network or power,  software or hardware issues               on the host machine. Normally restarting/terminating the instance or                           contacting AWS are the options available.
 – Instance Status Checks – checks related to the VM(Virtual machine) itself.               E.g. memory leaks, corrupted file system, incompatible file system,                                  mis-configured network. Normally restarting/terminating the instance or               checking/trouble shooting your own application for bugs are the options.

On the AWS console go to the CloudWatch service :
 – Click “Create dashboard”
 – Add a widget to dashboard based on the metrics listed above
 – Save the dashboard.(See snapshot below)

Now what if we want to monitor a custom metrics(Memory Utilization) which is not monitored by default by CloudWatch. Well then we have to use some custom scripts for it. Lets see how it is done.

- Install the required packages:
 sudo yum install perl-Switch perl-DateTime perl-Sys-Syslog perl-LWP-Protocol-https
- Download the CloudWatch Custom Monitoring Scripts:
 curl -O
- Unzip the scripts:
 cd aws-scripts-mon
- Execute the script(You will get a "Successfully reported metrics to CloudWatch. Reference Id: 84bf63d3-2841-11e7-a20f-7786b8297dbd
" message on success):
 ./ --mem-util --mem-used --mem-avail
- Add a crontab job for 5 minutes intervals:
 */5 * * * * ~/aws-scripts-mon/ --mem-util --disk-space-util --disk-path=/ --from-cron

Once you have run these scripts successfully, the custom metrics for memory utilization will also be available and you can add it as a widget. See below.

Very Intuitive and Easy going step by step AWS tutorial for Beginners

Please try this link –

I have tried a lot of sites like,, etc to name a few, but the best one is this one.

It is very intuitive and easy going step by step AWS tutorial for Beginners. In which it helps you to create a highly available, auto-scaling WordPress website using EC2 instances, MySQL database over a pair of public subnets hosting the instances, a pair of private subnets hosting the databases enforced with load balance and Route53 DNS Management. Further is also uses CloudFront as CDN for website media, Cloudwatch and SNS for Alerts, Failover management.

I have never seen all this much put into one tutorial. In fact this website is hosted using the same approach. If you are an AWS enthusiast, this website will give you the fire in you to start sailing on this AWS boat and charm to dive deeper to learn more and advanced topics and services in AWS.

Wish you guys best of luck.


Compare Sitecore Vs Solr Items

Have you ever faced any urgent Production issue where your deployment succeeded and site is working fine and then you come to know that the number of items in the Solr and Sitecore don’t match and you also want to see the delta of those differences. You can also use this information to setup a threshold to setup alerts if the mismatch of items surpasses a defined limit(I used Amazon’s SNS(Simple Notification Service) to notify via email and text to the Production SWAT team as soon as threshold passed the limit)

This Powershell script will be very handy for you. The base idea is that you get detaisl of items from your Sitecore master and web database and also Solr master and web databases. Once you have these JSONs in hand comparing those objects would not be that difficult. Just filter out the columns you need and you are good to go.

//First Get Items From Sitecore Master Database
$childsMaster = Get-ChildItem master:/sitecore/content/../Products -Language * -Version *
write-host “Count of items Product Catalog(Master): ” $childsMaster.length

//Then Get Items From Sitecore Web Database
$childsWeb = Get-ChildItem web:/sitecore/content/../Products -Language * -Version *
write-host “Count of items Product Catalog(Web): ” $childsWeb.length

//Then Get Items From Sitecore Solr Master
$items_catalog_index_master = wget “*&fq=_language%3Aen-CA&rows=9999&fl=marketsku_s&wt=json&indent=true” | ConvertFrom-Json
write-host “Count of items catalog_index_master: ” $items_catalog_index_master.response.numfound

//Then Get Items From Sitecore Solr Slave
$items_catalog_index_web = wget “*&fq=_language%3Aen-CA&rows=9999&fl=marketsku_s&wt=json&indent=true” | ConvertFrom-Json

write-host “Count of items catalog_index_web: ” $items_catalog_index_web.response.numfound

write-host “Compare Sitecore Master Vs Web Databases”

Compare-Object $childsMaster $childsWeb -PassThru
write-host “Compare Sitecore Solr catalog_index_master Vs catalog_index_web”

Compare-Object ($ ($

write-host “Compare Master Database Vs Solr catalog_index_web”
Compare-Object ($childsMaster.comparefieldname) ($ -PassThru

Latest AWS Certifications

Now a days I am very fascinated with Cloud Technology and Big Data. These are the technologies of the future and have immense potential and thus have been working hard for the past 6 months and did clear these 2 certifications:

– AWS Certified Solutions Architect – Associate

– AWS Certified Developer – Associate

Next in target are –

– AWS Certified SysOps Administrator – Associate

– AWS Certified Bigdata Certification

– AWS Certified Security Certification

Sitecore Errors




So here is the scenario

You are running the home page of a Sitecore website.

–        The page runs perfectly from the CD servers

–        The page runs perfectly from the “Experience editor” mode from the CM servers

–        But when you run the page from “Preview” mode from CM servers, it give you above error

You are redirected to the no layout error page like this:

Well, now if you manually create this URL – %7D&sc_mode=preview&sc_lang=en

Now preview works, and this is a very annoying error.


There can be multitude of reasons for the error, as you don’t know if this is a publishing issue, or security issues as Preview mode used anonymous user to show the item and if the item does not has anonymous access enabled you might have got this error. We tried to fix the problem by targeting these probable causes. But nothing was working.


So after lot of toiling we figured out that this was the reason for the error –

In preview mode Sitecore looks for the item configured in preview database in CM server pointing to preview. But if that CM server is not configured then you will get this error.


On CM servers, if the Preview servers are not configured, then the database must be pointing to “Master” for preview proposes.

Go to Site settings of the website in Sitecore.config( location: WebsiteApp_ConfigInclude)


<site name=”website” enableTracking=”true” virtualFolder=”/” physicalFolder=”/” rootPath=”/sitecore/content” startItem=”/home” database=”master” domain=”extranet” allowDebug=”true”cacheHtml=”true” htmlCacheSize=”50MB” registryCacheSize=”0″ viewStateCacheSize=”0″ xslCacheSize=”25MB” filteredItemsCacheSize=”10MB” enablePreview=”true” enableWebEdit=”true”enableDebugger=”true” disableClientData=”false” cacheRenderingParameters=”true” renderingParametersCacheSize=”10MB”/>

Sitecore 8.1 and Active Directory 1.3 Integration

Sitecore 8.1 AD 1.3 Module Integration

Integrating the Active Directory module with Sitecore allows you to import, authenticate and manage the AD users, roles and profiles inside the Sitecore.


Let’s assume that we want to accomplish the following:

–        We have a Sitecore Instance already running and we want to integrate the AD users, roles and profiles of our company for authenticating and managing permissions on the Sitecore items

–        So we need to first import the users, roles and profiles list inside Sitecore user manager, role manager and then assign appropriate permissions to the users.

–        So let’s try to accomplish this

o    First lets integrate the AD

o   Assign proper permissions to the AD users to access Sitecore Items


ð  AD Integration:

–        First we will have to setup an Sitecore instance if we are starting from scratch else we can use an existing instance.

–        Then we will install the “Active directory Module 1.3”(for Sitecore 8.2). Sitecore provides a matrix as if which AD module works with which Sitecore version.

–        After installing proper AD module,  we will configure, verify and test the AD integration.

–        Note : Please backup your existing instance source files, databases, configs in case a rollback is needed.


1-     First of all Setup a banana Sitecore Installation using The 8.2 Sitecore Installer from (if starting from scratch)-

(Use the web installer Sitecore web application installer)


2-     InstallAD 1.3 Module” package  from – (Use Active Directory 1.3 rev.161017)

o   After installation verify the following changes to the Sitecore website folder

  • App_ConfigIncludeldap.config – provides LDAP Confuguration
  • BinLightLDAP.dll – LDAP DLLs
  • BinLightLDAPClient.dll – LDAP DLLs
  • SitecoreadminLDAPLogin.aspx – Single sign-on page
  • SitecoreadminProviderStatus.aspx – AD status page


3-     Perform the following Configuration changes for AD to work with Sitecore :

  1. ConnectionStrings.config

Add LDAP Connection string under <connectionStrings> section.

Note: ‘’ the AD server name.

<add name=”LDAP_CONN” connectionString=”LDAP://,DC=com” />

  1. Domains.config

Add a new domain under <Domain> section.

Note: “usa” is the domain name.

           <domain name=”usa” ensureAnonymousUser=”false” />

  1. Sitecore.config

Update the <switchingProviders> section.

In the switching provider section you have to provide additional settings for membership, role manager and

profile settings specifying what the new AD providers are. See the bold entries below



<provider providerName=”sql” storeFullNames=”true” wildcard=”%” domains=”*” />

      <provider providerName=”ad” storeFullNames=”false” wildcard=”*” domains=”usa” />



<provider providerName=”sql” storeFullNames=”true” wildcard=”%” domains=”*” ignoredUserDomains=”” allowedUserDomains=”” />

<provider providerName=”ad” storeFullNames=”false” wildcard=”*” domains=”usa” />



<provider providerName=”sql” storeFullNames=”true” wildcard=”%” domains=”*” ignoredDomains=”” />



  1. Web.config

Update the <membership>, <rolemanager> and <profile> sections as below.

These settings specify 2 things- one who is the new membership, role or profile provider and second that you are switching the provider from SQL to the one you are adding.

<membership defaultProvider=”sitecore” hashAlgorithmType=”SHA1″>


<clear />

<add name=”sitecore” type=”Sitecore.Security.SitecoreMembershipProvider, Sitecore.Kernel” realProviderName=”switcher” providerWildcard=”%” raiseEvents=”true” />

<add name=”switcher” type=”Sitecore.Security.SwitchingMembershipProvider, Sitecore.Kernel” applicationName=”sitecore” mappings=”switchingProviders/membership” />

<add name=”sql” type=”System.Web.Security.SqlMembershipProvider” connectionStringName=”core” applicationName=”sitecore” minRequiredPasswordLength=”1″ minRequiredNonalphanumericCharacters=”0″ requiresQuestionAndAnswer=”false” requiresUniqueEmail=”false” maxInvalidPasswordAttempts=”256″ />

<add name=”ad” type=”LightLDAP.SitecoreADMembershipProvider” connectionStringName=”LDAP_CONN” applicationName=”sitecore” minRequiredPasswordLength=”1″ minRequiredNonalphanumericCharacters=”0″ requiresQuestionAndAnswer=”false” requiresUniqueEmail=”false” connectionProtection=”Secure” connectionUsername=”LDAP-Server-UserName” connectionPassword=” LDAP-Server-Password” attributeMapUsername=”sAMAccountName” enableSearchMethods=”true” enablePasswordReset=”false” />



<roleManager defaultProvider=”sitecore” enabled=”true”>


<clear />

<add name=”sitecore” type=”Sitecore.Security.SitecoreRoleProvider, Sitecore.Kernel” realProviderName=”switcher” raiseEvents=”true” />

<add name=”switcher” type=”Sitecore.Security.SwitchingRoleProvider, Sitecore.Kernel” applicationName=”sitecore” mappings=”switchingProviders/roleManager” />

<add name=”sql” type=”System.Web.Security.SqlRoleProvider” connectionStringName=”core” applicationName=”sitecore” />

<add name=”ad” type=”LightLDAP.SitecoreADRoleProvider” connectionStringName=”LDAP_CONN” applicationName=”sitecore” attributeMapUsername=”sAMAccountName” cacheSize=”2MB” username=” LDAP-Server-UserName ” password=” LDAP-Server-Password” />




<profile defaultProvider=”switcher” enabled=”true” inherits=”Sitecore.Security.UserProfile, Sitecore.Kernel”>


<clear />

<add name=”sql” type=”System.Web.Profile.SqlProfileProvider” connectionStringName=”core” applicationName=”sitecore” />

<add name=”switcher” type=”Sitecore.Security.SwitchingProfileProvider, Sitecore.Kernel” applicationName=”sitecore” mappings=”switchingProviders/profile” />



<clear />

<add type=”System.String” name=”SC_UserData” />



4-     Verify AD Integration:

  1. Execute page – http://sitename/sitecore/admin/ProviderStatus.aspx(e.g. http://testad/sitecore/admin/ProviderStatus.aspx )
  2. It will show which Provider is active for which domain

See snapshot




5-     Verify from Sitecore admin:

  • Open Sitecore user manager and role manager to verify that you have successfully imported the AD users and roles.


6-     Filtering the AD users to get selective users:

  • In the “ad” provider stringers in the membership, role manager or profile strings you can add this extra filter.
  • The highlighted filter will only pull “members of Lead developers from Developers Group from the AD Organization”

<add name=”ad” type=”LightLDAP.SitecoreADMembershipProvider” connectionStringName=”LDAP_CONN” applicationName=”sitecore” minRequiredPasswordLength=”1″ minRequiredNonalphanumericCharacters=”0″ requiresQuestionAndAnswer=”false” requiresUniqueEmail=”false” connectionProtection=”Secure” connectionUsername=”LDAP-Server-UserName” connectionPassword=” LDAP-Server-Password” attributeMapUsername=”sAMAccountName” enableSearchMethods=”true” enablePasswordReset=”false” customFilter=”(memberOf=CN=Lead Developers,OU=Developers Group,OU=USA,DC=mywebsite,DC=com)” />


ð  Assigning permissions to users:

–        There are multiple ways to assign permissions to the Sitecore items to these users. It would be a different topic to discuss.

–        But let me provide an example how I can add permissions using a Sitecore PowerShell script.

–        The script(e.g. this script assigns permissions of “Sitecore Author” to all Lead developers)

$userIdentity = “usaLead Developers

$userPassword = “SitecorePassword”

$users = Get-User $userIdentity -ErrorAction SilentlyContinue

foreach ($user in users) {

if($user -eq $null) {

Add-Rolemember -Rolename “sitecoreAuthor” -MemberName $users