说明:介绍几款简单、易使用http压测工具,便于研发同学,压测服务,明确服务临界值,寻找服务瓶颈点。
压测时候可重点以下指标,关注并发用户数、TPS(每秒事务数量)、RT(事务响应时间)、事物失败率、CPU(不要超过70%)、LOAD(4核以下服务,不要超过2)
http_load
以并行复用的方式运行,以测试web服务器的吞吐量与负载。不同于大多数压力测试工具,它是单进程,所以一般不会把客户机搞死,也可以测试https类网站的请求。
支持多个url。
wget http:
//acme.com/software/http_load/http_load-14aug2014.tar.gz
tar zxvf http_load-14aug2014.tar.gz
ln -s http_load-14aug2014 http_load
cd http_load
make && make install
➜ /Users/yxy/data/soft/http_load >http_load --help
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.
参数简单说明
-parallel 简写-p:并发的用户数
-rate 简写-r:每秒访问次数
-fetches 简写-f:总计访问次数
-seconds 简写-s:持续访问时间
url_file 压测url(文件形式,需要访问的url,支持多个,每行一个)
|
执行实例
➜ /Users/yxy/data/soft/http_load >http_load -p
10
-s
10
urls #
10
个并发用户,连续不停访问10s,
182
fetches,
10
max parallel,
1
.03449e+
06
bytes, in
10.0038
seconds
--
182
次访问,最大并发数是
10
,总计传输数据
1
.03449e+
06
字节,运行时间
10
秒
5684
mean bytes/connection
18.1932
fetches/sec,
103410
bytes/sec
--每秒的响应请求
18.1932
,每秒传递的数据为
103410
字节
msecs/connect:
24.8529
mean,
1048.38
max,
4.062
min
--连接平均响应时间是
24.85
毫秒,最大响应时间
1048
毫秒,最小响应时间
4
毫秒
msecs/first-response:
483.459
mean,
683.458
max,
164.157
min
--每次连接平均返回时间 平均,最大,最小
HTTP response codes:
code
200
--
182
|
Apache Bench(Apache自带服务器压力测试工具)
➜ /Users/yxy >ab -c
10
-n
50
http:
//192.168.100.152:18800/casefolder-social/question/detail?shareUID=40d0c000-09b6-416c-b626-b9ce61399d07
-- -n 表示:每次请求数,默认不能超过
1024
个,-c表示:
1
个请求的并发连接数,默认最大不能超过
50000
。
-- 模拟
50
个并发连接每次以
100
个请求数来测试网站的Web性能
This is ApacheBench, Version
2.3
<$Revision:
1663405
$>
Copyright
1996
Adam Twiss, Zeus Technology Ltd, http:
//www.zeustech.net/
Licensed to The Apache Software Foundation, http:
//www.apache.org/
Benchmarking
192.168
.
100.152
(be patient).....done
Server Software: Apache-Coyote/
1.1
Server Hostname:
192.168
.
100.152
Server Port:
18800
Document Path: /casefolder-social/question/detail?shareUID=40d0c000-09b6-416c-b626-b9ce61399d07
Document Length:
641
bytes
Concurrency Level:
10
Time taken
for
tests:
0.703
seconds
Complete requests:
50
Failed requests:
0
Total transferred:
39100
bytes
HTML transferred:
32050
bytes
Requests per second:
71.16
[#/sec] (mean)
Time per request:
140.532
[ms] (mean)
Time per request:
14.053
[ms] (mean, across all concurrent requests)
Transfer rate:
54.34
[Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect:
6
21
26.4
13
102
Processing:
87
114
50.9
107
460
Waiting:
84
114
51.0
106
459
Total:
100
136
58.2
119
473
Percentage of the requests served within a certain time (ms)
50
%
119
66
%
126
75
%
131
80
%
132
90
%
217
95
%
223
98
%
473
99
%
473
100
%
473
(longest request)
|
webbench
使用方式和http_load相似,指标较为简单
webbench是Linux下的一个网站压力测试工具,最多可以模拟3万个并发连接去测试网站的负载能力。
下载地址:http://soft.vpser.net/test/webbench/webbench-1.5.tar.gz
安装非常简单
#tar zxvf webbench-
1.5
.tar.gz
#cd webbench-
1.5
#make && make install
|
会在当前目录生成webbench可执行文件,直接可以使用了
用法:webbench -c 并发数 -t 运行测试时间 URL
例如:
/Users/yxy/data/soft/webbench >webbench -c
10
-t
30
http:
//192.168.100.152:18800/casefolder-social/question/detail\?shareUID\=40d0c000-09b6-416c-b626-b9ce61399d07
Webbench - Simple Web Benchmark
1.5
Copyright (c) Radim Kolar
1997
-
2004
, GPL Open Source Software.
Benchmarking: GET http:
//192.168.100.152:18800/casefolder-social/question/detail?shareUID=40d0c000-09b6-416c-b626-b9ce61399d07
10
clients, running
30
sec.
Speed=
3958
pages/min,
51585
bytes/sec.
Requests:
1979
susceed,
0
failed.
|
参考文献