Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Web App not autoscaling in time

UPDATE: It appears to be working now.

I have configured our Azure Web App to scale between 4 and 10 instances for CPU load over 80% and under 60%. Autoscale settings

Our site have now been at over 95% CPU load for over two hours and no autoscaling has occurred.

When looking at the "schedule and performance rules" I see that the Duration (minutes) is 300. schedule and performance rules

I feel that this should be 10min instead but when I set it and save (with valid validation rules) I get this error:

autoscale error

Have I done something wrong or is there a bug in the portal?

After I manually increadsed to 5 and then decreased back to 4 I can see that autoscaling is working in the management services log:

ActiveAutoscaleProfile: {   "Name": "Default",   "Capacity": {
    "Minimum": "2",
    "Maximum": "10",
    "Default": "2"   },   "Rules": [
    {
      "MetricTrigger": {
        "Name": "CpuPercentage",
        "Namespace": "",
        "Resource": "xxx",
        "ResourceLocation": "West Europe",
        "TimeGrain": "PT1H",
        "Statistic": "Average",
        "TimeWindow": "PT5H",
        "TimeAggregation": "Average",
        "Operator": "GreaterThanOrEqual",
        "Threshold": 80.0,
        "Source": "xxx"
      },
      "ScaleAction": {
        "Direction": "Increase",
        "Type": "ChangeCount",
        "Value": "1",
        "Cooldown": "PT5M"
      }
    },
    {
      "MetricTrigger": {
        "Name": "CpuPercentage",
        "Namespace": "",
        "Resource": "xxx",
        "ResourceLocation": "West Europe",
        "TimeGrain": "PT1H",
        "Statistic": "Average",
        "TimeWindow": "PT5H",
        "TimeAggregation": "Average",
        "Operator": "LessThan",
        "Threshold": 60.0,
        "Source": "xxx"
      },
      "ScaleAction": {
        "Direction": "Decrease",
        "Type": "ChangeCount",
        "Value": "1",
        "Cooldown": "PT5M"
      }
    }   ] }

Description: The autoscale engine attempting to scale resource xxx' from 3 instances count to 2 instances count.

LastScaleActionTime: Wed, 03 Jun 2015 09:11:38 GMT

Microsoft.Resources/EventNameV2: Autoscale a resource.

Microsoft.Resources/Operation: Scale down

Microsoft.Resources/ResourceUri: /xxx

NewInstancesCount: 2

OldInstancesCount: 3

ResourceName: xxx

so I can see that autoscaling indeed works.

Can the value be changed programmatically?

like image 978
Martin Avatar asked Sep 27 '22 12:09

Martin


1 Answers

This appears to be a bug in the preview portal. I gave feedback on this here if you want to vote it up.

The problem has to do with the TimeGrain property that exists in the MetricTrigger as part of the autoscale rule. It appears the preview portal defaults this value to 1 hour ("PT1H") with no way to change it. This prevents you from setting a Duration in the portal to a value less than 60 minutes.

As a workaround, if you use the current portal at https://manage.windowsazure.com, and configure autoscale by CPU for your web app there, then return back to the preview portal, you will be able to set your Duration to as low as 5 minutes.

Finally, to answer your question about setting this programmatically. Yes, this is possible using the management libraries. I show how to do this here for a cloud service. But, it should be the same (or very similar) for web apps. This was over a year ago though so it may not work 100% as I wrote about, but it looks like the MetricTrigger class is still basically the same and that is where most of your attention will be.

like image 114
Rick Rainey Avatar answered Oct 06 '22 01:10

Rick Rainey