Enable RSS on all Virtual Machines with PowerShell #vRSS #Hyper-V

Hello Folks,

In Windows Server 2012 R2, Microsoft works to improve networking workloads inside the Virtual Machine, because back in Windows Server 2012 we had a bottleneck inside the Host limited to one Core and bottleneck inside the VM again limited to one Core, so we need to expand that out and have a Virtual Machine being able to use multiple Cores in the host and inside the VM, therefore Microsoft introduced a new feature in Windows Server 2012 R2 called Virtual Receive Side Scaling (vRSS).

With vRSS, we are now able to turn RSS On inside the VM expanding to multiple Cores and that used just like would be in the physical Host so you can pretend that the VM as the physical Host, and as soon as you turn on RSS inside the VM, you automatically get spread inside the Host as well, so they introduced logically VMQ to actually spread from 1 Core up to 16 Cores.

If you like to deep dive in VMQ and RSS, here you go 3 part series VMQ Deep Dive.

Let’s see now vRSS in action:

I want to point out that the demoing VM that I am using has 8 Virtual Processors with one vNIC, and the host has 4 physical NICs 1GbE teamed with one CPU socket Quad Core.

With RSS turned off you can see that the network workload is using 1 Core only and the maximum network throughput is around 2Gbps.vRSS-00

vRSS-01

So in order to eliminate that bottleneck of 1 CPU, with vRSS you jump into your VM setting the network adapter RSS to true, and now RSS is enabled on that machine and here is the result 🙂 

PS C:\Set-NetAdapterRss –Name * -Enabled $true

As you can see immediately the network throughput went from 2Gbps to 3.3Gbps, and all 8 VPs are active now.

vRSS-02

vRSS-03

vRSS-04

The vRSS is able to expand the throughput to the VM from around 3Gbps all the way to 10Gbps on a 10Gbps Network Cards, Microsoft confirmed that it can go higher on throughput with 40Gpbs cards but the result is very depending on the CPU of the server.

The question that might come up… What if I have many Virtual Machines on that host, and I want to turn on RSS automatically on all VMs instead of logging into each VM and enable RSS?

The answer is WMI and PowerShell!

With the help of well-respected and fellow MVP Yusuf Ozturk @ http://www.yusufozturk.info/ ,I modified the following script that retrieves all VMs guest hostname from the Host and turn on RSS automatically J  it’s required to have Hyper-V 2012 R2.

function Get-VMGuestInfo
{
[CmdletBinding(SupportsShouldProcess = $true)]
param (
   [Parameter(
       Mandatory = $true,
       HelpMessage = ‘Virtual Machine Name’)]
   $VMName,

   [Parameter(
       Mandatory = $false,
       HelpMessage = ‘Hyper-V Host Name’)]
   $HyperVHost = “localhost”,

[Parameter(
       Mandatory = $false,
       HelpMessage = ‘Debug Mode’)]
   [switch]$DebugMode = $false
)

# Enable Debug Mode
if ($DebugMode)
{
$DebugPreference = “Continue”
}
else
{
$ErrorActionPreference = “silentlycontinue”
}

$VMState = (Get-VM -ComputerName $HyperVHost -Name $VMName).State
if ($VMState -eq “Running”)
{
filter Import-CimXml
{
$CimXml = [Xml]$_
$CimObj = New-Object -TypeName System.Object
foreach ($CimProperty in $CimXml.SelectNodes(“/INSTANCE/PROPERTY”))
{

if ($CimProperty.Name -eq “Name” -or $CimProperty.Name -eq “Data”)
{
$CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE
}
}
$CimObj
}

$VMConf = Get-WmiObject -ComputerName $HyperVHost -Namespace “root\virtualization\v2” -Query “SELECT * FROM Msvm_ComputerSystem WHERE ElementName like ‘$VMName’ AND caption like ‘Virtual%’ “
$KVPData = Get-WmiObject -ComputerName $HyperVHost -Namespace “root\virtualization\v2” -Query “Associators of {$VMConf} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent”
$KVPExport = $KVPData.GuestIntrinsicExchangeItems
if ($KVPExport)
{

# Get KVP Data
$KVPExport = $KVPExport | Import-CimXml

# Get Guest Hostname
$VMHostname = ($KVPExport | where {$_.Name -eq “FullyQualifiedDomainName”}).Data
}
else
{
$VMHostname = “Unknown”
}
}
else
{
$VMHostname = “Unknown”
}

$Properties = New-Object Psobject
$Properties | Add-Member Noteproperty VMHostname $VMHostname
Write-Output $Properties
}

$VMs = Get-VM -ComputerName $HyperVHost
foreach ($VM in $VMs)
{
$VMName = $VM.Name
$VMHostName = (Get-VMGuestInfo -VMName $VMName -HyperVHost $HyperVHost).VMHostName
$Output = $VMHostName
Add-Content -Value $Output -Path C:\Temp\VMs.txt
}

# Get Domain Credentials
$cred = get-credential “Domain\User”

# Turn on RSS on all running Guests
Invoke-Command -ComputerName (Get-Content C:\Temp\VMs.txt) -Credential $cred -ScriptBlock {Set-NetAdapterRss –Name * -Enabled $true}

Give it a try and see how it works.

Enjoy your day!

Cheers,
Charbel

About Charbel Nemnom 325 Articles

Charbel Nemnom is a Microsoft Cloud Consultant and Technical Evangelist, totally fan of the latest’s IT platform solutions, accomplished hands-on technical professional with over 15 years of broad IT Infrastructure experience serving on and guiding technical teams to optimize performance of mission-critical enterprise systems. Excellent communicator adept at identifying business needs and bridging the gap between functional groups and technology to foster targeted and innovative IT project development. Well respected by peers through demonstrating passion for technology and performance improvement. Extensive practical knowledge of complex systems builds, network design and virtualization.

Be the first to comment

Leave a Reply