Nginx压力测试工具之WebBench
在Apache中有自带的ab命令可以测试服务的压力,而nginx没有自带的命令,必须要采用第三方软件来测试,今天就简单介绍一下webbench对nginx的压力测试,压力测试是对系统管理员和运维人员必须的,可以很清晰地看清服务器能接受多大压力.注:本人是在虚拟机上做测试。
1.下载webbench软件和安装
wget http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz
tar xvf webbench-1.5.tar.gz -C /usr/local/
cd /usr/local/webbench-1.5/
make
make install
2.命令详解
[root@CentOS179min webbench-1.5]# ./webbench -help
webbench [option]... URL
-f|--force Don'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.
--get Use GET request method.
--head Use HEAD request method.
--options Use OPTIONS request method.
--trace Use TRACE request method.
-?|-h|--help This information.
-V|--version Display program version.
[root@centos179min webbench-1.5]#
webbench -c 并发数 -t 运行测试时间 URL
3、测试实例结果
当并发300时:
向http://test.domain.com/phpinfo.php发起300个线程请求,持续时间60秒
# webbench -c 300 -t 60 http://test.domain.com/phpinfo.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://test.domain.com/phpinfo.php
300 clients, running 60 sec.
Speed=24525 pages/min, 20794612 bytes/sec.
Requests: 24525 susceed, 0 failed.
速度:每秒钟响应请求数:24525 pages/min,每秒钟传输数据量20794612 bytes/sec.
返回数:24525次返回成功,0次返回失败
当并发1000时:
# webbench -c 1000 -t 60 http://test.domain.com/phpinfo.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://test.domain.com/phpinfo.php
1000 clients, running 60 sec.
Speed=24920 pages/min, 21037312 bytes/sec.
Requests: 24833 susceed, 87 failed.
当并发1000时,已经显示有87个连接failed了,说明超负荷了。
备注:
1、压力测试工作应该放到产品上线之前进行
2、测试时尽量跨公网模拟正式环境进行
3、测试时并发应当由小逐渐加大,比如并发100时观察一下网站负载是多少、打开是否流程,并发200时又是多少、网站打开缓慢时并发是多少、网站打不开时并发又是多少
3.测试网站压力
[root@centos179min webbench-1.5]# ./webbench -c 200 -t 10 http://192.168.1.179/test.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.1.179/test.php
200 clients, running 10 sec.
Speed=58386 pages/min, 51328516 bytes/sec. --每秒钟响应请求数:Speed=58386 pages/min,每秒钟传输数据量:51328516 bytes/sec
Requests: 9731 susceed, 0 failed. --10秒200个客户端请求没有失败
[root@centos179min webbench-1.5]# ./webbench -c 1000 -t 10 http://192.168.1.179/test.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.1.179/test.php
1000 clients, running 10 sec.
Speed=47916 pages/min, 42126676 bytes/sec.
Requests: 7986 susceed, 0 failed. --10秒1000个客户端请求也没有失败
[root@centos179min webbench-1.5]# ./webbench -c 2000 -t 10 http://192.168.1.179/test.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.1.179/test.php
2000 clients, running 10 sec.
Speed=50394 pages/min, 44303164 bytes/sec.
Requests: 8399 susceed, 0 failed. --10秒中内发2000个请求也没有失败
[root@centos179min webbench-1.5]# ./webbench -c 4000 -t 10 http://192.168.1.179/test.php
Webbench - Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.
Benchmarking: GET http://192.168.1.179/test.php
4000 clients, running 10 sec.
Speed=46644 pages/min, 40894852 bytes/sec.
Requests: 7749 susceed, 25 failed. --10秒内4000客户端发送请求就有25个失败,证明10秒并发不超过4000,注nginx没有做过忧化
[root@centos179min webbench-1.5]#
WebBench安装及测试 http://www.linuxidc.com/Linux/2013-04/83586.htm
用WebBench测试网站负载 http://www.linuxidc.com/Linux/2013-03/80612.htm
网站压力测试工具 WebBench http://www.linuxidc.com/Linux/2013-01/77510.htm
服务器压力测试工具WebBench的安装和使用 http://www.linuxidc.com/Linux/2012-08/69400.htm
Linux下网站压力测试工具WebBench下载安装使用 http://www.linuxidc.com/Linux/2011-02/31995.htm
Linux中两款并发测试工具ab&WebBench http://www.linuxidc.com/Linux/2011-01/31392.htm
使用Nginx搭建WEB服务器 http://www.linuxidc.com/Linux/2013-09/89768.htm
搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程 http://www.linuxidc.com/Linux/2013-09/89692.htm