Friday, August 12, 2016

VMware Esxi Performance Modes



It is quite normal for anyone wanting to extract as much as they can from a hardware that they have bought. Make optimal use of it. When you are looking at Esxi hosts you are looking at a certified hardware which has been tested and tasted by experts at VMware and the vendor. If you have put some thousands or crores of money into your hardware, then you might well make the best use of it. If you are a biological being, then you want to live longer but if you are hardware then you want to do the best before you become obsolete.
VMware itself supports 3 types of performance or power modes.
1.       High Performance
2.       Balanced
3.       Low power
I myself would put my hosts in high performance mode but your scenarios might differ. I mean does it make sense to put your bike always on high throttle or wheelie mode (if you have any of the newer street bikes with different riding modes coz I don’t) in a city traffic? No. Below is a glimpse of where you can do it via GUI.
I would however want to do this via Powercli where you can get this done to all your esxi hosts at once. High performance mode as the name suggests, the operating system assumes that your workload’s requirement of resources keeps changing drastically and it always needs the resources to be ready. It does however comes at the cost of more power consumption. The main goal here is the performance and power consumption is of no concern to the esxi host.
Balanced as the name itself suggests will maintain a balance between the power consumption and the performance. Here esxi will still give priority to the performance but not at the cost of too much power consumption.
Low Power is the most energy saving mode where esxi will prioritize on power saving against performance. This can be used for failover hosts in a cluster if your HA settings are such that you have reserved hosts for failover.
Combine this with the BIOS settings of your esxi hosts and you will have some amazing performance for your hosts.
I would suggest the following for your environment if you are wondering what is the right one for your environment. I suggest 2 ways of deciding it.
Method 1: Flactuation
You can approximately consider the following values per day or week.
Lowerst % of resource Usage
Highest % of Resource Usage
Flactuation [H-L]
Performance Setting
L
H
30 - 40
High Performance
L
H
20 - 30
Balanced
L
H
20 - 10
Low Power

Method 2: Maximum Resource Usage
-+70% to -+90% à High performance
-+50% to -+70% à Balanced
50% or less         à Low Power
Here -+ stands for plus or minus, meaning an approximation or round figure.
This will set the performance of your esxi hosts to High Performance.
(Get-View (Get-VMHost | Get-View).ConfigManager.PowerSystem).ConfigurePowerPolicy(1)
Please note that here
1. High performance
2. Balanced
3. LowPower

You would however may not remember the above 3 options against their numbers. So it might be better to do a write-host for this function where it will inform about it and asks you to choose.
Write-Host "choose a number from below
1. High performance
2. Balanced
3. LowPower
" -BackgroundColor White -ForegroundColor Black

And take the user input after this with
$option = Read-Host "?"
It is also annoying that this won’t tell you the real progress or won’t tell you currently on which host is it running. That is why we might want to create a loop for each host and display the name of the host before it runs.
foreach ($vmhost in (get-cluster $cluster | get-vmhost | sort))
{$vmhost.Name
(Get-View (Get-VMHost $vmhost | Get-View).ConfigManager.PowerSystem).ConfigurePowerPolicy($option)
}
 This is how it will look at the end with some timers built in the script to tell you how much it took for you to run this script.
$cluster = Read-Host "name of the cluster[type * to include all clusters]?"
Write-Host "choose a number from below
1. High performance
2. Balanced
3. LowPower
" -BackgroundColor White -ForegroundColor Black
$option = Read-Host "?"

$stopWatch = [system.diagnostics.stopwatch]::startNew()
$stopWatch.Start()

foreach ($vmhost in (get-cluster $cluster | get-vmhost | sort))
{$vmhost.Name
(Get-View (Get-VMHost $vmhost | Get-View).ConfigManager.PowerSystem).ConfigurePowerPolicy($option)
}

$stopWatch.Stop()
Write-Host "Elapsed Runtime:" $stopWatch.Elapsed.Hours "Hours" $stopWatch.Elapsed.Minutes "minutes and" $stopWatch.Elapsed.Seconds "seconds." -BackgroundColor White -ForegroundColor Black
 

Obviously you have noticed that I have left out the custom option. Well that is for you to discover and I am sure it will be worth your time.
I have put this into my vTool at github which contains a lot of such useful functions to make your life easier.