Linux-ab压力测试

2019-07-12 linux 压力测试工具 ab 参考:https://www.cnblogs.com/myvic/p/7703973.html
ab是apachebench命令的缩写
ab安装:
yum -y install httpd-tools
检查是否安装成功:
ab -V

详情说明:

-n在测试会话中所执行的请求个数。默认时,仅执行一个请求。请求的总数量ab

-c一次产生的请求个数。默认是一次一个。请求的用户量

-t测试所进行的最大秒数。其内部隐含值是-n 50000,它可以使对服务器的测试限制在一个固定的总时间以内。默认时,没有时间限制。

-V显示版本号并退出


ab的应用

ab的命令参数比较多,我们经常使用的是-c和-n参数。

ab -c 10 -n 100 http://www.myvick.cn/index.php :同时处理100个请求并运行10次index.php

  -c10表示并发用户数为10

  -n100表示请求总数为100


ab post请求: post参数放在txt中
ab -c 20 -n 20 -H 'token:dnJlZGl0' -T 'application/json' -p /root/addloanCheck.txt http://xxx/decision-route-server/decision/addloanquery

 

响应:

[root@work2 ~]# ab -c 10 -n 15 -T 'application/json' -p /root/pre-check.txt http://10.200.20.140:18114/api/fund-config/fund/pre-check
This is ApacheBench, Version 2.3 <$Revision: 1430300 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.200.20.140 (be patient).....done


Server Software:
Server Hostname: 10.200.20.140
Server Port: 18114

Document Path: /api/fund-config/fund/pre-check
Document Length: 351 bytes

Concurrency Level: 10
Time taken for tests: 1.154 seconds
Complete requests: 15
Failed requests: 0
Write errors: 0
Total transferred: 7365 bytes
Total body sent: 13020
HTML transferred: 5265 bytes
Requests per second: 12.99 [#/sec] (mean)
Time per request: 769.585 [ms] (mean)
Time per request: 76.959 [ms] (mean, across all concurrent requests)
Transfer rate: 6.23 [Kbytes/sec] received
11.01 kb/s sent
17.24 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 5 7 2.2 6 11
Processing: 197 385 107.9 425 496
Waiting: 196 385 107.8 425 493
Total: 203 392 108.6 433 501

Percentage of the requests served within a certain time (ms)
50% 427
66% 467
75% 480
80% 487
90% 490
95% 501
98% 501
99% 501
100% 501 (longest request)


#Percentage of requests served within a certain time(ms)这部分数据用于描述每个请求处理时间的分布情况,比如以上测试,80%的请求处理时间都不超过7ms,这个处理时间是指前面的Time per request,即对于单个用户而言,平均每个请求的处理时间

 

未完待续...

posted @ 2019-11-13 11:22  艳阳下的小菜园  阅读(237)  评论(0编辑  收藏  举报