1 个不稳定版本
0.0.1 | 2020年9月24日 |
---|
#56 in #基准测试
30KB
596 行代码
概述
网络服务基准测试工具。目前仅限于 HTTP(H1 或 H2,通过 TCP 或 TLS)。然而,它很容易扩展到其他协议。
用法
使用 cargo
构建
$ cargo build --release
$ ./target/release/service-benchmark help
USAGE:
service-benchmark [FLAGS] [OPTIONS] --num_req <NUMBER_OF_REQUESTS> [SUBCOMMAND]
FLAGS:
-v, --verbose Print debug information. Not recommended for `-n > 500`
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-c, --concurrency <CONCURRENCY> Concurrent threads. Default `1`.
-n, --num_req <NUMBER_OF_REQUESTS> Number of requests.
-r, --rate <RATE_PER_SECOND> Request rate per second. E.g. 100 or 0.1. By default no limit.
SUBCOMMANDS:
help Prints this message or the help of the given subcommand(s)
http Run in HTTP(S) mode
关于 http
命令的帮助
$./target/release/service-benchmark help http
USAGE:
service-benchmark http [FLAGS] [OPTIONS] <TARGET>
ARGS:
<TARGET> Target, e.g. https://my-service.com:8443/8kb
FLAGS:
--conn_reuse If connections should be re-used
--http2_only Enforce HTTP/2 only
--ignore_cert Allow self signed certificates. Applies to the target (not proxy).
--store_cookies If cookies should be stored
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
--tunnel <TUNNEL> HTTP Tunnel used for connection, e.g. http://my-proxy.org
示例
测试一个端点
./target/release/service-benchmark -c 4 -n 50000 \
http https://my-local-nginx.org/10kb --ignore_cert --conn_reuse
通过 HTTP 隧道
./target/release/service-benchmark -c 4 -n 50000 \
http https://my-local-nginx.org/10kb \
--tunnel https://127.0.0.1:8080 --ignore_cert --conn_reuse
给定请求速率(1,000 RPS)
./target/release/service-benchmark -c 4 -r 1000 -n 50000 \
http https://my-local-nginx.org/10kb \
--tunnel https://127.0.0.1:8080 --ignore_cert --conn_reuse
依赖项
~10–14MB
~288K SLoC