Managing accelerated networking in Azure IaaS virtual machines

We can configure Azure virtual machines in IaaS (infrastructure-as-a-service) to take advantage of accelerated networking. This will improve the network component by reducing jitter, needing less CPU, lower latency, and higher packets per second. When the accelerated networking feature is not enabled, all the network traffic of any given VM traverses the virtualization host (Hyper-V) and the virtual switch. When using the accelerated networking feature, the traffic goes straight from the VM to the physical NIC (network interface card). Another benefit of receive side scaling (RSS) is that all TCP connection is shared across multiple processor cores. When this feature is not used, then all TCP connection is processed in a single processor.

Be aware that this feature is recommended to improve communication of virtual machines within the same virtual network. When publishing VMs to the Internet or communicated with on-premises workloads, you most likely will not see a significant change related to traffic performance.

RSS and Microsoft Azure VMs

We also need to be aware of a couple of configurations that must be met before enabling the RSS feature. The first one is the operating system type/version: If you are planning to use on Windows, the version must be at least Windows Server 2012 R2 Datacenter or newer. If your choice is Linux, then the kernel must have been released after October 2017 where the acceleration feature was enabled in the Linux kernel.

The second piece of the requirement is the VM type. The rule of thumb is that general-purpose and compute-optimized with two or move vCPUs should support the feature. If the VM type supports hyperthreading, then the rule of thumb is VM type with four or more vCPUs should support the functionality.

You may have noticed that I said should support, as you are aware, Microsoft Azure is dynamic and it is continuously changing. My recommendation is to avoid memorizing these type of rules and use Azure Portal to help you to check when you need to validate. Try to create a VM using Azure Portal and select the VM type that you want to verify, check the Networking tab. If the item Accelerated Networking is available and you can choose Yes (by default is No), that means that VM type has support to enable the RSS feature.

accelerated networking

Validating if an Azure VM is using accelerated networking

We can use PowerShell to gather the information about network adapters and then check if they have the accelerated network enabled.

The first step is to execute the Get-NetAdapter PowerShell cmdlet, which will list all existing network adapters on the current VM. The second step is to run Get-NetAdapterRSS using the network adapter name, and we should look for the Enabled property. If it says True, that means that network acceleration is enabled.

These were the two cmdlets used in the screenshot below.

Get-NetAdapter
Get-NetAdapterRSS -Name ‘Adapter Name’

accelerated networking

If you want to list all network adapters and their status, we can run the following cmdlet:

Get-NetAdapter | % {Get-NetAdapterRSS -Name $_.Name } | Select Name,Enabled

accelerated networking

The other change at the operating system level is the network adapter driver. We should see the Mellanox ConnectX being listed as depicted in the image below.

accelerated networking

We can also check if any given network interface attached to a virtual machine to see if the accelerated network is enabled. The first step is to find out the network interface name. In the VM blade, click on Networking and the name will be listed on the right side.

We can use Cloud Shell and run the cmdlet below to check if accelerated networking is enabled.

Get-AZNetworkInterface -Name ‘Interface-Name’ | Select Name,EnableAcceleratedNetworking

If you are not worried about a specific virtual machine network interface and just want to list all the network interfaces, the following cmdlet will list all your network interfaces at the subscription level and their current status.

Get-AzNetworkInterface | Select Name,EnableAcceleratedNetworking

Enabling accelerated networking on an existing virtual machine

If you have a running virtual machine, these steps can be used to enable the accelerated networking feature.

The first step is to stop the virtual machine and enable support to accelerated network at the virtual network level. These following cmdlets can be used to enable the support using Cloud Shell.

$tempNIC = Get-AZNetworkInterface -Name ‘vNICName’
$tempNIC.EnableAcceleratedNetworking
$tempNIC.EnableAcceleratedNetworking = $True
$tempNIC | Set-AZNetworkInterface

The final step is to start the VM, and the drivers will be automatically loaded into the virtual machine. We can always check using PowerShell in the VM to validate if the RSS has been enabled following the steps that we have done in the previous step.

Using a simple script to get the job done

If you want to automate this process on a VM basis, I wrote the following PowerShell script to perform the entire process. The script includes stopping the VM, changing the network accelerated feature, and starting the VM up again. The script can be found here.

Param(
    [string]$VMName
)
#retrieving Resource Group and Virtual vNIC
$vm = Get-AzVM | Where-Object { $_.Name -eq $vmName }
If (!$vm){
    Write-Host -Foregroundcolor 'Yellow' "The VM $vmName cannot be found in your current subscription."
    break
}Else{
    $rg = (Get-AzVM | Where-Object { $_.Name -eq $vmName } ).ResourceGroupName
    Write-Host "Stopping the VM $vmName..."
    Write-Host
    Stop-AzVM -Name $vmName -ResourceGroup $rg -Force
    Start-Sleep -Seconds 180
    $vtempNIC = Get-AzVM | Where-Object { $_.Name -eq $vmName }
    $vtempNIC = $vtempNIC.NetworkProfile.NetworkInterfaces.Id.Split("/")
    $vNIC = Get-AzNetworkInterface -Name $vTempNIC[-1]  -ResourceGroupName $rg
    $vNIC.EnableAcceleratedNetworking = $true
    $vNIC | Set-AzNetworkInterface
    Write-Host
    Write-Host "Starting the VM $vmName ..."
    Start-AzVM -ResourceGroup $rg -Name $vmName
}

Featured image: Shutterstock

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top