ab压测接口

安装ab

yum -y install httpd-tools

参数含义

-n即requests,用于指定压力测试总共的执行次数。
-c即concurrency,用于指定压力测试的并发数。
-t即timelimit,等待响应的最大时间(单位:秒)。
-b即windowsize,TCP发送/接收的缓冲大小(单位:字节)。
-p即postfile,发送POST请求时需要上传的文件,此外还必须设置-T参数。
-u即putfile,发送PUT请求时需要上传的文件,此外还必须设置-T参数。
-T即content-type,用于设置Content-Type请求头信息,例如:application/x-www-form-urlencoded,默认值为text/plain。
-v即verbosity,指定打印帮助信息的冗余级别。
-w以HTML表格形式打印结果。
-i使用HEAD请求代替GET请求。
-x插入字符串作为table标签的属性。
-y插入字符串作为tr标签的属性。
-z插入字符串作为td标签的属性。
-C添加cookie信息,例如:"Apache=1234"(可以重复该参数选项以添加多个)。
-H添加任意的请求头,例如:"Accept-Encoding: gzip",请求头将会添加在现有的多个请求头之后(可以重复该参数选项以添加多个)。
-A添加一个基本的网络认证信息,用户名和密码之间用英文冒号隔开。
-P添加一个基本的代理认证信息,用户名和密码之间用英文冒号隔开。
-X指定使用的代理服务器和端口号,例如:"126.10.10.3:88"。
-V打印版本号并退出。
-k使用HTTP的KeepAlive特性。
-d不显示百分比。
-S不显示预估和警告信息。
-g输出结果信息到gnuplot格式的文件中。
-e输出结果信息到CSV格式的文件中。
-r指定接收到错误信息时不退出程序。
-h显示用法信息,其实就是ab -help。

结果参数含义

Server Software: Apache/2.2.25 (服务器软件名称及版本信息)

Server Hostname: www.xxx.com(服务器主机名)

Server Port: 80 (服务器端口)

Document Path: /lol (供测试的URL路径)

Document Length: 0 bytes (供测试的URL返回的文档大小)



Concurrency Level: 100 (并发数)

Time taken for tests: 0.800 seconds (压力测试消耗的总时间)

Complete requests: 100 (压力测试的的总次数)

Failed requests: 0 (失败的请求数)

Total transferred: 16342 bytes (传输的总数据量)

HTML transferred: 0 bytes (HTML文档的总数据量)

Requests per second: 125.03 [#/sec] (mean) (平均每秒的请求数)

Time per request: 799.805 [ms] (mean) (所有并发用户(这里是100)都请求一次的平均时间)

Time per request: 7.998 [ms] (mean, across all concurrent requests) (单个用户请求一次的平均时间)

Transfer rate: 19.95 [Kbytes/sec] received (传输速率,单位:KB/s)

参数编写

ab -n 1000 -c 100 -t 1 -p /root/post.txt -T 'application/json'     接口地址 //类似于www.baidu.com/

结果:

Server Software:        nginx
Server Hostname:        ***
Server Port:            80

Document Path:          /api/mf0202
Document Length:        1568 bytes

Concurrency Level:      100
Time taken for tests:   2.005 seconds
Complete requests:      1113
Failed requests:        0
Write errors:           0
Non-2xx responses:      1114
Total transferred:      2117714 bytes
Total body sent:        612836
HTML transferred:       1746752 bytes
Requests per second:    555.15 [#/sec] (mean)
Time per request:       180.130 [ms] (mean)
Time per request:       1.801 [ms] (mean, across all concurrent requests)
Transfer rate:          1031.54 [Kbytes/sec] received
                        298.51 kb/s sent
                        1330.05 kb/s total

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        1    5   2.8      7      10
Processing:    20  165  21.6    171     307
Waiting:       16  165  21.8    171     307
Total:         22  170  22.1    175     309
发布了45 篇原创文章 · 获赞 3 · 访问量 7121

猜你喜欢

转载自blog.csdn.net/qq_38228582/article/details/102627000
今日推荐