首页 > 代码库 > centos7下ab测试(Apache Bench)
centos7下ab测试(Apache Bench)
一、环境准备安装和命令查看
1、安装工具
yum install httpd-tools
[root@localhost ttt]# yum install httpd-tools
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-tools-2.4.6-40.el7.centos.4.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-tools-2.4.6-40.el7.centos.4.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=====================================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================================
Installing: httpd-tools x86_64 2.4.6-40.el7.centos.4 updates 83 k
Installing for dependencies:apr x86_64 1.4.8-3.el7 base 103 k
apr-util x86_64 1.5.2-6.el7 base 92 k
Transaction Summary
====================================================================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 278 k
Installed size: 584 k
Is this ok [y/d/N]: y
Downloading packages:
(1/3): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm | 83 kB 00:00:00
(2/3): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00:00
(3/3): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------
Total 203 kB/s | 278 kB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.8-3.el7.x86_64 1/3
Installing : apr-util-1.5.2-6.el7.x86_64 2/3
Installing : httpd-tools-2.4.6-40.el7.centos.4.x86_64 3/3
Verifying : httpd-tools-2.4.6-40.el7.centos.4.x86_64 1/3
Verifying : apr-util-1.5.2-6.el7.x86_64 2/3
Verifying : apr-1.4.8-3.el7.x86_64 3/3
Installed:
httpd-tools.x86_64 0:2.4.6-40.el7.centos.4
Dependency Installed:
apr.x86_64 0:1.4.8-3.el7 apr-util.x86_64 0:1.5.2-6.el7
Complete!
2.ab测试的命令参数
ab: wrong number of arguments Usage: ab [options] [http[s]://]hostname[:port]/path Options are: -n requests Number of requests to perform -c concurrency Number of multiple requests to make at a time -t timelimit Seconds to max. to spend on benchmarking This implies -n 50000 -s timeout Seconds to max. wait for each response Default is 30 seconds -b windowsize Size of TCP send/receive buffer, in bytes -B address Address to bind to when making outgoing connections -p postfile File containing data to POST. Remember also to set -T -u putfile File containing data to PUT. Remember also to set -T -T content-type Content-type header to use for POST/PUT data, eg. ‘application/x-www-form-urlencoded‘ Default is ‘text/plain‘ -v verbosity How much troubleshooting info to print -w Print out results in HTML tables -i Use HEAD instead of GET -x attributes String to insert as table attributes -y attributes String to insert as tr attributes -z attributes String to insert as td or th attributes -C attribute Add cookie, eg. ‘Apache=1234‘. (repeatable) -H attribute Add Arbitrary header line, eg. ‘Accept-Encoding: gzip‘ Inserted after all normal header lines. (repeatable) -A attribute Add Basic WWW Authentication, the attributes are a colon separated username and password. -P attribute Add Basic Proxy Authentication, the attributes are a colon separated username and password. -X proxy:port Proxyserver and port number to use -V Print version number and exit -k Use HTTP KeepAlive feature -d Do not show percentiles served table. -S Do not show confidence estimators and warnings. -q Do not show progress when doing more than 150 requests -g filename Output collected data to gnuplot format file. -e filename Output CSV file with percentages served -r Don‘t exit on socket receive errors. -h Display usage information (this message) -Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers) -f protocol Specify SSL/TLS protocol (SSL2, SSL3, TLS1, TLS1.1, TLS1.2 or ALL)
二、测试方案
1、模拟每秒50次并发请求
centos7下ab测试(Apache Bench)