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 10urls   #10个并发用户,连续不停访问10s,182fetches, 10max parallel, 1.03449e+06bytes, in 10.0038seconds--182次访问,最大并发数是10,总计传输数据1.03449e+06字节,运行时间10秒5684mean bytes/connection18.1932fetches/sec, 103410bytes/sec--每秒的响应请求18.1932,每秒传递的数据为103410字节msecs/connect: 24.8529mean, 1048.38max, 4.062min--连接平均响应时间是24.85毫秒,最大响应时间1048毫秒,最小响应时间4毫秒msecs/first-response: 483.459mean, 683.458max, 164.157min--每次连接平均返回时间 平均,最大,最小HTTP response codes:  code 200-- 182 | 
Apache Bench(Apache自带服务器压力测试工具)
| ➜ /Users/yxy >ab -c 10-n 50http://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 1996Adam 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:        641bytesConcurrency Level:      10Time taken fortests:   0.703secondsComplete requests:      50Failed requests:        0Total transferred:      39100bytesHTML transferred:       32050bytesRequests 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:        62126.413102Processing:    8711450.9107460Waiting:       8411451.0106459Total:        10013658.2119473Percentage 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 30http://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-b9ce61399d0710clients, running 30sec.Speed=3958pages/min, 51585bytes/sec.Requests: 1979susceed, 0failed. |