MS Azure Autoscaling - won't recognize target for reactive rules

425 Views Asked by At

I'm trying to setup an autoscaling solution for my Azure apps. I've got it to react to constraintRules but just can't make it react to reactiveRules.

I'm using diagnostics to log all the messages from the Autoscaling (using P&P Autoscaling Block) - so I can see that the autoscaler sees my reactive rules, but the target is not being identified. Such as this:

<TraceSource>Autoscaling General</TraceSource>
<Object>Rule match.
[BEGIN DATA]
{"EvaluationId":"67281173-085f-49a1-95f8-0b9c50a4de7d",
 "MatchingRules":
    [{"RuleName":"Default constraints for all roles",
      "RuleDescription":"SLA rule",
      "Targets":["JobsRole","RESTAPI","Web"]},
     {"RuleName":"scaleWebApi",
      "RuleDescription":"Scale up when cpu average over 5%",
      "Targets":[]},
     {"RuleName":"scaledownWebApi",
      "RuleDescription":"Scale down when cpu avg under 5%",
      "Targets":[]}]}
</Object>

Where the reactive rules are defined as:

<reactiveRules>
  <rule name="scaleWebApi"
      description="Scale up when cpu average over 5%" rank="2" enabled="true">
    <when>
       <any>
          <greater operand="RESTAPI_CPU_Avg" than="5" />
       </any>
    </when>
    <actions>
        <scale target="RESTAPI" by="1" />
    </actions>
  </rule>
  <rule name="scaledownWebApi" rank="2" enabled="true"
       description="Scale down when cpu avg under 5%">
    <when>
      <all>
        <lessOrEqual operand="RESTAPI_CPU_Avg" than="5" />
      </all>
    </when>
    <actions>
      <scale target="RESTAPI" by="-1" />
    </actions>
  </rule>
</reactiveRules>

My constraintRules - they DO work

<constraintRules>
  <rule name="Default constraints for all roles"
       description="SLA rule" enabled="true" rank="0">
    <actions>
      <range target="JobsRole" min="1" max="5" />
      <range target="RESTAPI" min="1" max="5" />
      <range target="Web" min="1" max="5" />
    </actions>
  </rule>
</constraintRules>

and my service config file (only the part of the roles)

<services>
  <service dnsPrefix="<dns>" slot="Production" scalingMode="Scale">
    <roles>
      <role alias="JobsRole" roleName="JobsRole" wadStorageAccountName="<mystore>" />
      <role alias="RESTAPI" roleName="RESTAPI" wadStorageAccountName="<mystore>" />
    </roles>
  </service>
  <service dnsPrefix="<dns>" slot="Production" scalingMode="Scale">
    <roles>
      <role alias="Web" roleName="Web" wadStorageAccountName="<mystore>" />
    </roles>
  </service>
</services>

What could be the problem and how can I try and make sense out of it?

3

There are 3 best solutions below

1
On

I can’t spot anything wrong in your config. But please make sure the target name is correct. It should be the role name. I would like to suggest you to check http://msdn.microsoft.com/en-us/library/hh680945(v=PandP.50).aspx to see whether it helps.

Best Regards,

Ming Xu.

1
On

I don't know that much about WASABi, but I would like to suggest an azure management and auto scaling SaaS service - AzureOps from Opstera, that will do this for you through simple and intuitive UI. No additional infrastructure or coding. Please check us out here AzureOps

Thanks
Opstera support

3
On

it appears to be an issue with the service information store (assuming that the operands are correctly set up, but you did not copy those in the question).

In each of the roles you define, you need to set the wadStorageAccountName to a "friendly" name, and not the actual connection string. Then in the same XML file, you define where that storage account really points to:

  <services>
    <service dnsPrefix="<dns>" slot="Production" scalingMode="Scale">
      <roles>
        <role alias="JobsRole" roleName="JobsRole" wadStorageAccountName="MyStorageFriendlyName" />
        <role alias="RESTAPI" roleName="RESTAPI" wadStorageAccountName="MyStorageFriendlyName" />
      </roles>
    </service>
    <service dnsPrefix="<dns>" slot="Production" scalingMode="Scale">
      <roles>
            <role alias="Web" roleName="Web" wadStorageAccountName="MyStorageFriendlyName" />
      </roles>
    </service>
  </services>
  <storageAccounts>
    <storageAccount alias="MyStorageFriendlyName" connectionString="DefaultEndpointsProtocol=https;AccountName=<accountName>;AccountKey=<accountKey>">
    </storageAccount>
  </storageAccounts>

Also note that this account must be the one that the target app (in this case the RESTAPI role) uploads its performance counters to (frequently), otherwise it will not find any data in order to aggregate and save it as data points.

Additionally, make sure your operands define the aggregation to happen with a time window of AT LEAST 10 minutes, otherwise due to the asynchronous nature of all these processes happening (uploading the perf counter data on one side, then aggregating the data and generating the data points, and then evaluation the rules on a separate process), then when evaluation the rules, you might not get fresh data that is newer than 5 minutes (that's why at least 10 is a good number).

I hope all of this helps clarify what's going on in Wasabi. Thanks