最近项目新增了一个接口,一键导出五个报表的数据,因为数据量有些大,需要测试一下性能,就用wrk压了一下。
然而压测过程中发现,请求似乎一直没有发送出去,显示0 requests in xxxs, 0.00B read
(倒数第三行),不断尝试各种修改lua脚本,还是0 requests
➜ ~ wrk -t4 -c10 -d10s -s export_all.lua --latency https://xxxx/export/all
Running 10s test @ https://xxxx/export/alll
4 threads and 10 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 0.00us 0.00us 0.00us nan%
Req/Sec 0.00 0.00 0.00 nan%
Latency Distribution
50% 0.00us
75% 0.00us
90% 0.00us
99% 0.00us
0 requests in 10.01s, 0.00B read
Requests/sec: 0.00
Transfer/sec: 0.00B
后来同事说:会不会10s内这个接口还没请求完成?
立刻尝试将时间调整为30s,问题完美解决了……
然而出现了8个timeout的接口,咋办呢,那就加个--timeout参数吧。开发告诉我,这个接口的超时设置为300s(Orz……没办法,数据量太大了),好吧,问题又来了,在命令中加入--timeout 300s
报错了:[1] 59503 segmentation fault wrk -t4 -c10 -d1000s -s --timeout 300s
google也没找到关于timeout可设置的最大值,好吧,没有感情的重复尝试机器模式,不断的取中间值,终于发现,可设置的最大值是228s
然鹅……当我修改参数为wrk -t2 -c2 -d60s -s export_all.lua --latency https://xxxx/export/all --timeout 240s
时,它居然又能跑起来
➜ ~ wrk -t2 -c2 -d60s -s export_all.lua https://xxxx/export/all --latency --timeout 240s
Running 1m test @ https://xxxx/export/all
2 threads and 2 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 1.22s 536.48ms 3.76s 92.59%
Req/Sec 0.24 0.43 1.00 76.47%
Latency Distribution
50% 1.06s
75% 1.21s
90% 1.39s
99% 3.59s
102 requests in 1.00m, 15.62MB read
Requests/sec: 1.70
Transfer/sec: 266.39KB
这个问题先放这,等我找到timeout相关说明再来补充
网友评论