azureazure-web-app-servicedevopsautoscalemode

Automatically restart ONE single instance when CPU hits 90% on Azure App Autoscale and load balance?


Azure Dashboard

I've been having issues with Azure App Autoscale. The main instance (ends with YX) always gets overloaded no matter how many other instances I add.

When the app's average CPU reaches 60%, I add one more instance.

When the average response time gets high, the app becomes unresponsive.

I am able to resolve the issue from time to time by manually restarting the primary instance.

I leave Health Check enabled, but it never restarts the instance on its own, as it still has the Healthy status.

Is there a way to automatically restart ONE single instance when the CPU hits avg 90%?

... or maybe another way to better allocate the resources?

Thank you.


Solution

  • What you're looking for is Azure App Service auto healing. There are two different types that you'll want to consider.

    1. Auto Heal allows you to set up mitigation actions based on what conditions are present in your app. You define conditions and actions to take when those conditions are present. There isn't a condition for CPU usage, but there are for request duration, memory limits, request counts, and status codes. You can address your problem by setting auto-heal rules based on these other metrics.

    enter image description here

    1. The second option is proactive auto-heal. Proactive auto-heal will monitor your entire application and restart it if it determines that it's in a "bad state" based on memory usage and request time.

    enter image description here

    You can get to these options through your app service's "Diagnose and solve problems" blade.

    enter image description here

    It's under "diagnostic tools".

    enter image description here