网络稳定性测试
- 关注的指标,avg(平均耗时)、loss(丢包率)
- route -n 网关ip查询,从IP routing table中可以看到0.0.0.0对应的ip
- ping
- -c表示运行的秒数,运行完会反馈下面的结果
- 实际执行的时间可能会大于设置的秒数
[root@iZ2ze5i5qr1kmeajdt3k6kZ ~]# ping -i 1 -q -c 86400 192.168.71.253
PING 192.168.71.253 (192.168.71.253) 56(84) bytes of data.
--- 192.168.71.253 ping statistics ---
86400 packets transmitted, 86400 received, 0% packet loss, time 86398301ms
rtt min/avg/max/mdev = 0.013/0.035/9.915/0.040 ms
- mtr
- -c表示运行的秒数,运行完会反馈下面的结果
- 会把经历了哪些IP最终到的IP都显示出来
[root@9Z2ze2i5Dr1gmeajpd8k2kZ ~]# mtr --report --no-dns --show-ips -i 1 -c 86400 172.36.10.8
Start: Tue May 8 20:32:46 2018
HOST: iZ2ze5i5qr1gmeajtd8k6kZ Loss% Snt Last Avg Best Wrst StDev
1.|-- 192.168.69.139 0.0% 86400 1.1 1.0 1.0 7.3 0.1
2.|-- 172.36.10.8 0.0% 86400 1.1 1.1 1.1 20.1 0.1
HTTP压测
-
关注的指标,RT(Latency Avg)、QPS(Requests/sec)、TPS(Transfer/sec)
-
测试的时候在接口中直接输出4K、16K、32K的数据,模拟真实的情况。比直接压测一个hello Word更有说服力
-
netstat -ant | grep xxxx 、 lsof -i:port 可以对压测中的数据进行查看
-
siege
- 并发数限制为255,需要改配置文件
- 造成的压力不明显
-
ab
- 并发数限制为0-20000
-
wrk
- -latency 延时统计
- -timeout 请求超时时间
- -c 并发
- -t 要使用的线程数
- -d 测试持续时间
- wrk
[root@chons ~]# wrk --latency --timeout 5 -c 1000 -t 1 -d 60 http://192.168.69.145:8080/output/data16k
Running 1m test @ http://192.168.69.145:8080/output/data16k
1 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.41s 1.12s 5.00s 69.06%
Req/Sec 476.65 112.18 2.81k 93.50%
Latency Distribution
50% 1.08s
75% 2.08s
90% 3.11s
99% 4.62s
28476 requests in 1.00m, 463.92MB read
Socket errors: connect 0, read 0, write 0, timeout 1909
Requests/sec: 474.47
Transfer/sec: 7.73MB
DNS测试
- 生成了10W个随机子域名
- 测试工具queryperf
- 关注指标QPS、RT、成功率(失败率)
工具安装
- https://www.isc.org/downloads/
- wget https://www.isc.org/downloads/file/bind-9-10-7/?version=tar-gz
- 注意docker里面的系统无法直接wget,把下载好的文件放到宿主机器。使用docker cp命令
- 解压 && cd contrib/queryperf
- ./configure && make
- cp queryperf /usr/bin/
生成随机子域名
for i in $(seq 0 100000); do echo $i; echo "$(tr -dc a-z < /dev/urandom | head -c 12).default.svc.cluster.local A" >>testdata.txt; done
测试
-
queryperf [-d datafile] [-s server_addr] [-p port] [-q num_queries]
-
-d: 后面接上一个文件,文件的内容是用户对DNS的请求,一行为一条请求,所以为了测试,我们可以在里面写上几千几万条。
-
-s: DNS服务器地址
-
-p: DNS服务器端口
-
-q: 请求多少次
-
-
bash-4.3# queryperf -d testdata.txt -s 172.26.0.10 -q 5000
DNS Query Performance Testing Tool
Version: $Id: queryperf.c,v 1.12 2007/09/05 07:36:04 marka Exp $
[Status] Processing input data
[Status] Sending queries (beginning with 172.26.0.10)
Statistics:
[Timeout] Query timed out: msg id 4571
[Timeout] Query timed out: msg id 4572
[Timeout] Query timed out: msg id 4573
[Timeout] Query timed out: msg id 4574
[Timeout] Query timed out: msg id 4575
[Timeout] Query timed out: msg id 4576
[Timeout] Query timed out: msg id 4577
[Timeout] Query timed out: msg id 26478
[Status] Testing complete
Statistics:
Parse input file: once
Ended due to: reaching end of file
Queries sent: 100001 queries
Queries completed: 100001 queries
Queries lost: 0 queries
Queries delayed(?): 0 queries
RTT max: 0.137697 sec
RTT min: 0.000201 sec
RTT average: 0.000520 sec
RTT std deviation: 0.001675 sec
RTT out of range: 0 queries
Percentage completed: 100.00%
Percentage lost: 0.00%
Started at: Mon May 14 18:59:04 2018
Finished at: Mon May 14 18:59:13 2018
Ran for: 8.893822 seconds
Queries per second: 11243.872432 qps