Checking for N+1 with PowerShell

When administering a Hyper-V cluster with shared storage, it’s important to be aware of the resources provisioned to each VM and the resources available on all the hosts. For example, in a two node cluster, in order for it to be N+1 (the ability for the cluster to be able to withstand a failure of one physical host) each host would need to be able to handle running the normal VM workload all by itself. Most of the time, unless you have a very compute-intensive environment, memory is usually going to be the bottleneck for maintaining an N+1 cluster. So in this post, we will focus calculating capacity for N+1 by measuring memory utilization. Thankfully we can easily determine this by using PowerShell.

Determining if a Two Node Cluster is N+1

In this example we will use a two node cluster.  We want to make sure that if one Hyper-V host goes down, the other host can handle running all the VMs. First, we have to find out the total physical memory of each Hyper-V host. In other words, we need to know how much physical memory is installed on each host. Then, we have to compare the total physical memory of each Hyper-V host with the total amount of memory used by all running VMs in the cluster. The following diagram shows two hosts with 16GB of physical memory.  Hyper-V requires around 2GB of memory to run the hypervisor and the OS. So, the amount of memory each of our Hyper-V hosts leaves available to VMs is roughly 14GB. 1-Cluster1 Now that we have the total physical memory of each host, we need to see how much memory each running VM is using. To do this, we will use Get-VM with the –VMName parameter, combined with the asterisk (*) symbol to specify all VMs followed by the –ComputerName parameter to list each Hyper-V host (TGLAB-HV01 and TGLAB-HV02):

Get-VM –VMname * -Computername tglab-hv01,tglab-hv02

2-cluster1ps A table will be displayed with the assigned memory information for each VM: 3-cluster1ps Now, we can either take the time to manually add up the amount of memory consumed by each VM or we can leverage PowerShell to do all the heavy lifting for us. Using Measure-Object we can select the MEMORYASSIGNED property and add each value using the –sum parameter:

(Get-VM –VMname * -ComputerName tglab-hv01,tglab-hv02 | Measure-Object memoryassigned –sum).sum/1MB

4-vmadd After running the command, we can see that the total amount of memory used by all VMs is 6518MB. So the 14GB of available memory on each host is more than enough run all the currently running VMs in the cluster on just one host. This is just a quick way to verify if a cluster is N+1. If you wanted to be more accurate, you would need to consider the overhead of each VM with the following formula: VM assigned memory + 32mb used for the first 1GB of each VM + 8mb for each following 1GB So, if we had a VM with 4GB of assigned memory we would add 4096MB + 32MB + (3 x 8MB) which would equal 4152MB. There are Hyper-V resource calculators online that can be used to make calculating the overhead of each VM easier.

N+1 with Different Sized Nodes

Checking for N+1 with only two identical nodes in a cluster is pretty simple. However, adding more nodes of different sizes to the cluster makes it a little tougher to calculate. Let’s say we have a Hyper-V cluster made up of 5 hosts using shared storage. Each Hyper-V host is configured with the following amount of memory: 5-advcluster We run our command again to gather the total amount of assigned memory for every VM on each host:

(Get-VM –VMname * -ComputerName tglab-hv01,tglab-hv02,tglab-hv03,tglab-hv04,tglab-hv05 | Measure-Object memoryassigned –sum).sum/1MB

For demonstration purposes, let’s say that the command returns a value of 320000. So, we have a total sum of 320GB memory in use by all VMs currently running in the cluster. Now, to determine if a cluster with different sized nodes is N+1, we want to make sure that we can still run all VMs if the largest host is taken out of play. In our example, we will pretend TGLAB-HV01 is down. This gives us a cluster with a remaining total physical memory of 288GB. 6-advclusterdown On top of that, we need to account for the 2GB of memory it takes to run Hyper-V and the OS on each host. So we will take the number of remaining hosts left in the cluster and multiply that by 2GB. In our example, that means it will cost us 8GB to run the remaining four Hyper-V hosts. So the amount of memory we would need to run the VMs plus Hyper-V and the management operating system would be 320GB + 8GB which equals 328GB. But, with only 288GB of total physical memory available on the remaining hosts, the four Hyper-V hosts would not be able to run the entire VM workload. Therefore, the cluster is not N+1. An easy way of calculating this is by using the following formula: Formula It’s useful to be able to quickly check for N+1, especially when a cluster host needs to be taken down for maintenance.

 

Altaro Hyper-V Backup
Share this post

Not a DOJO Member yet?

Join thousands of other IT pros and receive a weekly roundup email with the latest content & updates!

Leave a comment or ask a question

Your email address will not be published. Required fields are marked *

Your email address will not be published. Required fields are marked *

Notify me of follow-up replies via email

Yes, I would like to receive new blog posts by email

What is the color of grass?

Please note: If you’re not already a member on the Dojo Forums you will create a new account and receive an activation email.