Search code examples
azureazure-web-app-service

Azure Scale Out on Memory keeps flapping (not scaling in)


I'm trying to set up an auto-scale on Azure to scale out when 5-min average memory exceeds 90%.

Here's a 24-hour chart of 1-min memory usage:

enter image description here

I have a scale-out rule for 5-min average memory from 1 to 2. I have a scale-in rule when average 5 min memory is under 80%. Admittedly this is quite tight. However, the scale in NEVER seems to fire, it's always prevented by 'flapping'. Surely given the chart above there would be several places where it could scale in? (I don't even see where a 5-min average would be triggered for the scale up, given the chart is a 1-min average).


Solution

  • I've also discovered that scaling out based on memory percentage gets tricky with smaller instance sizes; that's because Azure fails to recognize that the greater part of the memory used is actually dedicated to the OS and other infrastructure...

    Here you can find a quite exhaustive explanation: https://medium.com/@jonfinerty/flapping-and-anti-flapping-dcba5ba92a05.

    There seem to be no workarounds and I'm considering letting it go (and only scale out and in based on CPU).