Sitecore KeepAlive config patching

The heartbeat of Sitecore is it’s keepalive.aspx which keeps Sitecore alive and working continuously. There is a good KB article provided by sitecore “Automatic site recycling after the site has been idle for a period” to understand what a KeepAlive.aspx is all about. Another good read is “Keeping Sitecore alive”.

During an implementation in a scaled environment where we had separate CM, Publishing and Aggregation cum Processing server or multiple CD servers, we need to make sure all the environments are up and running all the time. Adding the url of keepalive.aspx on a server which hits itself does not works all the times as the website might be down due to apppool recycle or the machine itself got restarted and there has been no first request yet made to sitecore. The KeepAlive agent can run only if sitecore is up and a first request has already been made after the appPool recycle.

So one of the option is to make sitecore keealive agent hit url of other servers in the vicinity.

Here’s an example for CD servers hitting each other,


<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">

<sitecore>

<scheduling>

<agent patch:before="*[@type='Sitecore.Tasks.TaskDatabaseAgent']" name="CD01" type="Sitecore.Tasks.UrlAgent" method="Run" interval="00:15:00">

<param desc="url">http://CD1hostname/sitecore/service/keepalive.aspx</param>

<LogActivity>true</LogActivity>

</agent>

<agent patch:after="*[@name='CD01']" type="Sitecore.Tasks.UrlAgent" name="CD02" method="Run" interval="00:15:00">

<param desc="url">http://CD2hostname/sitecore/service/keepalive.aspx</param>

<LogActivity>true</LogActivity>

</agent>

</scheduling>

</sitecore>

</configuration>

Example of CM, Publishing Instance and Aggregation / Processing Server hitting each other,


<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">

<sitecore>

<scheduling>

<agent patch:before="*[@type='Sitecore.Tasks.TaskDatabaseAgent']" name="CM01" type="Sitecore.Tasks.UrlAgent" method="Run" interval="00:15:00">

<param desc="url">http://CM01hostname/sitecore/service/keepalive.aspx</param>

<LogActivity>true</LogActivity>

</agent>

<agent patch:after="*[@name='CM01']" type="Sitecore.Tasks.UrlAgent" name="CD02" method="Run" interval="00:15:00">

<param desc="url">http://CM02hostname/sitecore/service/keepalive.aspx</param>

<LogActivity>true</LogActivity>

</agent>

<agent patch:after="*[@name='CM02']" type="Sitecore.Tasks.UrlAgent" name="PI01" method="Run" interval="00:15:00">

<param desc="url">http://PI01hostname/sitecore/service/keepalive.aspx</param>

<LogActivity>true</LogActivity>

</agent>

<agent patch:after="*[@name='PI01']" type="Sitecore.Tasks.UrlAgent" name="AG01" method="Run" interval="00:15:00">

<param desc="url">http://AG01hostname/sitecore/service/keepalive.aspx</param>

<LogActivity>true</LogActivity>

</agent>

</scheduling>

</sitecore>

</configuration>

 

Let’s validate what we see at /sitecore/admin/showconfig.aspx

KeepAlive-1

You might be wondering why do I need to add “name” attribute to all the agent nodes and use patch:after / patch:before. Her’s the reason why, if we use the below patching sitecore only picks the last node and ignores patching of all the other agent.


<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">

<sitecore>

<scheduling>

<!-- The time format is "HH:MM:SS" -->

<agent type="Sitecore.Tasks.UrlAgent" method="Run" interval="00:05:00">

<!-- Replace [WEBSITE] with the appropriate domain -->

<param desc="url">http://CD01hostname/sitecore/service/keepalive.aspx</param>

<LogActivity>true</LogActivity>

</agent>

<agent type="Sitecore.Tasks.UrlAgent" method="Run" interval="00:05:00">

<!-- Replace [WEBSITE] with the appropriate domain -->

<param desc="url">http://CD02hostname/sitecore/service/keepalive.aspx</param>

<LogActivity>true</LogActivity>

</agent>

</scheduling>

</sitecore>

</configuration>

The resultant config patching if seen using /sitecore/admin/showconfig.aspx would reveal that it only picked the last node of the agent.
KeepAlive-2

Leave a Reply

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