深浅模式
bash
sudo apt update && \
sudo apt install -y build-essential git libev-dev libtool m4如果提示 autoconf 版本过低
bashsudo apt remove autoconfbashwget http://ftp.gnu.org/gnu/autoconf/autoconf-2.72.tar.gz && \ tar -xzf autoconf-2.72.tar.gz && \ cd autoconf-2.72 && \ ./configure --prefix=/usr/local && \ make && \ sudo make install
下载
bash
wget -O weighttp-weighttp-0.5.tar.gz https://github.com/lighttpd/weighttp/archive/refs/tags/weighttp-0.5.tar.gz解压
bash
tar -zxvf weighttp-weighttp-0.5.tar.gz进入目录
bash
cd weighttp-weighttp-0.5安装
bash
./autogen.sh && \
./configure && \
make && \
make install验证
bash
weighttp -Vbash
# 高并发测试
weighttp -c 500 -k -n 500 -t 4 127.0.0.1:80
# 启用 Keep-Alive
weighttp -n 500 -c 20 -k 127.0.0.1:80
# 指定超时时间
weighttp -n 100 -c 10 --timeout 5 127.0.0.1:80用法
weighttp使用与apache bench(ab) 类似的命令行参数来表示 weighttp 支持的功能子集:
中文注解
weighttp <选项> <URI>
-n num 请求数(强制)
-t num 线程数(默认值:1)(注意:与@ab -t timeout@不同)
-c num 并发客户端(默认值:1)
-k 保持活动(默认值:否)
-K num num 流水线请求(默认值:1)(注意:不是@ab@的功能)
-6 使用 ipv6(默认值:否)
-i 使用 HTTP HEAD 方法(默认:GET)
-m 方法使用自定义 HTTP 方法(默认值:GET)
-H str 向请求添加标题(“标签:值”);可重复
-b size 套接字缓冲区大小(SO_SNDBUF、SO_RCVBUF)
-B addr 建立传出连接时绑定的本地地址
-C cookie 将 cookie 添加到请求(“cookie-name=value”);可重复
-F 使用 TCP 快速打开(RFC 7413)
-T 类型 Content-Type 标头用于 POST/PUT 数据,
例如应用程序/x-www-form-urlencoded
(默认值:文本/纯文本)
-A 字符串添加基本 WWW 授权(str 是用户名:密码)
-P 字符串添加基本代理授权(str 是用户名:密码)
-X 代理代理:端口或 unix 域套接字路径以“/”开头
-p 文件使用文件内容作为正文发出 HTTP POST 请求
-u file 使用文件内容作为主体发出 HTTP PUT 请求
-d 不报告扩展百分位数(超出最小值、平均值、最大值)
-S 不显示标准差置信度警告
-l(忽略;与 Apache Bench (ab) 兼容)
-e 文件输出 CSV 文件,其中包含总服务时间的百分比
-r(忽略;与 Apache Bench (ab) 兼容)
-a 运行基准测试的最大时间秒数(或直到 -n 请求)
-s 截止秒数截止失败(默认值:4)
-q quiet:不显示版本标题或进度
-h 显示帮助并退出
-V 显示版本并退出英文注解
weighttp <options> <URI>
-n num number of requests (mandatory)
-t num thread count (default: 1) (note: differs from @ab -t timeout@)
-c num concurrent clients (default: 1)
-k keep alive (default: no)
-K num num pipelined requests (default: 1) (note: not a feature of @ab@)
-6 use ipv6 (default: no)
-i use HTTP HEAD method (default: GET)
-m method use custom HTTP method (default: GET)
-H str add header to request ("label: value"); repeatable
-b size socket buffer sizes (SO_SNDBUF, SO_RCVBUF)
-B addr local address to bind to when making outgoing connections
-C cookie add cookie to request ("cookie-name=value"); repeatable
-F use TCP Fast Open (RFC 7413)
-T type Content-Type header to use for POST/PUT data,
e.g. application/x-www-form-urlencoded
(default: text/plain)
-A string add Basic WWW Authorization (str is username:password)
-P string add Basic Proxy-Authorization (str is username:password)
-X proxy proxy:port or unix domain socket path beginning w/ '/'
-p file make HTTP POST request using file contents for body
-u file make HTTP PUT request using file contents for body
-d do not report extended percentiles (beyond min,mean,max)
-S do not show standard deviation confidence warnings
-l (ignored; compatibility with Apache Bench (ab))
-e file output CSV file with percentages for total time to serve
-r (ignored; compatibility with Apache Bench (ab))
-a time max seconds to run benchmark (or until -n requests)
-s cutoff seconds to cutoff fails (default: 4)
-q quiet: do not show version header or progress
-h show help and exit
-V show version and exit