IP层
fping
- 可以一次ping多个主机
- 可以从主机列表文件ping
- 结果清晰 便于脚本处理
- 速度快
fping -A -u -c 10 122.x.x.x
# 122.x.x.x : xmt/rcv/%loss = 10/10/0%, min/avg/max = 3.16/4.28/6.05
网络性能
iperf
# server 10.224.41.36
iperf3 -s
# client 发送,带宽1M,时长10秒
iperf3 -c 10.224.41.36 -b 1M -t 10
# client 接收,带宽1M,时长10秒
iperf3 -c 10.224.41.36 -b 1M -t 10 -R
netperf
测试方法: 每种测试类型执行3次,中间睡眠10秒, 每种测试类型分别执行100、500、1500个实例, 每实例测试时间长度为60秒
# TCP_RR 1 byte: 测试TCP 小数据包 request/response的性能
netperf -t TCP_RR -H $serverip -c -C -l 60
# UDP_RR 1 byte: 测试UDP 小数据包 request/response的性能
netperf -t UDP_RR -H $serverip -c -C -l 60
# TCP_RR 256 byte: 测试TCP 大数据包 request/response的性能
netperf -t TCP_RR -H $serverip -c -C -l 60 -- -r256,256
# UDP_RR 256 byte: 测试UDP 大数据包 request/response的性能
netperf -t UDP_RR -H $serverip -c -C -l 60 -- -r256,256
运输层
nc
dd if=/dev/zero bs=512M count=1 | nc 10.224.41.36 8888
dd if=/dev/zero bs=512M count=1 | nc 10.200.100.24 8888
sudo nc -l 10.224.41.36 8888 >/dev/null
sudo nc -l 10.200.100.24 8888 >/dev/null
HTTP/HTTPS
webbech
wrk
https://github.com/wg/wrk
# 启用1个线程,每个线程并发100个连接,压测10秒
$ wrk -t1 -c100 -d10s --latency http://test.com
Running 10s test @ http://test.com(压测时间30s)
1 threads and 100 connections(共1个测试线程,100个连接)
Thread Stats Avg Stdev Max +/- Stdev
(平均值) (标准差) (最大值)(正负一个标准差所占比例)
Latency 316.94ms 319.23ms 1.99s 89.96%
(延迟)
Req/Sec 261.78 203.48 1.00k 77.66%
(每秒处理中的请求数)
Latency Distribution
(延迟分布)
50% 302.71ms
75% 378.96ms
90% 630.04ms
99% 1.60s
2634 requests in 10.05s, 5.44MB read
(10.05秒内共处理完成了2634个请求,读取了5.44MB数据)
Socket errors: connect 0, read 0, write 0, timeout 44
(Socket错误数统计,0个连接错误,0个读取错误,0个写入错误,44个超时)
Requests/sec: 262.22(平均每秒262.22个请求)
Transfer/sec: 554.27KB(平均每秒读取数据554.27KB)
vegeta
https://github.com/tsenart/vegeta
# http压测
./vegeta attack -timeout 1s -connections=500 -duration=60s -rate=25000 -targets test11.vip.txt > results.bin
# https压测
./vegeta attack -timeout 1s -connections=500 -duration=60s -rate=2000 -insecure -targets test11.ssl.txt > results.bin
# 查看结果
./vegeta report results.bin
# 不重用连接,增加CPS
./vegeta attack -keepalive=false -timeout=1s -connections=60000 -duration=60s -rate=28000 -targets test11.vip.txt > results.bin
./vegeta attack -keepalive=false -timeout=1s -connections=60000 -duration=60s -rate=60000 -targets target.txt |tee results.bin | ./vegeta report
test11.vip.txt
GET http://test11.vip.vip.com/
test11.ssl.txt
GET https://test11.vip.vip.com/
http_load
https://acme.com/software/http_load/
./http_load -parallel 1000 -seconds 120 http_load.txt 2>&1 > /dev/null
批量执行脚本
#!/bin/bash
if [ $# -ne 2 ]; then
echo 'command log_path process_num'
exit -1
fi
echo "$1 $2"
echo '开始测试'
for i in $(seq 1 $2);
do
./http_load -parallel 100 -seconds 60 http_load.txt 2>&1 >> $1 &
echo "./http_load -parallel 100 -seconds 60 http_load.txt 2>&1 >> $1 &"
done