Azure多種機(jī)型都配置了FPGA卡惕稻,這是硬件基礎(chǔ)再榄,可以實(shí)現(xiàn)網(wǎng)絡(luò)加速。
軟件上襟诸,VM 跳過了虛擬化層面的hypervisor瓦堵,直接和物理網(wǎng)卡的邏輯網(wǎng)卡通信。減少了對(duì)物理機(jī)CPU的占用歌亲,提高了效率菇用。
在重載的應(yīng)用中,網(wǎng)絡(luò)側(cè)占用CPU的資源大大減少陷揪,可以明顯提升應(yīng)用的流暢性惋鸥。當(dāng)然如果在輕載情況下,效果并不明顯悍缠。
加速網(wǎng)絡(luò)(Accelerated networking)支持的類型
加速網(wǎng)絡(luò)支持大多數(shù)具有2個(gè)或更多vCPU的通用和計(jì)算優(yōu)化實(shí)例大小卦绣。普通2個(gè)vCPU,有超線程技術(shù)的需要4個(gè)vCPU飞蚓。
具體實(shí)操
參考文檔: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 意思是網(wǎng)卡開啟加速網(wǎng)絡(luò)的功能
$ 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]
發(fā)現(xiàn)了:Ethernet controller: Mellanox Technologies
這是Mellanox網(wǎng)卡的VF接口滤港,說明帶有加速網(wǎng)絡(luò)的VM就創(chuàng)建好了。
軟件測(cè)速
從github下載軟件來測(cè)速
[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
多次測(cè)試趴拧,下載大約2Gbit溅漾,上傳大約1.5Gbit。
額外的測(cè)試:(內(nèi)網(wǎng)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": ""
}
測(cè)速
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
多次測(cè)試樟凄,多個(gè)cpu,在當(dāng)前無負(fù)載的情況下兄渺,網(wǎng)速?zèng)]有提高缝龄。
普通vm 測(cè)試:
$ 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": ""
}
檢查網(wǎng)絡(luò)情況
[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
網(wǎng)絡(luò)測(cè)速
[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
下載速度差不多,上傳速度差異明顯
提升現(xiàn)有vm網(wǎng)速
需要停機(jī)挂谍,再升級(jí)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 不能提升網(wǎng)速叔壤,需要resize
(原來vm 的 size 用了超線程,但只有2個(gè)vCPU口叙,加速網(wǎng)絡(luò)需要4個(gè)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"
},
....
}
然后提升網(wǎng)卡
$ 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\"",
....
}
啟動(dòng)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
測(cè)速:
[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倍;下載速度妄田,在輕載情況下相差不明顯俺亮。