DennieTidwell
Enthusiast
Enthusiast

“Mem.Usage.Average” against the total aggregate of cluster host memory

Jump to solution

Please see attachment for full story.

Please give me a sanity check on this. I was using the “Mem.Usage.Average” as a % against VM allocated MemoryMB. The sum of these calculations was coming nowhere near the actual calculations from vCenter based on %Memory. So, I modified my calculations as you see in the spreadsheet to use the “Mem.Usage.Average” against the total aggregate available across all hosts in the cluster. This sum came within 1% of my calculations based on vCenter GUI. Am I correct in using “Mem.Usage.Average” against the total aggregate of cluster host memory instead of against VM allocated memory? Thxs-

ExcelOutput.jpg

SDK is not clear on “total configured or available memory”. https://www.vmware.com/support/developer/converter-sdk/conv55_apireference/memory_counters.html description Portion of memory in use as a percentage of total configured or available memory.


$start = (Get-Date).AddDays(-5)

get-cluster -Location ActualClusterName | Get-VM | Where {$_.PowerState -eq "PoweredOn"} @{N="Mem.Usage.Average";E={[Math]::Round((($_ |Get-Stat -Stat mem.usage.average -Start $start -Finish $finish -IntervalMins 1800 -MaxSamples (250) |Measure-Object Value -Average).Average),2)}} `


Cluster is 6 hosts with 128G per host for total of 768G (786432 MB RAM) There are 118 powered on VMs


vCGUI.jpg

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

for me the SDK says that the percentage reflects the ratio of the "active" memory in the VM against the configured memory for the VM.

A VM configured with 8GB of memory that has a "usage" of 25% is actively using 2GB of memory.

vm-mem-usage.png

I suspect that your numbers you get for the VMs are skewed due to the large period of time over which you take the average (see my previous reply).

You can in fact cross-check the mem.usage.average with the mem.active.average.

In the following code I calculate from the 2 different counters the actual memory being used by the VM.

$clusterName = 'MyCluster'

$stat = 'mem.usage.average','mem.active.average'

$vm = Get-Cluster -Name $clusterName | Get-VM | where{$_.PowerState -eq 'PoweredOn'}

$stats = Get-Stat -Entity $vm -Stat $stat -Realtime -MaxSamples 1

$stats | Group-Object -Property {$_.Entity.Name} | %{

  [PSCustomObject]@{

    VM = $_.Group[0].Entity.Name

    MemoryMB = $_.Group[0].Entity.MemoryMB

    MemUsagePerc = $_.Group | where{$_.MetricId -eq 'mem.usage.average'} | select -ExpandProperty Value

    MemUsageMB = [int]($_.Group[0].Entity.MemoryMB * ($_.Group | where{$_.MetricId -eq 'mem.usage.average'}).Value)/100

    MemActiveMB = ($_.Group | where{$_.MetricId -eq 'mem.active.average'} | select -ExpandProperty Value)/1KB

  } 

}

The result shows, for a specific VM, that both numbers are close enough to be considered the same imho.

Which they should be in fact, the mem.usage.average is derived from the mem.active.average.

vm-mem-usage-2.png


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership

Shouldn't you be comparing data for the same time period ?

You now take an average over 5 days for the VMs, but you seem to compare that against the data that is shown in the vSphere client.

That latter data is reflecting current data, not an average over 5 days.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

DennieTidwell
Enthusiast
Enthusiast

Hi Luc - thanks for replying.

Your comment is well taken although that is not my core question.

The core question is whether the metric percentage should be applied to the individual VM allocated memory or rather the total cluster available memory.

Does "Mem.Usage.Average" results run against VMs reflect used memory as a percentage of each VM allocated memory or as a percentage of total cluster available memory?

The SDK reference is not definitive on this the way I read it.

Based on my results, when applied to individual VM allocated memory, the resulting total used memory on each VM is very small. When these individual VM memory used results are summed up in Excel, they are tiny, when the observed memory use in the cluster is consistently above 75% on every host. When I run the "Mem.Usage.Average" against the hosts, the numbers are consistent with observed vC GUI results. (ie. the host report using this same metric (although using 30 days) is consistently over 75% per host)

When I compare results of Mem.Usage.Average % * VM MemoryMB allocated as run against VMs and total them - they are significantly lower as to be unreal.

BTW, I was on Amazon the other day and saw what appeared to be an upcoming book on Powercli Performance scripting methods authored by you. It wasn't available yet and I haven't been able to find it since. Do you have another book on the way? Cause I want it.

Thanks

Dennie

0 Kudos
LucD
Leadership
Leadership

for me the SDK says that the percentage reflects the ratio of the "active" memory in the VM against the configured memory for the VM.

A VM configured with 8GB of memory that has a "usage" of 25% is actively using 2GB of memory.

vm-mem-usage.png

I suspect that your numbers you get for the VMs are skewed due to the large period of time over which you take the average (see my previous reply).

You can in fact cross-check the mem.usage.average with the mem.active.average.

In the following code I calculate from the 2 different counters the actual memory being used by the VM.

$clusterName = 'MyCluster'

$stat = 'mem.usage.average','mem.active.average'

$vm = Get-Cluster -Name $clusterName | Get-VM | where{$_.PowerState -eq 'PoweredOn'}

$stats = Get-Stat -Entity $vm -Stat $stat -Realtime -MaxSamples 1

$stats | Group-Object -Property {$_.Entity.Name} | %{

  [PSCustomObject]@{

    VM = $_.Group[0].Entity.Name

    MemoryMB = $_.Group[0].Entity.MemoryMB

    MemUsagePerc = $_.Group | where{$_.MetricId -eq 'mem.usage.average'} | select -ExpandProperty Value

    MemUsageMB = [int]($_.Group[0].Entity.MemoryMB * ($_.Group | where{$_.MetricId -eq 'mem.usage.average'}).Value)/100

    MemActiveMB = ($_.Group | where{$_.MetricId -eq 'mem.active.average'} | select -ExpandProperty Value)/1KB

  } 

}

The result shows, for a specific VM, that both numbers are close enough to be considered the same imho.

Which they should be in fact, the mem.usage.average is derived from the mem.active.average.

vm-mem-usage-2.png


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
DennieTidwell
Enthusiast
Enthusiast

Thanks for your time, Luc.

The correlation of stats may be a fluke based on my attempts to make sense of gathered stats. It is a strange coincidence that the numbers resulting from 5 days Mem.Usage.Average against VMs, calculated against total cluster memory, results in a value within 1% of vC GUI observed and gathered % Mem.Usage.Average over 30 days of aggregate cluster hosts.

The desired result of this exercise is to accurately report actual VM requirements for migration purposes. The active memory doesn't reflect this based on my reading as it doesn't include all used memory by the VM. In a 90% windows shop (or 90% anything), I guess shared memory is a wash.

Do you have any suggestions for accurately reporting VM requirements in total for migration or capacity planning?

I have rewarded all points. Thank you. Happy Holiday.

0 Kudos
LucD
Leadership
Leadership

It could be explained by the fact the most of your VMs have rather constant memory usage (but that does not mean that they always access the same pages over the 20 seconds measurement interval).

The art of capacity planning for CPU and memory requirements for vSphere VMs, is not simple.

There are many considerations to be made, and from that I can give the classic answer "It depends !" :smileygrin:

Some personal observations (in no specific order):

  • "active" memory is not a good indicator for capacity planning
  • to have a more complete picture of the memory requirements, you need to measure the memory consumption inside the guest OS
  • capacity planning is not an absolute science, it's more, imho, a trial and error method. And by acquiring experience, you get better at it (most of the time)
  • to improve your capacity planning skills, one needs to have a good understanding of what goes on inside the hypervisor, and inside the guest OS
  • don't be blinded by rules of thumb, they are there to help, but always question them for your specific environment

There are a bunch of good, commercial products on the market that help in capacity planning, but they require an investment.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos