Azure批处理自动缩放公式

huangapple go评论54阅读模式
英文:

Azure batch auto scale formula

问题

我正在尝试创建一个始终从1个节点开始的池。在超过70%的CPU使用率持续3分钟后,池应该生成另一台机器,然后重复。
我正在使用当前的公式:

initialPoolSize = 1;
$TargetDedicatedNodes = initialPoolSize;
$totalDedicatedNodes =
    (avg($CPUPercent.GetSample(TimeInterval_Minute * 3)) >= 0.7) ?
    ($TargetDedicatedNodes + 1) : $TargetDedicatedNodes;

我还尝试使用Microsoft文档中发布的以下公式:

initialPoolSize = 1;
$TargetDedicatedNodes = initialPoolSize;
$totalDedicatedNodes =
    (min($CPUPercent.GetSample(TimeInterval_Minute * 3)) > 0.7) ?
    ($CurrentDedicatedNodes * 1.1) : $CurrentDedicatedNodes;

这两个公式都不起作用,整个构建时间内我一直只有1个节点,并且CPU使用率达到了100%。

如果有人对此有任何经验或可以提供帮助,将不胜感激。

英文:

I'm trying to create a pool that always starts with 1 node. After 3 minutes of having more than 70% CPU usage the pool should generate another machine, and repeat.
I'm using the current formula:

initialPoolSize = 1;
$TargetDedicatedNodes = initialPoolSize;
$totalDedicatedNodes =
    (avg($CPUPercent.GetSample(TimeInterval_Minute * 3)) >= 0.7) ?
    ($TargetDedicatedNodes + 1) : $TargetDedicatedNodes;

I also tried using this formula that is posted in the Microsoft documentation:

initialPoolSize = 1;
$TargetDedicatedNodes = initialPoolSize;
$totalDedicatedNodes =
    (min($CPUPercent.GetSample(TimeInterval_Minute * 3)) > 0.7) ?
    ($CurrentDedicatedNodes * 1.1) : $CurrentDedicatedNodes;

Both formulas don't work, I'm stuck with only 1 node for the entire build time, and the CPU usage is at 100%.

If anyone has any experience with this or can help that'll be greatly appreciated

答案1

得分: 0

创建一个池,始终以1个节点启动。在CPU使用率超过70%的情况下持续3分钟后,池应生成另一台机器,并重复此过程。

您可以使用以下自动缩放公式来实现您的场景。

initialnumberVm = 1;
maximumNumberVm = 10; 
DemoPercentThreshold = 0.7;
DemoDuration = TimeInterval_Minute * 3; 
$demo = $CPUPercent.GetSamplePercent(DemoDuration);
$TargetDedicated = ($CPUPercent.GetSamplePercent(DemoDuration) > DemoPercentThreshold ? initialnumberVm + 1 : initialnumberVm);
$TargetDedicated = max(initialnumberVm, min($TargetDedicated, maximumNumberVm));
  1. 该公式允许的最大节点数为10,并且从一个节点开始。
  2. 池的节点具有3分钟的平均CPU利用率。如果平均CPU利用率大于或等于70%,它会向池中添加一个新节点。
  3. 如果平均CPU利用率低于70%,则会保持相同数量的节点不变。节点数量在初始值和允许的最大数量之间保持不变。

评估输出:

$TargetDedicatedNodes=2
$TargetLowPriorityNodes=0
$NodeDeallocationOption=requeue
$demo=83.3333
DemoDuration=3m
DemoPercentThreshold=0.7
initialnumberVm=1
maximumNumberVm=10

Azure批处理自动缩放公式

参考:
在Azure Batch池中自动缩放计算节点 - Azure Batch | Microsoft Learn

英文:

> Create a pool that always starts with 1 node. After 3 minutes of
having more than 70% CPU usage the pool should generate another machine, and repeat.

You can use the below autoscale formula to achieve your scenario.

initialnumberVm = 1;
maximumNumberVm =  10; 
DemoPercentThreshold = 0.7;
DemoDuration = TimeInterval_Minute * 3; 
$demo = $CPUPercent.GetSamplePercent(DemoDuration);
$TargetDedicated = ($CPUPercent.GetSamplePercent(DemoDuration) > DemoPercentThreshold ? initialnumberVm + 1 : initialnumberVm);
$TargetDedicated = max(initialnumberVm, min($TargetDedicated, maximumNumberVm));
  1. The maximum number of nodes allowed by this formula is 10, and it starts with one node.
  2. The pool's nodes have 3 minutes of average CPU utilization. It adds a new node to the pool if the average CPU utilization is more than or equal to 70%.
  3. It maintains the same number of nodes if the average CPU utilization is less than 70%. The number of nodes is constantly maintained between the initial value and the permitted maximum number.

Evaluation output:

$TargetDedicatedNodes=2
$TargetLowPriorityNodes=0
$NodeDeallocationOption=requeue
$demo=83.3333
DemoDuration=3m
DemoPercentThreshold=0.7
initialnumberVm=1
maximumNumberVm=10

Azure批处理自动缩放公式

Reference:
Autoscale compute nodes in an Azure Batch pool - Azure Batch | Microsoft Learn

答案2

得分: 0

这是答案,供任何有疑问的人参考:

maxNumberOfVMs = 20; // 您想要的最大虚拟机数量

samplePercentThreshold = 0.7; // 样本百分比阈值

sampleDuration = TimeInterval_Minute * 3; // 获取最后一个样本

$sample = (avg($CPUPercent.GetSample(sampleDuration))); // 如果平均CPU使用率超过70%,则增加一个节点,如果不是,则保持不变

$TargetDedicated = ($sample >= samplePercentThreshold ? $TargetDedicated + 1 : $TargetDedicated); // 如果平均CPU使用率低于20%,则减少一个节点,如果不是,则保持不变

$TargetDedicated = ($sample <= 0.2 ? $TargetDedicated - 1 : $TargetDedicated); // 始终保持节点数低于最大值

$TargetDedicated = min($TargetDedicated, maxNumberOfVMs);

英文:

This is the answer for anyone wondering

maxNumberOfVMs = 20; // maximum number of VMs you want

samplePercentThreshold = 0.7;

sampleDuration = TimeInterval_Minute * 3; 

// Get the last sample

$sample = (avg($CPUPercent.GetSample(sampleDuration)));

// If the average CPU usage was more than 70%, increase nodes by one, if 
not true keeps as is

$TargetDedicated = ($sample &gt;= samplePercentThreshold ? $TargetDedicated +1 
: $TargetDedicated);

// If the average CPU usage is below 20% decrease nodes by one, if not true 
keep as is

$TargetDedicated = ($sample &lt;= 0.2 ? $TargetDedicated - 1 : 
$TargetDedicated);

// Always keep the number of nodes under the maximum

$TargetDedicated = min($TargetDedicated, maxNumberOfVMs);

huangapple
  • 本文由 发表于 2023年5月24日 18:21:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/76322472.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定