目前比较常见的网站压力测试工具有webbench、ab、tcpcopy、loadrunner,下面介绍一下webbench的安装和使用。
wget http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz
tar -zxvf webbench-1.5.tar.gz
yum install -y gcc ctags
cd webbench-1.5 make && make install make clean
如果遇到如下问题:
install: cannot create regular file '/usr/local/man/man1': No such file or directory make: *** [install] Error 1
网上有说
mkdir /usr/local/man
执行完后,再次make应该就没问题了,如果还报错,那就走下面~
但是我发现man
目录是存在的,那问题只可能是权限了,修改好权限,问题解决。
chmod 777 /usr/local/man
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.
这里time和clients比较重要,
time是benchmark持续多久
clients是指time时间内请求多少次。
比如我们测试百度, 启动100个客户端同时请求百度首页,持续60S:
webbench -t 60 -c 100 http://www.baidu.com/
运行结果
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software. Benchmarking: GET http://www.baidu.com/ 100 clients, running 60 sec. Speed=1291 pages/min, 2542624 bytes/sec. Requests: 1291 susceed, 0 failed.
没有难的技术,当你弄清它的原理时,你会发现原来如此简单~ 欢迎加群【536501561】讨论