You dont have javascript enabled! Please enable it!

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

3 Min. Read

In this article, we will show you how to enable RSS on all Hyper-V Virtual Machines using PowerShell.

Introduction

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 a 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 is used just like would be in the physical Host so you can pretend that the VM is 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.

Enable RSS on Hyper-V Virtual Machines

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 10Gbps Network Cards, Microsoft confirmed that it can go higher on throughput with 40Gpbs cards but the result is very dependent 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 enabling 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 hostnames from the Host and turns on RSS automatically J  it’s required to have Hyper-V 2012 R2 or later.

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.

Learn more

Do you want to learn about Windows Server Hyper-V, I highly encourage you to check Windows Server Hyper-V Cookbook for in-depth details about Hyper-V and automation tasks.

Enjoy your day!

Cheers,
Charbel

Related Posts

Previous

Live Migration Comparison over TCP/IP, Compression, and SMB MultiChannel with Hyper-V 2012 R2

Build a Step by Step Hyper-V and VMM Lab with PowerShell

Next

4 thoughts on “Enable RSS on all Virtual Machines using PowerShell #vRSS #Hyper-V”

Leave a comment...

  1. Hello Dan, thanks for the comment!
    Please note that I’ve updated the article, you should be able to copy the script now.
    Let me know how it works for you.
    Thanks,

  2. Thanks, Dan, yes the script will work on Windows Server 2019 Hyper-V.
    Please note that if you have Windows Server 2016 VMs and later running on Windows Hyper-V 2019, then vRSS should be enabled by default and you don’t need to run the script.
    Hope it helps!

Let me know what you think, or ask a question...

error: Alert: The content of this website is copyrighted from being plagiarized! You can copy from the 'Code Blocks' in 'Black' by selecting the Code. Thank You!