美文网首页
Azure VM的加速网络

Azure VM的加速网络

作者: 华阳_3bcf | 来源:发表于2018-10-30 14:54 被阅读0次

Azure多种机型都配置了FPGA卡,这是硬件基础,可以实现网络加速。

软件上,VM 跳过了虚拟化层面的hypervisor,直接和物理网卡的逻辑网卡通信。减少了对物理机CPU的占用,提高了效率。

在重载的应用中,网络侧占用CPU的资源大大减少,可以明显提升应用的流畅性。当然如果在轻载情况下,效果并不明显。

加速网络(Accelerated networking)支持的类型

加速网络支持大多数具有2个或更多vCPU的通用和计算优化实例大小。普通2个vCPU,有超线程技术的需要4个vCPU。

具体实操

参考文档:https://docs.microsoft.com/en-us/azure/virtual-network/create-vm-accelerated-networking-cli

Create resource group

$ az group create --name roy-fpga --location southeastasia

{
  "id": "/subscriptions/xxx/resourceGroups/roy-fpga",
  "location": "southeastasia",
  "managedBy": null,
  "name": "roy-fpga",
  "properties": {
    "provisioningState": "Succeeded"
  },
  "tags": null
}

Create vnet

$ az network vnet create -g roy-fpga -n roy-fpga-vnet --address-prefix 10.0.0.0/16 --subnet-name roy-fpga-subnet --subnet-prefix 10.0.0.0/24

{

  "newVNet": {
    "additionalProperties": {},
    "addressSpace": {
      "additionalProperties": {},
      "addressPrefixes": [
        "10.0.0.0/16"
      ]
    },
...
}

Create public ip

$ az network public-ip create --name roy-pip -g roy-fpga
{
  "publicIp": {
    "additionalProperties": {},
    "dnsSettings": null,
    "etag": "W/\"8681014a-1d63-41dd-8d36-3b7d0381c943\"",
....
  }
}

Create Nic

--accelerated-networking true 意思是网卡开启加速网络的功能

$ az network nic create \
-g roy-fpga \
> -n roy-pubnic \
> --vnet-name roy-fpga-vnet \
> --subnet roy-fpga-subnet \
> --accelerated-networking true \
> --public-ip-address roy-pip
{
  "NewNIC": {
    "additionalProperties": {},
    "dnsSettings": {
      "additionalProperties": {},
      "appliedDnsServers": [],
      "dnsServers": [],
      "internalDnsNameLabel": null,
      "internalDomainNameSuffix": "[50ap2osglnpe5ouvy5u5gwu21d.ix.internal.cloudapp.net](http://50ap2osglnpe5ouvy5u5gwu21d.ix.internal.cloudapp.net)",
      "internalFqdn": null
    },
    "enableAcceleratedNetworking": true,
    "enableIpForwarding": false,
...
}

Create VM

$ az vm create -g roy-fpga -n roy-pub-vm --image OpenLogic:CentOS:7.4:latest --size Standard_D4s_v3 --nics roy-pubnic --generate-ssh-keys
{
  "fqdns": "",
  "id": "/subscriptions/xxx/resourceGroups/roy-fpga/providers/[Microsoft.Compute/virtualMachines/roy-pub-vm](http://Microsoft.Compute/virtualMachines/roy-pub-vm)",
  "location": "southeastasia",
  "macAddress": "00-0D-3A-A2-D9-33",
  "powerState": "VM running",
  "privateIpAddress": "10.0.0.4",
  "publicIpAddress": "168.63.232.200",
  "resourceGroup": "roy-fpga",
  "zones": ""
}

Check on VM

[royzeng@roy-pub-vm ~]$ lspci
0000:00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (AGP disabled) (rev 03)
0000:00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 01)
0000:00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
0000:00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 02)
0000:00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA
0001:00:02.0 Ethernet controller: Mellanox Technologies MT27500/MT27520 Family [ConnectX-3/ConnectX-3 Pro Virtual Function]

发现了:Ethernet controller: Mellanox Technologies
这是Mellanox网卡的VF接口,说明带有加速网络的VM就创建好了。

