Thursday, October 2, 2014

Sitecore's HeartBeat.aspx for Load Balancer Health Checks

Sitecore includes a HeartBeat page so that you can point your loadbalancer's health check at it to determine if that current machine is healthy and should take traffic.  It is a very simplistic health check but it is probably sufficient for basic Sitecore implementations.

The functionality of the included HeartBeat.aspx will enumerate all of your connection strings and try to make a simple connection over to the database.  If everything checks out Sitecore will generate a blank page with a standard HTTP 200 response.  If there are any issues connecting to any of the databases this page will return an HTTP 500 response.

There are two issues you need to be aware of if you are using this page.

Machine.Config Connection String
NET 4.5 typically configures a default ASP.NET membership provider connection string in the machine.config.  This typically points to .\SQLEXPRESS and thus out of the box the heartbeat page will fail on servers that do not have SQL Express installed.

The best approach is to just clear connection strings before you add in your Sitecore connection strings.  You could take the approach of editing the machine.config but that may not be as maintainable.
  • Clear existing connection strings before loading your Sitecore Connection Strings
    • Open \App_Config\ConnectionStrings.config
    • Add <clear /> directly under the <connectionStrings> node
Active Directory or other non-database Connection Strings
If you have your Sitecore instance configured to use the Active Directory Module you are probably adding your Active Directory connection strings to your main ConnectionStrings.config file.  These will fail the database check since they are not database connection strings.

The best way to resolve this issue to add a Sitecore setting to exclude specific connection strings from the Heart Beat check.  This setting is not configured in the default Web.Config file that is configured by Sitecore.  You can add it by including this patch config: