Reasons and solutions for slow Hyper-V virtual machine network

Poor network performance on Hyper-V VM

A few times I've encountered a situation where copying files from a virtual machine on a Hyper-V host running Windows Server was much slower. In this article, I try to describe a few different ways to improve the network performance of Hyper-V virtual machines running on Windows Server (and the latest Windows 10 and 11 versions).

Receive segment merge (RSC) in Hyper-V vSwitch

First, you should pay attention to the Receive Segment Consolidation (RSC)  feature coming to Hyper-V on Windows Server 2019/2022 (and Windows 10 1809+) . Receive segment coalescence is used at the virtual switch level (vSwitch).

RSC allows reducing CPU load and increasing network throughput by combining multiple TCP segments into larger segments Network performance is improved because large segments are processed faster than many smaller segments.

In previous Hyper-V versions (Windows Server 2016/2012R2), only hardware receive segment coalescing mode was supported at the NIC level.

If RSC support is enabled, it may cause additional network latency in some hardware configurations.

By default, RSC is enabled on all external switches on Windows Server 2019.

You can check whether RSC is enabled for the virtual switch using the following command:

Get-VMSwitch | Select-Object *RSC*

You can disable the use of RSC for IPv4 traffic on the client network adapter using the following command:

Disable-NetAdapterRsc -Name "Ethernet" -IPv4

Check if disabling RSC improves replication speed in Hyper-V VM. If network speeds improve, RSC can be disabled on the virtual switch to which the VM is connected.

You can use  the iperf  tool to check network throughput.

To disable software RSC for a specific virtual switch, run the following command:

Set-VMSwitch -Name vSwitchName -EnableSoftwareRsc $false

check if RSC is enable on hyper-v switch

You can enable/disable RSC on the fly and it will not affect any active connections.

Alternatively, you can disable RSC entirely on Windows hosts:

netsh int tcp set global rsc=disabled

Virtual Machine Queuing (VMQ) mode in network adapter driver

In some cases, poor network performance in Hyper-V virtual machines may result if VMQ (Virtual Machine Queuing) is enabled in the network adapter driver of the physical  Hyper-V host.

VMQ is a hardware feature and if your hardware does not support it enabling it in the driver can result in packet loss and increased network latency.

This issue is typical of Broadcom Gigabit Network Adapters and occurs in all Hyper-V versions (Windows Server 2012 R2/2016/2019).

VMQ is designed to improve network performance by forwarding packets directly from physical network adapters to virtual machines.

VMQ can be disabled in the properties of the network adapter driver.

disable VMQ (Virtual Machine Queue) in NIC driver settings

Alternatively, you can use PowerShell to display a list of VMQ-capable network adapters and their status:

Get-NetAdapterVmq

To disable VMQ for a specific network card, run the following command (the network adapter will be unavailable for a few seconds):

Set-NetAdapterVmq -Name “NICName” -Enabled $False

check if vmq is enabled in NIC - powershell

After disabling VMQ, it is a good idea to reboot the host and check network performance.


Make sure the QoS bandwidth limiting policy is disabled in Windows  .

Optimizing TCP settings for Hyper-V on Windows Server 2019

Save the current TCP settings on the Hyper-V host and apply the new settings that will make the TCP settings in Windows Server 2019 almost similar to those in Windows Server 2016.

Save current settings:

​
Get-NetTCPSetting -SettingName Datacenter,DatacenterCustom,InternetCustom,Internet|select SettingName,CongestionProvider,CwndRestart,ForceWS|Export-csv c:\backup\ws2019_network_stack_settings_nettcp_backup.csv

​
By default, in Windows Server 2019 and Windows 10 1709+, the CUTRIC implementation of TCP is used. This algorithm is optimized for high-speed networks with high latency (it is also used by default in Linux kernel 2.6.19 and later).

Windows TCP stack on Windows Server 2019 based on CUBIC

The following settings apply only in Windows Server 2019 or Hyper-V 2019.

Apply new NetTCP settings to the LAN:

Set-NetTCPSetting -SettingName DatacenterCustom,Datacenter -CongestionProvider DCTCP
Set-NetTCPSetting -SettingName DatacenterCustom,Datacenter -CwndRestart True
Set-NetTCPSetting -SettingName DatacenterCustom,Datacenter -ForceWS Disabled

For WAN:

Set-NetTCPSetting -SettingName InternetCustom,Internet -CongestionProvider CTCP
Set-NetTCPSetting -SettingName InternetCustom,Internet -DelayedAckTimeoutMs 50
Set-NetTCPSetting -SettingName InternetCustom,Internet -ForceWS Disabled

Disable network RSS and RSC network optimization methods at the TCP stack level:

netsh int tcp show global
netsh int tcp set global RSS=Disabled
netsh int tcp set global RSC=Disabled

Or at the network card level:

Get-NetAdapter | Set-NetAdapterAdvancedProperty -DisplayName "Recv Segment Coalescing (IPv4)" -DisplayValue "Disabled" -NoRestart
Get-NetAdapter | Set-NetAdapterAdvancedProperty -DisplayName "Recv Segment Coalescing (IPv6)" -DisplayValue "Disabled" -NoRestart
Get-NetAdapter | Set-NetAdapterAdvancedProperty -DisplayName "Receive Side Scaling" -DisplayValue "Disabled" –NoRestart

Disable vRSS for all virtual machines:

Get-VM | Set-VMNetworkAdapter -VrssEnabled $FALSE

Disable Large Send Offload (LSO) on the network card:
Get-NetAdapter | Set-NetAdapterAdvancedProperty -DisplayName "Large Send Offload Version 2 (IPv4)" -DisplayValue "Disabled" -NoRestart
Get-NetAdapter | Set-NetAdapterAdvancedProperty -DisplayName "Large Send Offload Version 2 (IPv6)" -DisplayValue "Disabled" -NoRestart
Get-NetAdapter | Restart-NetAdapter

You can also disable these options in the Advanced tab of the network adapter properties:

  • Receive Segment Merging (IPv4/IPv6) = Disabled
  • Large Send Offload v2 (IPv4/IPv6) = Disabled

disable recv segment coalescing on hyper-v

These TCP stack settings will make Windows Server 2019 network protocol settings similar to previous Windows Server versions.

Guess you like

Origin blog.csdn.net/webmote/article/details/132273022