How to auto-heal your web app so you hopefully get your weekends back

Summary

This document outlines how to set up auto-healing for your web app. At times you may be enjoying your weekend and get a call telling you an app is constantly running at 100% CPU. 
Autoheal is a way to automatically recycle your app pool based on certain triggers.
I have created a POC web app with 3 instance VMs.I have turned on all diagnostic logs and set them to verbose. 
Here is the Event Log before enabling auto-heal in the web.config (there were more records but I removed them as they were all similar):













And here is the new web.config. This will recycle the app pool when we get 20 or more requests in a period of 30 seconds:









So, once this is deployed, I will call the end point 100 times in less than 30 seconds which should cause the trigger to run its action – Recycle
Here is the calling Powershell code (this just simulates a client):

$URL = ‘http://autohealingpoc.azurewebsites.net/api/values’;

$contentType = “application/json”;

for($i=1

    $i -le 100

    $i++){   

    Write-Host ‘I is: ‘ + $i;

   $response = Invoke-RestMethod -Method Get -Uri $URL -Headers $headers -ContentType $contentType;

   $response;

}


After I ran 100 requests in less than 30 seconds you can see in the event log that the instance RD0003FF857039 recycled:












When I really loaded it up, all 3 instance auto-healed:























Thanks
Russ

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s