【学习笔记】web压力测试工具webbench

web压力测试工具webbench概述

webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好,安装使用也特别方便。

并发能力比较高,可以测试https及动态静态页面。

适合中小型网站测试承受能力。

1.适用系统:linux

2.核心原理

父进程fork若干个子进程,每个子进程在用户要求时间或默认的时间内对目标web循环发出实际访问请求,父子进程通过管道进行通信,子进程通过管道写端向父进程传递在若干次请求访问完毕后记录到的总信息,父进程通过管道读端读取子进程发来的相关信息,子进程在时间到后结束,父进程在所有子进程退出后统计并给用户显示最后的测试结果,然后退出。

3.编译安装

1.wget https://www.ha97.com/code/webbench-1.5.tar.gz
2.tar zxvf webbench-1.5.tar.gz
3.cd webbench-1.5
4.make
5.make install

4.使用

1.webbench -c 1000 -t 30 127.0.0.1/test.jpg

参数说明:-c表示并发数,-t表示时间(s)

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.