一、安装工具ab
- CentOS6默认安装
- CentOS7需要手动安装
CentOS7安装方式如下- 联网:yum install httpd-tools
- 无网络:
(1)进入cd/run/media/root/CentOS7×86_64/Packages(路径跟centos6不同)
(2)顺序安装
apr-l.4.8-3.el7.x86_64.rpm
apr-util-l.5.2-6.e.×86-64.rpm
httpd-too1s-2.4.6-67.e17.centos.x86_64.rpm
二、使用方式
ab -n [请求数] -c [并发数] -p [指定请求数据文件] -T "application/x-www-form-urlencoded" [测试的请求]
-p
表示POST请求的请求数据文件。
文件格式:[key]=[value]&[key]=[value]…
示例如何
ab -n 1000 -c 200 -p /opt/postfile -T "application/x-www-form-urlencoded" token.abc4m.cn/api/weixin/info
请求数据文件我放在/opt/postfile
文件中。内容如下:c=1ea1e&
三、结果显示
测试结果如下:
[root@com opt]# ab -n 1000 -c 200 -p /opt/postfile -T "application/x-www-form-urlencoded" token.abc4m.cn/api/weixin/info
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 token.abc4m.cn (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
apr_pollset_poll: The timeout specified has expired (70007)