Azure Web App 没有及时自动缩放
Azure Web App not autoscaling in time
更新:它现在似乎可以正常工作了。
我已经将我们的 Azure Web 应用程序配置为在 4 到 10 个实例之间扩展 CPU 负载超过 80% 和低于 60%。
我们的网站现在已经超过 95% CPU 负载超过两个小时,并且没有发生自动缩放。
查看 "schedule and performance rules" 时,我看到持续时间(分钟)为 300。
我觉得这应该是 10 分钟,但是当我设置它并保存时(使用有效的验证规则)我得到这个错误:
是我做错了什么还是门户中有错误?
在我手动增加到 5 然后又减少到 4 之后,我可以在管理服务日志中看到自动缩放正在运行:
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
所以我可以看到自动缩放确实有效。
可以通过编程方式更改值吗?
这似乎是预览门户中的错误。如果你想投赞成票,我就此 here 提供了反馈。
问题与作为自动缩放规则的一部分存在于 MetricTrigger 中的 TimeGrain 属性 有关。预览门户似乎将此值默认为 1 小时 ("PT1H"),无法更改。这会阻止您将门户中的持续时间设置为小于 60 分钟的值。
作为解决方法,如果您在 https://manage.windowsazure.com 使用当前门户,并通过 CPU 为您的 Web 应用配置自动缩放,然后 return 返回预览门户,您将能够将您的持续时间设置为低至 5 分钟。
最后,回答您有关以编程方式设置此问题的问题。是的,这可以使用管理库。我展示了如何为云服务执行此操作 here。但是,它应该与网络应用程序相同(或非常相似)。这是一年多以前的事了,所以它可能不会像我写的那样 100% 工作,但看起来 MetricTrigger class 仍然基本相同,这就是你的大部分注意力所在。
更新:它现在似乎可以正常工作了。
我已经将我们的 Azure Web 应用程序配置为在 4 到 10 个实例之间扩展 CPU 负载超过 80% 和低于 60%。
我们的网站现在已经超过 95% CPU 负载超过两个小时,并且没有发生自动缩放。
查看 "schedule and performance rules" 时,我看到持续时间(分钟)为 300。
我觉得这应该是 10 分钟,但是当我设置它并保存时(使用有效的验证规则)我得到这个错误:
是我做错了什么还是门户中有错误?
在我手动增加到 5 然后又减少到 4 之后,我可以在管理服务日志中看到自动缩放正在运行:
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
所以我可以看到自动缩放确实有效。
可以通过编程方式更改值吗?
这似乎是预览门户中的错误。如果你想投赞成票,我就此 here 提供了反馈。
问题与作为自动缩放规则的一部分存在于 MetricTrigger 中的 TimeGrain 属性 有关。预览门户似乎将此值默认为 1 小时 ("PT1H"),无法更改。这会阻止您将门户中的持续时间设置为小于 60 分钟的值。
作为解决方法,如果您在 https://manage.windowsazure.com 使用当前门户,并通过 CPU 为您的 Web 应用配置自动缩放,然后 return 返回预览门户,您将能够将您的持续时间设置为低至 5 分钟。
最后,回答您有关以编程方式设置此问题的问题。是的,这可以使用管理库。我展示了如何为云服务执行此操作 here。但是,它应该与网络应用程序相同(或非常相似)。这是一年多以前的事了,所以它可能不会像我写的那样 100% 工作,但看起来 MetricTrigger class 仍然基本相同,这就是你的大部分注意力所在。