Fortio(Φορτίο)最初是 Istio 的负载测试工具,现已发展为独立项目,也被 Meshery 等项目采用。它能以指定的每秒查询数(QPS)运行,记录执行时间直方图并计算百分位数(如 p99),可运行指定时长、固定调用次数或直至中断。名称源自希腊语“φορτίο”,意为“负载/负担”。
启动 Fortio 服务器
shelldocker run -p 8080:8080 -p 8079:8079 fortio/fortio server &
此命令启动 Fortio 服务器,映射 HTTP 端口 8080 和 gRPC 端口 8079,可通过 http://localhost:8080/fortio/ 访问 Web UI。
运行负载测试
shelldocker run fortio/fortio load http://www.google.com/
对指定目标(如 http://www.google.com/)执行负载测试。
Go 安装:
shellgo get fortio.org/fortio
二进制下载:从 https://github.com/fortio/fortio/releases 下载对应平台的二进制文件。
macOS(Homebrew):
shellbrew install fortio
Windows:下载 ZIP 包并解压,在命令提示符中运行 fortio.exe server。
| 参数 | 描述与示例 |
|---|---|
-qps rate | 每秒查询数(QPS),0 表示无等待/最大 QPS(默认 8) |
-c connections | 并行连接数(goroutine/线程数,默认 4) |
-t duration | 测试持续时间(如 -t 30m 表示 30 分钟,默认 5s),0 表示运行至中断 |
-n numcalls | 固定调用次数,替代持续时间模式(默认 0,使用 -t) |
-r resolution | 直方图最低桶分辨率(秒,默认 0.001,即 1ms),建议设为预期典型延迟的 1/10 |
-H "header: value" | 添加请求头,可多次指定(如 -H "Host: example.com") |
-a | 自动保存 JSON 结果,文件名基于标签和时间戳 |
-json filename | JSON 结果输出文件(或 - 表示 stdout),默认相对 -data-dir 目录 |
-labels "l1 l2 ..." | 添加到 JSON 结果的额外标签,默认包含目标 URL 和主机名 |
运行 fortio help 查看所有命令和参数,包括 gRPC、TCP、UDP 测试相关参数。
shellfortio server & # 输出示例: # 14:11:05 I fortio_main.go:171> 未使用动态标志监控(使用 -config 设置监控目录) # Fortio 1.17.0 tcp-echo server listening on [::]:8078 # Fortio 1.17.0 grpc 'ping' server listening on [::]:8079 # Fortio 1.17.0 https redirector server listening on [::]:8081 # Fortio 1.17.0 echo server listening on [::]:8080 # Data directory is /Users/ldemailly/go/src/fortio.org/fortio # UI started - visit: http://localhost:8080/fortio/
shellfortio server -http-port 10.10.10.10:8088
将 HTTP 服务器绑定到 10.10.10.10:8088。
shell# 启动 HTTP 服务器监听 Unix 域套接字 fortio server --http-port /tmp/fortio-uds-http & # 通过 Unix 域套接字访问 fortio curl -unix-socket=/tmp/fortio-uds-http http://foo.bar/debug
shell# 启动 TCP 回显服务器 fortio tcp-echo & # 对 TCP 服务器执行最大 QPS 负载测试(100000 次调用) fortio load -qps -1 -n 100000 tcp://localhost:8078
shell# 启动 UDP 回显服务器 fortio udp-echo & # 对 UDP 服务器执行最大 QPS 负载测试(100000 次调用) fortio load -qps -1 -n 100000 udp://localhost:8078/
简单 gRPC Ping
shellfortio grpcping -n 5 localhost
向本地 gRPC 服务器发送 5 次 Ping 请求。
使用 TLS 的 gRPC Ping
shell# 启动带 TLS 的 Fortio 服务器 fortio server -cert /path/to/server.crt -key /path/to/server.key # 使用 CA 证书连接 fortio grpcping -cacert /path/to/ca.crt localhost
shellfortio load http://www.google.com
以默认 QPS(8)和持续时间(5s)测试 http://www.google.com。
负载测试结果包含以下关键指标:
例如,测试输出中可能包含:
Ended after 5.059691387s : 40 calls. qps=7.9056 Aggregated Function Time : count 40 avg 0.060587641 +/- 0.006564 min 0.052549016 max 0.089893269 sum 2.42350566 # target 50% 0.0605556 # target 75% 0.065 # target 90% 0.075 # target 99% 0.0849466
表示 40 次调用,QPS 约 7.9,平均延迟 0.06s,p99 延迟 0.0849s。
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务