微软开源基于 golang 开发的网络性能压测工具 ethr 实践
概述
Ethr 是一个用 golang 编写的跨平台网络性能测量工具。该项目的目标是提供一个本地工具,用于跨 TCP、UDP、HTTP、HTTPS 等多种协议以及跨多个平台的带宽、连接/秒、数据包/秒、延迟、丢失和抖动的全面网络性能测量; Ethr 支持多线程,这允许它扩展到 1024 甚至更多的连接数,多个客户端与单个服务器通信等; 用于延迟测量,它类似于 Windows 上的 latte 或 Linux 上的 sockperf
1、ethr 二进制安装
wget https://github.com/microsoft/ethr/releases/download/v1.0.0/ethr_linux.zip
unzip ethr_linux.zip
mv ethr /usr/local/bin && chmod +x ethr
2、ethr 命令行常见选项
-t 指定测试类型, 取值包括 b 带宽 c 每秒连接数 p 每秒包数 l 延迟、损耗和抖动 pi Ping 丢失和延迟
-x 指定适用于到目标站点的网络测试
-n 并发会话/线程数, 0 设置为当前 cpu 数
-d 测试时长, 0 不限时
-p 指定测试时的协议类型, 取值 tcp、udp 等
网络带宽
// 启动服务端
ethr -s -port 5203
// 带宽测试
ethr -c 192.168.31.11 -port 5203 -t b -d 1m
> Using destination: 192.168.31.11, ip: 192.168.31.11, port: 5203
> [ 5] local 192.168.31.16 port 30961 connected to 192.168.31.11 port 5203
> - - - - - - - - - - - - - - - - - - - - - - -
> [ ID ] Protocol Interval Bits/s
> [ 5] TCP 000-001 sec 15.49G
> [ 5] TCP 001-002 sec 18.59G
> [ 5] TCP 002-003 sec 15.20G
> [ 5] TCP 003-004 sec 15.48G
> [ 5] TCP 004-005 sec 17.46G
> [ 5] TCP 005-006 sec 16.17G
> [ 5] TCP 006-007 sec 16.11G
> [ 5] TCP 007-008 sec 16.30G
每秒转发包数
// 启动服务端
ethr -s -port 5203
// UDP 每秒包转发数 压测
ethr -c 192.168.31.11 -port 5203 -t p -p udp -n 0 -d 0
> Using destination: 192.168.31.11, ip: 192.168.31.11, port: 5203
> Protocol Interval Bits/s Pkts/s
> UDP 000-001 sec 50.77M 6.35M
> UDP 001-002 sec 52.93M 6.62M
> UDP 002-003 sec 55.81M 6.98M
> UDP 003-004 sec 52.76M 6.59M
> UDP 004-005 sec 51.86M 6.48M
> UDP 005-006 sec 55.79M 6.97M
> UDP 006-007 sec 54.71M 6.84M
> UDP 007-008 sec 55.80M 6.97M
> UDP 008-009 sec 53.74M 6.72M
> UDP 009-010 sec 51.79M 6.47M
> UDP 010-011 sec 51.09M 6.39M
> UDP 011-012 sec 51.88M 6.49M
// 测试结论: 每秒包转发数 65w,
// 备注: 暂不支持 TCP 协议的 PPS 压测
每秒新建连接数
// 启动服务端
ethr -s -port 5203
// 每秒新建 tcp 连接数测试
ethr -c 192.168.31.11 -port 5203 -t c -p tcp -d 1m -n 0
> Using destination: 192.168.31.11, ip: 192.168.31.11, port: 5203
> Protocol Interval Conn/s
> TCP 000-001 sec 53.63K
> TCP 001-002 sec 63.17K
> TCP 002-003 sec 59.12K
> TCP 003-004 sec 51.59K
> TCP 004-005 sec 45.38K
> TCP 005-006 sec 52.47K
> TCP 006-007 sec 54.58K
> TCP 007-008 sec 64.67K
> TCP 008-009 sec 62.43K
> TCP 009-010 sec 56.70K
> TCP 010-011 sec 62.75K
网络延时
// 启动服务端
ethr -s -port 5203
// TCP 延时测试
ethr -c 192.168.31.11 -port 5203 -t l -p tcp -d 1m -n 0
> Using destination: 192.168.31.11, ip: 192.168.31.11, port: 5203
> Running latency test: 1000, 1
> Avg Min 50% 90% 95% 99% 99.9% 99.99% Max
> 120.508us 82.948us 112.010us 149.992us 175.457us 243.291us 427.164us 427.164us 544.289us
> 167.457us 82.565us 105.179us 399.238us 615.316us 728.474us 778.789us 778.789us 795.993us
> 116.686us 83.275us 110.900us 147.542us 161.407us 215.930us 370.528us 370.528us 699.011us
> 120.487us 81.468us 112.020us 147.313us 173.125us 265.141us 552.161us 552.161us 844.891us
> 125.260us 95.676us 116.963us 151.482us 179.537us 240.500us 466.104us 466.104us 621.117us
> 122.701us 77.962us 114.985us 152.897us 175.167us 283.537us 537.144us 537.144us 795.253us
> 108.325us 74.415us 103.420us 129.317us 144.962us 193.497us 369.824us 369.824us 805.387us
> 134.934us 81.191us 123.791us 161.572us 218.611us 315.985us 638.850us 638.850us 713.924us
> 140.875us 76.917us 120.009us 169.095us 299.080us 595.553us 653.219us 653.219us 654.012us
> 118.709us 89.973us 108.923us 144.635us 174.059us 266.124us 449.520us 449.520us 609.781us
网站测试
// 站点 ping 延迟
ethr -x http://192.168.31.11 -p icmp -t pi -d 0 -4
> Using destination: 192.168.31.11, ip: 192.168.31.11, port: 80
> [icmp] [warmup] Ping to 192.168.31.11: 577.924us
> [icmp] Ping to 192.168.31.11: 610.218us
> [icmp] Ping to 192.168.31.11: 604.991us
> [icmp] Ping to 192.168.31.11: 683.871us
> [icmp] Ping to 192.168.31.11: 534.377us
> [icmp] Ping to 192.168.31.11: 453.957us
> [icmp] Ping to 192.168.31.11: 512.837us
> [icmp] Ping to 192.168.31.11: 588.904us
> [icmp] Ping to 192.168.31.11: 548.445us
> -----------------------------------------------------------------------------------------
> TCP connect statistics for 192.168.31.11:
> Sent = 8, Received = 8, Lost = 0
> -----------------------------------------------------------------------------------------
> Avg Min 50% 90% 95% 99% 99.9% 99.99% Max
> 567.200us 453.957us 548.445us 610.218us 610.218us 610.218us 610.218us 610.218us 683.871us
> -----------------------------------------------------------------------------------------
// 站点 tcp 连接延迟
ethr -x http://192.168.31.11 -p tcp -t pi -d 0 -4
> Using destination: 192.168.31.11, ip: 192.168.31.11, port: 80
> [tcp] [warmup] Connection from [192.168.31.16]:6337 to [192.168.31.11]:80: 1.004ms
> [tcp] Connection from [192.168.31.16]:61945 to [192.168.31.11]:80: 792.947us
> [tcp] Connection from [192.168.31.16]:15991 to [192.168.31.11]:80: 811.263us
> [tcp] Connection from [192.168.31.16]:10841 to [192.168.31.11]:80: 873.637us
> [tcp] Connection from [192.168.31.16]:58697 to [192.168.31.11]:80: 951.613us
> [tcp] Connection from [192.168.31.16]:30421 to [192.168.31.11]:80: 936.934us
> [tcp] Connection from [192.168.31.16]:14777 to [192.168.31.11]:80: 764.685us
> [tcp] Connection from [192.168.31.16]:48157 to [192.168.31.11]:80: 788.011us
> [tcp] Connection from [192.168.31.16]:8247 to [192.168.31.11]:80: 920.898us
> -----------------------------------------------------------------------------------------
> TCP connect statistics for [192.168.31.11]:80:
> Sent = 8, Received = 8, Lost = 0
> -----------------------------------------------------------------------------------------
> Avg Min 50% 90% 95% 99% 99.9% 99.99% Max
> 854.998us 764.685us 811.263us 936.934us 936.934us 936.934us 936.934us 936.934us 951.613us
> -----------------------------------------------------------------------------------------
长按、识别、二维码
关注
运维技术帮
你可能还喜欢