ab
ab是apache自带的一款功能强大的测试工具。安装了apache一般就自带了。
安装目录默认为:/usr/bin/ab
安装httpd-tools:
[root@4662b88202f1 ~]# yum -y install httpd-tools
ab命令帮助
[root@4662b88202f1 ~]# ab -h
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
-l Accept variable document length (use this for dynamic pages)
-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.
-m method Method name
-h Display usage information (this message)
-I Disable TLS Server Name Indication (SNI) extension
-Z ciphersuite Specify SSL/TLS cipher suite (See openssl ciphers)
-f protocol Specify SSL/TLS protocol
(SSL2, TLS1, TLS1.1, TLS1.2 or ALL)
-E certfile Specify optional client certificate chain and private key
支持http及https,ab命令请求测试:
[root@4662b88202f1 ~]# ab -c 100 -n 1000 https://lolicp.com/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking lolicp.com (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
Completed 1000 requests
Finished 1000 requests
Server Software: WAF/2.4-12.1
Server Hostname: lolicp.com
Server Port: 443
SSL/TLS Protocol: TLSv1.2,ECDHE-RSA-AES256-GCM-SHA384,2048,256
Server Temp Key: ECDH P-256 256 bits
TLS Server Name: lolicp.com
Document Path: /
Document Length: 46275 bytes
Concurrency Level: 100
Time taken for tests: 5.681 seconds
Complete requests: 1000
Failed requests: 0
Total transferred: 46753985 bytes
HTML transferred: 46275000 bytes
Requests per second: 176.03 \[#/sec\] (mean)
Time per request: 568.089 \[ms\] (mean)
Time per request: 5.681 \[ms\] (mean, across all concurrent requests)
Transfer rate: 8037.16 \[Kbytes/sec\] received
Connection Times (ms)
min mean\[+/-sd\] median max
Connect: 113 183 163.2 135 2044
Processing: 81 222 257.3 140 3962
Waiting: 36 87 115.7 48 2075
Total: 194 405 315.3 294 4092
Percentage of the requests served within a certain time (ms)
50% 294
66% 350
75% 443
80% 522
90% 690
95% 937
98% 1311
99% 1898
100% 4092 (longest request)
\[root@4662b88202f1 \~\]# ab -c 100 -n 1000 http://lolicp.com/
This is ApacheBench, Version 2.3 \<$Revision: 1843412 $\>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking lolicp.com (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
Completed 1000 requests
Finished 1000 requests
Server Software: WAF/2.4-12.1
Server Hostname: lolicp.com
Server Port: 80
Document Path: /
Document Length: 176 bytes
Concurrency Level: 100
Time taken for tests: 0.965 seconds
Complete requests: 1000
Failed requests: 0
Non-2xx responses: 1000
Total transferred: 414000 bytes
HTML transferred: 176000 bytes
Requests per second: 1036.02 \[#/sec\] (mean)
Time per request: 96.523 \[ms\] (mean)
Time per request: 0.965 \[ms\] (mean, across all concurrent requests)
Transfer rate: 418.86 \[Kbytes/sec\] received
Connection Times (ms)
min mean\[+/-sd\] median max
Connect: 35 41 3.6 41 56
Processing: 35 43 7.1 42 125
Waiting: 35 42 7.1 41 125
Total: 71 83 9.5 83 170
`Percentage of the requests served within a certain time (ms)
50% 83
66% 84
75% 91
80% 92
90% 93
95% 94
98% 97
99% 120
100% 170 (longest request)`
http_load
http_load以并行复用的方式运行,用以测试web服务器的吞吐量与负载。但是它不同于大多数压力测试工具,它可以以一个单一的进程运行,一般不会把客户机搞死。还可以测试HTTPS类的网站请求。
软件官网页面:https://acme.com/software/http_load/
安装目录默认为:/usr/local/bin/http_load
下载压缩包并编译安装:
[root@dd643482f260 ~]# curl https://acme.com/software/http_load/http_load-09Mar2016.tar.gz -o http_load-09Mar2016.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 17339 100 17339 0 0 12142 0 0:00:01 0:00:01 --:--:-- 12133
[root@dd643482f260 ~]# tar xf http_load-09Mar2016.tar.gz
[root@dd643482f260 ~]# cd http_load-09Mar2016
[root@dd643482f260 http_load-09Mar2016]# yum -y install make gcc gcc-c++
[root@dd643482f260 http_load-09Mar2016]# make
cc -O -ansi -pedantic -U__STRICT_ANSI__ -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wno-long-long -c timers.c
cc -O -ansi -pedantic -U__STRICT_ANSI__ -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wno-long-long http_load.c timers.o -s -o http_load
[root@dd643482f260 http_load-09Mar2016]# make install
rm -f /usr/local/bin/http_load
cp http_load /usr/local/bin
rm -f /usr/local/man/man1/http_load.1
cp http_load.1 /usr/local/man/man1
cp: cannot create regular file '/usr/local/man/man1': No such file or directory
make: *** [Makefile:36: install] Error 1
查看帮助:
[root@dd643482f260 http_load-09Mar2016]# http_load -h
usage: http_load [-checksum] [-throttle] [-proxy host:port] [-verbose] [-timeout secs] [-sip sip_file]
-parallel N | -rate N [-jitter]
-fetches N | -seconds N
url_file
One start specifier, either -parallel or -rate, is required.
One end specifier, either -fetches or -seconds, is required.
进行测试:
[root@dd643482f260 http_load-09Mar2016]# echo 'http://lolicp.com/' > test.url
[root@dd643482f260 http_load-09Mar2016]# http_load -r 1000 -f 10000 test.url
10001 fetches, 29 max parallel, 1.76018e+06 bytes, in 81.6393 seconds
176 mean bytes/connection
122.502 fetches/sec, 21560.4 bytes/sec
msecs/connect: 68.771 mean, 127.372 max, 59.622 min
msecs/first-response: 65.3248 mean, 364.204 max, 35.49 min
HTTP response codes:
code 301 -- 10001
如需开启https测试,需修改Makefile文件:
[root@a25372746bb5 http_load-09Mar2016]# sed -i 's/^#SSL_/SSL_/g' Makefile
[root@a25372746bb5 http_load-09Mar2016]# make
cc -O -DUSE_SSL -I/usr/local/ssl/include -ansi -pedantic -U__STRICT_ANSI__ -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wno-long-long -c timers.c
cc -O -DUSE_SSL -I/usr/local/ssl/include -ansi -pedantic -U__STRICT_ANSI__ -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wno-long-long http_load.c timers.o -s -L/usr/local/ssl/lib -lssl -lcrypto -o http_load
http_load.c:45:10: fatal error: openssl/ssl.h: No such file or directory
#include <openssl/ssl.h>
^~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:27: http_load] Error 1
`[root@a25372746bb5 http_load-09Mar2016]# yum -y install openssl-devel --nogpgcheck`
[root@a25372746bb5 http_load-09Mar2016]# make
cc -O -DUSE_SSL -I/usr/local/ssl/include -ansi -pedantic -U__STRICT_ANSI__ -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wno-long-long http_load.c timers.o -s -L/usr/local/ssl/lib -lssl -lcrypto -o http_load
[root@a25372746bb5 http_load-09Mar2016]# make install
rm -f /usr/local/bin/http_load
cp http_load /usr/local/bin
rm -f /usr/local/man/man1/http_load.1
cp http_load.1 /usr/local/man/man1
cp: cannot create regular file '/usr/local/man/man1': No such file or directory
make: *** [Makefile:36: install] Error 1
开始https测试:
[root@a25372746bb5 http_load-09Mar2016]# echo 'https://lolicp.com/' > test.url
usage: http_load [-checksum] [-throttle] [-proxy host:port] [-verbose] [-timeout secs] [-sip sip_file]
[-cipher str]
-parallel N | -rate N [-jitter]
-fetches N | -seconds N
url_file
One start specifier, either -parallel or -rate, is required.
One end specifier, either -fetches or -seconds, is required.
[root@a25372746bb5 http_load-09Mar2016]# http_load -r 100 -f 500 test.url
501 fetches, 16 max parallel, 2.31838e+07 bytes, in 56.4463 seconds
46275 mean bytes/connection
8.87569 fetches/sec, 410723 bytes/sec
msecs/connect: 404.538 mean, 629.76 max, 74.803 min
msecs/first-response: 338.945 mean, 619.686 max, 120.153 min
HTTP response codes:
code 200 -- 501
webbench
webbench是Linux下的一个网站压力测试工具,最多可以模拟3万个并发连接去测试网站的负载能力。
官方页面: http://home.tiscali.cz/~cz210552/webbench.html
安装目录默认为:/usr/local/bin/webbench
一次安装依赖:
yum -y install make gcc gcc-c++ ctags
开始下载并编译安装:
[root@7ff1fad0b95a ~]# curl http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz -o webbench-1.5.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7675 100 7675 0 0 8955 0 --:--:-- --:--:-- --:--:-- 8945
[root@7ff1fad0b95a ~]# tar xf webbench-1.5.tar.gz
[root@7ff1fad0b95a ~]# cd webbench-1.5
[root@7ff1fad0b95a webbench-1.5]# make
ctags *.c
[root@7ff1fad0b95a webbench-1.5]# make install
install -s webbench /usr/local/bin
install -m 644 webbench.1 /usr/local/man/man1
install: cannot create regular file '/usr/local/man/man1': No such file or directory
make: *** [Makefile:16: install] Error 1
遇到的报错:
[root@7ff1fad0b95a webbench-1.5]# make
bash: make: command not found
解决方法
[root@7ff1fad0b95a webbench-1.5]# yum -y install make
[root@7ff1fad0b95a webbench-1.5]# make
cc -Wall -ggdb -W -O -c -o webbench.o webbench.c
make: cc: Command not found
make: *** [: webbench.o] Error 127
[root@7ff1fad0b95a webbench-1.5]# yum -y install gcc gcc-c++
[root@7ff1fad0b95a webbench-1.5]# make
cc -Wall -ggdb -W -O -c -o webbench.o webbench.c
webbench.c:21:10: fatal error: rpc/types.h: No such file or directory
#include
^~~~~
compilation terminated.
make: *** [: webbench.o] Error 1
本处采用临时拷贝文件,请make完成后还原。通常系统中都存在该文件。
[root@7ff1fad0b95a webbench-1.5]# cp /usr/include/sys/types.h /usr/include/rpc/
[root@7ff1fad0b95a webbench-1.5]# make
cc -Wall -ggdb -W -O -c -o webbench.o webbench.c
webbench.c: In function 'alarm_handler':
webbench.c:77:31: warning: unused parameter 'signal' [-Wunused-parameter]
static void alarm_handler(int signal)
~~^~~~
cc -Wall -ggdb -W -O -o webbench webbench.o
ctags *.c
/bin/sh: ctags: command not found
make: [Makefile:12: tags] Error 127 (ignored)
[root@7ff1fad0b95a webbench-1.5]# yum -y install ctags
webbench 命令帮助
[root@7ff1fad0b95a webbench-1.5]# webbench -h
webbench [option]... URL
-f|--force 不要等待服务器的回复.
-r|--reload 发送重新加载请求-语法: no-cache.
-t|--time <sec> 运行基准测试<sec>秒。 默认30.
-p|--proxy <server:port> 使用proxy服务进行请求.
-c|--clients <n> 一次运行<n> HTTP客户端。 默认一个.
-9|--http09 Use HTTP/0.9 样式请求.
-1|--http10 Use HTTP/1.0 协议.
-2|--http11 Use HTTP/1.1 协议.
--get 使用GET请求方法.
--head 使用HEAD请求方法.
--options 使用OPTIONS请求方法.
--trace 使用TRACE请求方法.
-?|-h|--help This information.
-V|--version Display program version.
暂只支持http方式,不支持https。请求测试:
[root@7ff1fad0b95a webbench-1.5]# webbench -c 1000 -t 2 http://lolicp.com/
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://lolicp.com/
1000 clients, running 2 sec.
`Speed=78119 pages/min, 421452 bytes/sec.
Requests: 2604 susceed, 0 failed.`
siege
一款开源的压力测试工具,可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行
下载页面:http://download.joedog.org/siege/
默认安装目录:/usr/local/bin/siege
下载压缩包并编译
[root@ebf27f2e7b16 ~]# curl http://download.joedog.org/siege/siege-4.0.5.tar.gz -o siege-4.0.5.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 512k 100 512k 0 0 10103 0 0:00:51 0:00:51 --:--:-- 3951
[root@ebf27f2e7b16 ~]# tar xf siege-4.0.5.tar.gz
[root@ebf27f2e7b16 ~]# cd siege-4.0.5
[root@ebf27f2e7b16 siege-4.0.5]# yum -y install openssl-devel gcc make
[root@ebf27f2e7b16 siege-4.0.5]# ./configure --with-ssl=/usr/include/openssl/ &&make &&make install
查看siege帮助:
[root@ebf27f2e7b16 siege-4.0.5]# siege -h
SIEGE 4.0.5
Usage: siege [options]
siege [options] URL
siege -g URL
Options:
-V, --version VERSION, prints the version number.
-h, --help HELP, prints this section.
-C, --config CONFIGURATION, show the current config.
-v, --verbose VERBOSE, prints notification to screen.
-q, --quiet QUIET turns verbose off and suppresses output.
-g, --get GET, pull down HTTP headers and display the
transaction. Great for application debugging.
-p, --print PRINT, like GET only it prints the entire page.
-c, --concurrent=NUM CONCURRENT users, default is 10
-r, --reps=NUM REPS, number of times to run the test.
-t, --time=NUMm TIMED testing where "m" is modifier S, M, or H
ex: --time=1H, one hour test.
-d, --delay=NUM Time DELAY, random delay before each request
-b, --benchmark BENCHMARK: no delays between requests.
-i, --internet INTERNET user simulation, hits URLs randomly.
-f, --file=FILE FILE, select a specific URLS FILE.
-R, --rc=FILE RC, specify an siegerc file
-l, --log[=FILE] LOG to FILE. If FILE is not specified, the
default is used: PREFIX/var/siege.log
-m, --mark="text" MARK, mark the log file with a string.
between .001 and NUM. (NOT COUNTED IN STATS)
-H, --header="text" Add a header to request (can be many)
-A, --user-agent="text" Sets User-Agent in request
-T, --content-type="text" Sets Content-Type in request
-j, --json-output JSON OUTPUT, print final stats to stdout as JSON
--no-parser NO PARSER, turn off the HTML page parser
--no-follow NO FOLLOW, do not follow HTTP redirects
`Copyright (C) 2020 by Jeffrey Fulmer, et al.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.`
siege压力测试结果:
[root@ebf27f2e7b16 siege-4.0.5]# siege -c 100 -r 1 https://lolicp.com/
`{ "transactions": 3900,
"availability": 100.00,
"elapsed_time": 15.67,
"data_transferred": 32.07,
"response_time": 0.30,
"transaction_rate": 248.88,
"throughput": 2.05,
"concurrency": 75.81,
"successful_transactions": 3800,
"failed_transactions": 0,
"longest_transaction": 7.13,
"shortest_transaction": 0.15
}`