webbench
原理
webbench首先fork出多个子进程,每个子进程都循环做web访问测试。子进程把访问的结果通过pipe告诉父进程,父进程做最终的统计结果(转至百度百科)
安装
[root@VM_114_93_centos local]# wget http://home.tiscali.cz/cz210552/distfiles/webbench-1.5.tar.gz[root@VM_114_93_centos local]# tar -zxvf webbench-1.5.tar.gz webbench-1.5 webbench-1.5/webbench-1.5/webbench.1webbench-1.5/socket.cwebbench-1.5/webbench.cwebbench-1.5/Makefilewebbench-1.5/debian/webbench-1.5/debian/ruleswebbench-1.5/debian/dirswebbench-1.5/debian/copyrightwebbench-1.5/debian/controlwebbench-1.5/debian/changelogwebbench-1.5/COPYRIGHTwebbench-1.5/ChangeLog[root@VM_114_93_centos local]# cd webbench-1.5/[root@VM_114_93_centos webbench-1.5]# make && make install
安装过程中报错总结
/bin/sh: ctags: command not found,解决方法:yum install ctagsinstall: cannot create regular file ‘/usr/local/man/man1’: No such file or directory 解决方法:mkdir /usr/local/man然后在输出make && make install
使用
安装完成后输出webbench,出现help界面
[root@VM_114_93_centos webbench-1.5]# webbench webbench [option]... URL-f|--forceDon't wait for reply from server. -r|--reload Send reload request - Pragma: no-cache. -t|--time <sec>Run benchmark for <sec> seconds. Default 30. -p|--proxy <server:port> Use proxy server for request. -c|--clients <n> Run <n> HTTP clients at once. Default one. -9|--http09 Use HTTP/0.9 style requests. -1|--http10 Use HTTP/1.0 protocol. -2|--http11 Use HTTP/1.1 protocol. --getUse GET request method. --head Use HEAD request method. --optionsUse OPTIONS request method. --trace Use TRACE request method. -?|-h|--help This information. -V|--version Display program version.
使用
[root@VM_114_93_centos swoole]# webbench -c 1000 -t 10 /Webbench - Simple Web Benchmark 1.5Copyright (c) Radim Kolar 1997-, GPL Open Source Software.Benchmarking: GET /1000 clients, running 10 sec.Speed=5766 pages/min, 11568162 bytes/sec.Requests: 958 susceed, 3 failed.
速度:每秒钟响应请求数:5766 pages/min,每秒钟传输数据量11568162 bytes/sec.
返回数:958 次返回成功,3次返回失败
ab
ab(apache bench)是apache下的一个工具,主要用于对web站点做压力测试,
安装
可以值安装Apache的tools
yum -y install httpd-tools
使用
-n在测试会话中所执行的请求个数。默认时,仅执行一个请求。
-c一次产生的请求个数。默认是一次一个。
[dev@web ~]$ ab -c 20 -n 50000 http://192.168.1.210/This is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, /Licensed to The Apache Software Foundation, /Benchmarking 192.168.1.210 (be patient)Completed 5000 requestsCompleted 10000 requestsCompleted 15000 requestsCompleted 20000 requestsCompleted 25000 requestsCompleted 30000 requestsCompleted 35000 requestsCompleted 40000 requestsCompleted 45000 requestsCompleted 50000 requestsFinished 50000 requestsServer Software: nginx/1.6.2Server Hostname: 192.168.1.210Server Port: 80Document Path: /Document Length: 41005 bytes # 请求的页面大小Concurrency Level: 20 # 并发量Time taken for tests: 1180.733 seconds # 测试总共耗时Complete requests: 50000 # 完成的请求Failed requests: 0 # 失败的请求Write errors: 0 # 错误Total transferred: 2067550000 bytes # 总共传输数据量HTML transferred: 2050250000 bytesRequests per second: 42.35 [#/sec] (mean) # 每秒钟的请求量。(仅仅是测试页面的响应速度)Time per request: 472.293 [ms] (mean) # 等于 Time taken for tests/(complete requests/concurrency level) 即平均请求等待时间(用户等待的时间)Time per request: 23.615 [ms] (mean, across all concurrent requests) # 等于 Time taken for tests/Complete requests 即服务器平均请求响应时间 在并发量为1时 用户等待时间相同Transfer rate: 1710.03 [Kbytes/sec] received # 平均每秒多少K,即带宽速率Connection Times (ms)min mean[+/-sd] median maxConnect: 0 1 18.5 0 1001Processing: 38 471 534.1 155 9269Waiting: 37 456 524.6 147 9259Total: 40 472 534.5 155 9269Percentage of the requests served within a certain time (ms)50% 15566% 57175% 78380% 87190% 121195% 160398% 183999% 100% 9269 (longest request)
剩余参数可以用ap --help
查看
siege
安装
下载:wget /pub/siege/siege-latest.tar.gz解压: tar -zxvf siege-latest.tar.gzcd siege-*.*.*./configure --prefix=/usr/local/siege --mandir=/usr/local/man --with-ssl=/usr/local/sslmkdir -p /usr/local/siege/etcmkdir -p /usr/local/siege/varmakemake install查看配置文件/usr/local/siege/bin/siege -C
siege的使用
举例说明:
50个用户(每次并发量)重复100次 共产生 50*100 个请求
/usr/local/siege/bin/siege -c 50 -r 100
50个用户 重复100次 发送GET参数
/usr/local/siege/bin/siege -c 50 -r 100 /s?wd=siege&rsv_spt=1&issp=1&rsv_bp=0&ie=utf-8&tn=baiduhome_pg&rsv_sug3=4&rsv_sug=2&rsv_sug1=4&rsv_sug4=60
50个用户 重复100次 发送POST参数 (注意引号)
/usr/local/siege/bin/siege -c 50 -r 100 “/a.php POST name=zhangsan”
50个用户 重复100次 发送POST参数(从文件中读取)
/usr/local/siege/bin/siege -c 50 -r 100 “/a.php POST < /root/ab_test/post.xml”
另外还有挺多参数
详情请man 或 siege -h
Transactions: 10 hits :服务器接收的请求数Availability: 100.00 % :有效情况的比例Elapsed time: 1.06 secs : 测试所用的时间Data transferred:0.04 MB :每个模拟用户的数据传输量Response time: 0.03 secs :响应每个模拟用户请求的平均时间Transaction rate:9.43 trans/sec :服务器每秒处理事务的平均数Throughput: 0.04 MB/sec :服务器每秒跟所有模拟用户的数据传输量Concurrency:0.25 :每秒的模拟连接Successful transactions:10 :处理成功的事务数(code<400)Failed transactions:0 : 处理失败的事务数(code>400)Longest transaction: 0.04 :最长的事务处理时间Shortest transaction: 0.02 :最短的事务处理时间
/siege-faq/