Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ระบบ >> Windows Server

ประสิทธิภาพเครือข่ายต่ำบน Hyper-V VMs ใน Windows Server 2019

เคยเจอหลายครั้งที่การคัดลอกไฟล์ระหว่าง VM บน Hyper-V Host ที่รัน Windows Server 2019 ช้ากว่าบน Host รัน Windows Server 2016 มาก ในบางการทดสอบ ความเร็ว Read/Write ผ่านเครือข่ายไปยัง VM บน WS2019 ต่ำกว่า WS2016 เกือบ 3 เท่า (ทดสอบ Copy ผ่าน SMB, SSH/SCP) บทความนี้รวบรวมวิธีปรับปรุงประสิทธิภาพเครือข่ายของ Hyper-V VMs บน Windows Server 2019 (และ Windows 10/11 Build ล่าสุด)

Receive Segment Coalescing (RSC) ใน Hyper-V vSwitch

ควรสังเกตฟีเจอร์ Receive Segment Coalescing (RSC) ที่ปรากฏใน Hyper-V บน Windows Server 2019/2022 (และ Windows 10 1809+) RSC ใช้งานที่ระดับ Virtual Switch (vSwitch) RSC ช่วยลด CPU Load และเพิ่ม Network Throughput โดยการรวม Multiple TCP Segments ให้กลายเป็น Segment ใหญ่ๆ . ประสิทธิภาพเครือข่ายดีขึ้นเพราะ Segment ใหญ่ประมวลผลได้เร็วกว่าหลาย Segment เล็ก

ใน Hyper-V เวอร์ชันก่อนหน้า (Windows Server 2016/2012R2) รองรับเฉพาะ Hardware Receive Segment Coalescing ที่ระดับ NIC

หากเปิดใช้งาน RSC อาจทำให้เกิด Network Delay เพิ่มในบาง Hardware Configuration

ปัญหาเกิดทั้ง Windows Server 2019 Full GUI และ Free Windows Hyper-V Server

โดยค่าเริ่มต้น RSC เปิดใช้งานสำหรับ External vSwitch ทั้งหมดบน Windows Server 2019

ตรวจสอบว่า RSC เปิดใช้งานสำหรับ Virtual Switches หรือไม่:

Get-VMSwitch | Select-Object *RSC*

ปิดใช้งาน RSC สำหรับ IPv4 Traffic บน Network Adapter ของ Client:

Disable-NetAdapterRsc -Name "Ethernet" -IPv4

ตรวจสอบว่าความเร็ว Copy ใน Hyper-V VM เพิ่มขึ้นหลังปิด RSC หรือไม่ หาก Network Speed ดีขึ้น สามารถปิด RSC บน Virtual Switch ที่ VM เชื่อมต่ออยู่

ตรวจสอบ Network Throughput ด้วย iperf Tool

ปิด Software RSC สำหรับ Virtual Switch เฉพาะ:

Set-VMSwitch -Name vSwitchName -EnableSoftwareRsc $false

ประสิทธิภาพเครือข่ายต่ำบน Hyper-V VMs ใน Windows Server 2019

สามารถ Enable/Disable RSC แบบ On-the-fly ได้ ไม่กระทบ Active Connections

หรือปิด RSC ทั้งหมดบน Windows Host:

netsh int tcp set global rsc=disabled

โหมด Virtual Machine Queue (VMQ) ใน Network Adapter Driver

ในบางกรณี หาก VMQ (Virtual Machine Queue) เปิดใช้งานใน Network Adapter Driver ของ Physical Hyper-V Host อาจทำให้ Network Performance ใน Hyper-V VMs แย่ลง VMQ เป็น Hardware Feature หาก Hardware ไม่รองรับแต่เปิดใน Driver จะทำให้ Packet Loss และ Network Latency เพิ่มขึ้น ปัญหานี้พบบ่อยกับ Broadcom Gigabit Network Adapters และเกิดในทุก Hyper-V Version (Windows Server 2012 R2/2016/2019)

VMQ ออกแบบมาเพื่อปรับปรุง Network Performance โดยการ Forward Packets จาก Physical Network Adapter ไปยัง VMs โดยตรง

ปิด VMQ ใน Properties ของ Network Adapter Driver

ประสิทธิภาพเครือข่ายต่ำบน Hyper-V VMs ใน Windows Server 2019

หรือแสดงรายการ Network Adapters ที่รองรับ VMQ และสถานะด้วย PowerShell:

Get-NetAdapterVmq

ปิด VMQ สำหรับ NIC เฉพาะ (Network Adapter จะไม่พร้อมใช้งานสักครู่):

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

ประสิทธิภาพเครือข่ายต่ำบน Hyper-V VMs ใน Windows Server 2019

หลังปิด VMQ ควร Restart Host และตรวจสอบ Network Performance

ตรวจสอบว่า QoS Bandwidth Limit Policies ปิดอยู่ใน Windows

ปรับ TCP Settings สำหรับ Hyper-V บน Windows Server 2019

Backup TCP Settings ปัจจุบันบน Hyper-V Host และนำ Settings ใหม่มาใช้ ทำให้ TCP Settings ใน Windows Server 2019 ใกล้เคียงกับ Windows Server 2016

Backup Settings ปัจจุบัน:

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

โดยค่าเริ่มต้นใน Windows Server 2019 และ Windows 10 1709+ ใช้ CUBIC TCP Implementation อัลกอริทึมนี้ปรับให้เหมาะกับ High-speed Networks ที่มี High Latency (ใช้ Default ใน Linux Kernel 2.6.19+)

ประสิทธิภาพเครือข่ายต่ำบน Hyper-V VMs ใน Windows Server 2019

นำ Settings ต่อไปไปใช้ได้เฉพาะ Windows Server 2019 หรือ Hyper-V 2019

ตั้งค่า NetTCP ใหม่สำหรับ LAN:

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

สำหรับ WAN:

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

ปิด Network RSS และ RSC Optimization Methods ที่ระดับ TCP Stack:

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

หรือที่ระดับ NIC:

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

ปิด vRSS สำหรับ VMs ทั้งหมด:

Get-VM | Set-VMNetworkAdapter -VrssEnabled $FALSE

ปิด Large Send Offload (LSO) บน NICs:
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

สามารถปิดตัวเลือกเหล่านี้ใน Advanced Tab ของ Network Adapter Properties ได้อีกด้วย:

  • Recv Segment Coalescing (IPv4/IPv6) = Disabled
  • Large Send Offload V2 (IPv4/IPv6) = Disabled

ประสิทธิภาพเครือข่ายต่ำบน Hyper-V VMs ใน Windows Server 2019

TCP Stack Settings เหล่านี้จะทำให้ Network Protocol Settings ของ Windows Server 2019 ใกล้เคียงกับ Windows Server เวอร์ชันก่อนหน้า