http压力测试工具及使用说明
转
说明:介绍几款简单、易使用http压测工具,便于研发同学,压测服务,明确服务临界值,寻找服务瓶颈点。
压测时候可重点以下指标,关注并发用户数、TPS(每秒事务数量)、RT(事务响应时间)、事物失败率、CPU(不要超过70%)、LOAD(4核以下服务,不要超过2)
- http_load
- Apache Bench(Apache自带服务器压力测试工具)
- webbench
http_load
以并行复用的方式运行,以测试web服务器的吞吐量与负载。不同于大多数压力测试工具,它是单进程,所以一般不会把客户机搞死,也可以测试https类网站的请求。
支持多个url。
官方网站
wget http://acme.com/software/http_load/http_load-14aug2014.tar.gztar zxvf http_load-14aug2014.tar.gzln -s http_load-14aug2014 http_loadcd http_loadmake && make install➜ /Users/yxy/data/soft/http_load >http_load --helpusage: http_load [-checksum] [-throttle] [-proxy host:port] [-verbose] [-timeout secs] [-sip sip_file] -parallel N | -rate N [-jitter] -fetches N | -seconds N url_fileOne 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/connection18.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).....doneServer Software: Apache-Coyote/1.1Server Hostname: 192.168.100.152Server Port: 18800Document Path: /casefolder-social/question/detail?shareUID=40d0c000-09b6-416c-b626-b9ce61399d07Document Length: 641 bytesConcurrency Level: 10Time taken for tests: 0.703 secondsComplete requests: 50Failed requests: 0Total transferred: 39100 bytesHTML transferred: 32050 bytesRequests 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] receivedConnection Times (ms) min mean[+/-sd] median maxConnect: 6 21 26.4 13 102Processing: 87 114 50.9 107 460Waiting: 84 114 51.0 106 459Total: 100 136 58.2 119 473Percentage 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-b9ce61399d07Webbench - Simple Web Benchmark 1.5Copyright (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-b9ce61399d0710 clients, running 30 sec.Speed=3958 pages/min, 51585 bytes/sec.Requests: 1979 susceed, 0 failed. |