软件测速

从github下载软件来测速

[royzeng@roy-pub-vm ~]$ git clone https://github.com/sivel/speedtest-cli.git
Cloning into 'speedtest-cli'...
remote: Enumerating objects: 1137, done.
remote: Total 1137 (delta 0), reused 0 (delta 0), pack-reused 1137
Receiving objects: 100% (1137/1137), 319.11 KiB | 293.00 KiB/s, done.
Resolving deltas: 100% (664/664), done.
[royzeng@roy-pub-vm ~]$ cd speedtest-cli/
[royzeng@roy-pub-vm speedtest-cli]$ python speedtest.py
Retrieving [speedtest.net](http://speedtest.net) configuration...
Testing from Microsoft Corp (168.63.232.200)...
Retrieving [speedtest.net](http://speedtest.net) server list...
Selecting best server based on ping...
Hosted by Singtel (Singapore) [6.25 km]: 3.595 ms
Testing download speed................................................................................
Download: 2028.88 Mbit/s
Testing upload speed................................................................................................
Upload: 1409.85 Mbit/s

多次测试,下载大约2Gbit,上传大约1.5Gbit。

额外的测试:(内网ip,更多cpu的VM)

For internal IP address test

$ az network nic create -g roy-fpga \
> --name roy-nic \
> --vnet-name roy-fpga-vnet \
> --subnet roy-fpga-subnet \
> --accelerated-networking true
{
  "NewNIC": {
    "additionalProperties": {},
    "dnsSettings": {
      "additionalProperties": {},
      "appliedDnsServers": [],
      "dnsServers": [],
      "internalDnsNameLabel": null,
      "internalDomainNameSuffix": "[50ap2osglnpe5ouvy5u5gwu21d.ix.internal.cloudapp.net](http://50ap2osglnpe5ouvy5u5gwu21d.ix.internal.cloudapp.net)",
      "internalFqdn": null
    },
     "enableAcceleratedNetworking": true,
    "enableIpForwarding": false,
...
 }
}

Create VM with larger size

$ az vm create -g roy-fpga -n roy-internal-vm --image OpenLogic:CentOS:7.4:latest --size Standard_D8s_v3 --nics roy-nic --generate-ssh-keys
{
  "fqdns": "",
  "id": "/subscriptions/xxx/resourceGroups/roy-fpga/providers/[Microsoft.Compute/virtualMachines/roy-internal-vm](http://Microsoft.Compute/virtualMachines/roy-internal-vm)",
  "location": "southeastasia",
  "macAddress": "00-0D-3A-A0-2A-C3",
  "powerState": "VM running",
  "privateIpAddress": "10.0.0.5",
  "publicIpAddress": "",
  "resourceGroup": "roy-fpga",
  "zones": ""
}

测速

From vm

[royzeng@roy-internal-vm speedtest-cli]$ python speedtest.py
Retrieving [speedtest.net](http://speedtest.net) configuration...
Testing from Microsoft Corporation (13.67.45.166)...
Retrieving [speedtest.net](http://speedtest.net) server list...
Selecting best server based on ping...
Hosted by MyRepublic (Singapore) [6.25 km]: 3.007 ms
Testing download speed................................................................................
Download: 2120.53 Mbit/s
Testing upload speed................................................................................................
Upload: 1371.83 Mbit/s

多次测试,多个cpu,在当前无负载的情况下,网速没有提高。

普通vm 测试:

$ az vm create -g roy-fpga -n roy-new --image OpenLogic:CentOS:7.4:latest --size Standard_D2s_v3 --generate-ssh-keys
{
  "fqdns": "",
  "id": "/subscriptions/xxx/resourceGroups/roy-fpga/providers/[Microsoft.Compute/virtualMachines/roy-new](http://Microsoft.Compute/virtualMachines/roy-new)",
  "location": "southeastasia",
  "macAddress": "00-0D-3A-A3-E5-66",
  "powerState": "VM running",
  "privateIpAddress": "10.0.0.6",
  "publicIpAddress": "168.63.238.227",
  "resourceGroup": "roy-fpga",
  "zones": ""
}

检查网络情况

[royzeng@roy-new speedtest-cli]$ lspci
00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (AGP disabled) (rev 03)
00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 01)
00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 02)
00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA

没有:Mellanox

网络测速

[royzeng@roy-new speedtest-cli]$ python speedtest.py
Retrieving [speedtest.net](http://speedtest.net) configuration...
Testing from Microsoft Corp (168.63.238.227)...
Retrieving [speedtest.net](http://speedtest.net) server list...
Selecting best server based on ping...
Hosted by Viewqwest Pte Ltd (Singapore) [6.25 km]: 3.064 ms
Testing download speed................................................................................
Download: 1919.65 Mbit/s
Testing upload speed................................................................................................
Upload: 168.21 Mbit/s

下载速度差不多,上传速度差异明显

提升现有vm网速

需要停机,再升级nic

VM deallocate
$ az vm deallocate -g roy-fpga -n roy-new
{
  "additionalProperties": {},
  "endTime": "2018-10-29T07:30:44.241096+00:00",
  "error": null,
  "name": "3c5aaac0-751c-4e5a-8acb-b27a09abf14d",
  "startTime": "2018-10-29T07:30:13.537983+00:00",
  "status": "Succeeded"
}
原来的vm size 不能提升网速,需要resize

(原来vm 的 size 用了超线程,但只有2个vCPU,加速网络需要4个vCPU)

$ az vm resize -g roy-fpga -n roy-new --size Standard_D4s_v3
{
  "additionalProperties": {},
  "availabilitySet": null,
  "diagnosticsProfile": null,
  "hardwareProfile": {
    "additionalProperties": {},
    "vmSize": "Standard_D4s_v3"
  },
....
}
然后提升网卡
$ az network nic update \
-n roy-newVMNic \
-g roy-fpga \
--accelerated-networking true
{
  "additionalProperties": {},
  "dnsSettings": {
    "additionalProperties": {},
    "appliedDnsServers": [],
    "dnsServers": [],
    "internalDnsNameLabel": null,
    "internalDomainNameSuffix": "[50ap2osglnpe5ouvy5u5gwu21d.ix.internal.cloudapp.net](http://50ap2osglnpe5ouvy5u5gwu21d.ix.internal.cloudapp.net)",
    "internalFqdn": null
  },
  "enableAcceleratedNetworking": true,
  "enableIpForwarding": false,
  "etag": "W/\"b297e515-7047-4056-ae6c-f10ef0103c50\"",
....
}

启动vm
$ az vm start -g roy-fpga -n roy-new
{
  "additionalProperties": {},
  "endTime": "2018-10-29T07:39:44.303596+00:00",
  "error": null,
  "name": "86c0623f-9136-42ca-b2ba-c28d6a9e1619",
  "startTime": "2018-10-29T07:39:24.944233+00:00",
  "status": "Succeeded"
}
登陆vm 检查
[royzeng@roy-new ~]$ lspci
0000:00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (AGP disabled) (rev 03)
0000:00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 01)
0000:00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)
0000:00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 02)
0000:00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA
0001:00:02.0 Ethernet controller: Mellanox Technologies MT27500/MT27520 Family [ConnectX-3/ConnectX-3 Pro Virtual Function]

多了: Ethernet controller: Mellanox

测速:
[royzeng@roy-new speedtest-cli]$ python speedtest.py
Retrieving [speedtest.net](http://speedtest.net) configuration...
Testing from Microsoft Corporation (13.67.40.11)...
Retrieving [speedtest.net](http://speedtest.net) server list...
Selecting best server based on ping...
Hosted by MyRepublic (Singapore) [6.25 km]: 2.047 ms
Testing download speed................................................................................
Download: 1703.39 Mbit/s
Testing upload speed................................................................................................
Upload: 1211.59 Mbit/s

上传速度从150M到1.2G,提升了8倍;下载速度,在轻载情况下相差不明显。

相关文章

网友评论

      本文标题:Azure VM的加速网络

      本文链接:https://www.haomeiwen.com/subject/ozsgtqtx.html