Twitter
LinkedIn
RSS

HA Admission control policy based on percentage

When configuring HA, you also have to enable and configure admission control as otherwise there is no assurance that all virtual machines in a cluster can be restarted after a host failure. While won’t go too much into details about the different admission control policies (refer to Duncan’s and Frank Denneman’s blogs), I most often chose for admission control based on a percentage of cluster resources reserved for failover capacity as this according to my opinion is the most flexible option out of the three.


Not so long ago Frank Dennemanwrote a very good article explaining the admission control based on a percentage therefore I am not going to repeat what has been written already, however I do want to share the way I usually decide on how to set the percentage, have a look at the following table:


# ESX Hosts in a cluster

Units / ESX Host

Total Units

% Failover capacity

Unused Units

# Host Failures

1

100

100

100

100

1

2

100

200

50

100

1

3

100

300

34

100

1

4

100

400

25

100

1

5

100

500

20

100

1

6

100

600

17

100

1

7

100

700

15

100

1

8

100

800

25

200

2

9

100

900

23

200

2

10

100

1000

20

200

2

11

100

1100

19

200

2

12

100

1200

17

200

2

13

100

1300

16

200

2

14

100

1400

15

200

2

15

100

1500

14

200

2

16

100

1600

13

200

2

17

100

1700

12

200

2

18

100

1800

12

200

2

19

100

1900

11

200

2

20

100

2000

10

200

2

21

100

2100

10

200

2

22

100

2200

10

200

2

23

100

2300

9

200

2

24

100

2400

9

200

2

25

100

2500

8

200

2

26

100

2600

8

200

2

27

100

2700

8

200

2

28

100

2800

8

200

2

29

100

2900

7

200

2

30

100

3000

7

200

2

31

100

3100

7

200

2

32

100

3200

7

200

2

So what I am doing here is, basically a cluster can exists out of a maximum of 32 ESX hosts and let’s say every ESX host is equal to 100 Units. As by this example in the above table I decided that for a cluster with less than eight ESX hosts I will reserve 100 Units (meaning I will reserve one ESX host) for redundancy purposes and for a cluster with eight or more ESX hosts I will reserve 200 Units (two ESX hosts). By using the following calculation you can easily determine to what you have to set the percentage: “(number of host failures * total units provided by one ESX host) / total units within a cluster = percentage of resources reserved for failover“.

As the total cluster resources will change over time because hosts will be added (or removed), I developed a powershell script that either you launch on a interval or let it run based on an event that indicates that the cluster resources has changed:


param(
[string]$cluster
)

function connectToVI
{
 $vcs = $vCenters
 foreach ($vcenter in $vcs)
   {
     Write-Host "`nConnecting to: " $vcenter -BackgroundColor DarkGreen -ForegroundColor Black
     $vcHost = Connect-VIServer -Server $vCenter -User $vmxVCUser -Password $vmxVCPassword -ErrorAction SilentlyContinue
     if ($vcHost.Isconnected -eq $true)
     {
       Write-Host "`nsuccessfully connected to: " $vcenter
     }
     else
    {
      Write-Host "`nfailed to connect to: " $vcenter
      $vCenters = @($vCenters | Where-Object {$_ -ne $vCenter})
    }
   }
   return $vCenters
}

function disconnectFromVI()
{
 $vcs = $vCenters
 foreach ($vcenter in $vcs)
 {
   Write-Host "`nDisconnecting from: " $vcenter -BackgroundColor DarkGreen -ForegroundColor Black
   DisConnect-VIServer -Server $vCenter -Confirm:$false -ErrorAction SilentlyContinue
   $vCenters = @($vCenters | Where-Object {$_ -ne $vCenter})
 }
 Return $vCenters
}

 $vCenter = "vCenter Server"

 if ((Get-PSSnapin "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue) -eq $null)
 {
   Measure-Command {Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue}
 }

 $vCenters = New-Object System.Collections.ArrayList
 [void]$vCenters.Add($vCenter)

 $vCenters = @(connectToVI)
 if ($vCenters.Count -gt 0)
 {
   if ($cluster.length -eq 0)
   {
     $cluster = (Get-VMHost -ID ("HostSystem-" + $VMWARE_ALARM_TARGET_ID) | Get-Cluster).Name
   }

   if ($cluster -ne $null)
   {
     $clusterview = Get-View -ViewType "ClusterComputeResource" -Filter @{"Name" = $cluster}
     $failoverCapacityInPercentage = $clusterview.configuration.dasConfig.admissionControlpolicy.cpuFailoverResourcesPercent

     if ($clusterview.configuration.dasConfig.admissionControlEnabled)
     {
       $hostCount = (@(Get-View -SearchRoot $clusterview.MoRef -ViewType "HostSystem")).Count

       if ($hostCount -gt 7 )
       {
         $failoverCapacityInPercentage = [math]::Round(((2* 100) / ($hostCount * 100))*100, 0)
       }
       else
       {
         $failoverCapacityInPercentage = [math]::Round(((1* 100) / ($hostCount * 100))*100, 0)
       }

       $clusterConfigSpec = New-Object VMware.Vim.ClusterConfigSpecEx
       $clusterConfigSpec.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo
       $clusterConfigSpec.dasConfig.admissionControlpolicy = New-Object VMware.Vim.ClusterFailoverResourcesAdmissionControlPolicy
       $clusterConfigSpec.dasConfig.admissionControlpolicy.cpuFailoverResourcesPercent = $failoverCapacityInPercentage
       $clusterConfigSpec.dasConfig.admissionControlpolicy.memoryFailoverResourcesPercent = $failoverCapacityInPercentage

       Write-Host "Setting Failover Capacity percentage to: $failoverCapacityInPercentage"
       $clusterview.ReConfigureComputeResource_Task($clusterConfigSpec, $true) | Out-Null
     }
   }
   $vCenters = @(disconnectFromVI)
 }



Leave a Reply