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”;
$i -le 100
Write-Host ‘I is: ‘ + $i;
$response = Invoke-RestMethod -Method Get -Uri $URL -Headers $headers -ContentType $contentType;
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: