如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Fortio(Φορτίο)最初是Istio的负载测试工具,现已发展为独立项目,名称源自希腊语“φορτίο”(意为“负载/负担”)。它是一个快速、轻量级(3Mb Docker镜像,依赖极少)的负载测试工具,同时也是可复用、可嵌入的Go库,支持命令行模式和服务器模式,服务器端包含简单Web UI及结果可视化功能。
Fortio主要用于以指定的每秒查询数(QPS)运行负载测试,记录执行时间直方图并计算百分位数(如p99,表示99%的请求响应时间小于该值)。支持按持续时间、固定调用次数运行,或持续运行直至中断。此外,它还提供类似httpbin的服务器端调试功能,如请求回显、延迟/错误注入、TCP/UDP回显、代理等。
Docker(推荐)
shell# 拉取镜像 docker pull fortio/fortio # 启动服务器模式(含Web UI) docker run -p 8080:8080 -p 8079:8079 fortio/fortio server # 运行负载测试 docker run fortio/fortio load http://www.google.com
源码安装
shell# 需Go 1.16+ go get fortio.org/fortio # 可执行文件位于$GOPATH/bin/fortio
二进制包
从https://github.com/fortio/fortio/releases%E4%B8%8B%E8%BD%BD%E5%AF%B9%E5%BA%94%E5%B9%B3%E5%8F%B0%E7%9A%84%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%8C%85%EF%BC%9A
shell# Linux示例 curl -L https://github.com/fortio/fortio/releases/download/v1.17.0/fortio-linux_x64-1.17.0.tgz \ | sudo tar -C / -xvzpf -
包管理器
brew install fortiofortio.exe核心参数(负载测试)
| 参数 | 描述示例 |
|---|---|
-qps rate | 查询每秒数(QPS),0表示无等待/最大速度(默认8) |
-c connections | 并行连接数(协程数)(默认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),建议配合.json后缀以便report命令识别 |
-labels "l1 l2" | 添加自定义标签到结果JSON(默认包含目标URL和主机名) |
完整参数列表
执行fortio help或查看https://github.com/fortio/fortio/wiki%E8%8E%B7%E5%8F%96%E5%85%A8%E9%83%A8%E5%8F%82%E6%95%B0%E3%80%82
1. 启动服务器(含Web UI)
shell# 默认端口(8080: HTTP服务,8079: GRPC服务) fortio server # 自定义HTTP端口 fortio server -http-port 10.10.10.10:8088 # Unix域套接字 fortio server --http-port /tmp/fortio-uds-http
Web UI访问地址:http://localhost:8080/fortio/
2. HTTP负载测试
shell# 基础测试(默认8 QPS,持续5s) fortio load http://www.google.com # 高并发测试(100 QPS,20连接,持续1分钟) fortio load -qps 100 -c 20 -t 1m https://api.example.com/v1/health # POST请求(指定 payload) fortio load -payload "test data" -content-type "application/json" https://api.example.com/v1/submit
3. TCP负载测试
shell# 启动TCP回显服务器 fortio tcp-echo & # 最大速度测试(10万次调用) fortio load -qps -1 -n 100000 tcp://localhost:8078
4. UDP负载测试
shell# 启动UDP回显服务器 fortio udp-echo & # 最大速度测试(10万次调用) fortio load -qps -1 -n 100000 udp://localhost:8078/
5. GRPC测试
shell# GRPC ping测试(5次调用) fortio grpcping -n 5 localhost:8079 # TLS加密GRPC测试 fortio grpcping -cacert /path/to/ca.crt localhost:8079
服务器模式(含Web UI)
shelldocker run -d \ -p 8080:8080 \ -p 8079:8079 \ --name fortio-server \ fortio/fortio server
访问http://localhost:8080/fortio/查看Web UI。
负载测试模式
shell# 测试本地服务(需确保容器网络可达) docker run --rm fortio/fortio load -qps 100 -t 30s http://host.docker.internal:8080/debug
无特殊环境变量,配置主要通过命令行参数实现。
通过-config参数指定配置目录,支持动态更新部分参数(如最大延迟max-echo-delay):
shellfortio server -config /path/to/config-dir
-a自动生成带时间戳的JSON结果(如fortio-20231001-123456.json)fortio report命令启动报告服务器,浏览历史结果:
shellfortio report -data-dir /path/to/results
shell$ fortio load -qps -1 -n 100000 tcp://localhost:8078 Fortio 1.17.0 running at -1 queries per second, 16->16 procs, for 100000 calls: tcp://localhost:8078 20:01:31 I tcprunner.go:218> Starting tcp test for tcp://localhost:8078 with 4 threads at -1.0 qps Starting at max qps with 4 thread(s) [gomax 16] for exactly 100000 calls (25000 per thread + 0) 20:01:32 I periodic.go:558> T003 ended after 1.240585427s : 25000 calls. qps=20151.77629520873 ... Aggregated Function Time : count 100000 avg 4.9404876e-05 +/- 1.145e-05 min 2.7697e-05 max 0.000887051 sum 4.94048763 # range, mid point, percentile, count >= 2.7697e-05 <= 0.000887051 , 0.000457374 , 100.00, 100000 # target 50% 0.00045737 # target 75% 0.00067221 # target 90% 0.000801115 # target 99% 0.000878457 # target 99.9% 0.000886192 All done 100000 calls (plus 0 warmup) 0.049 ms avg, 80495.0 qps
关键指标:
shell$ fortio grpcping -n 5 localhost 22:36:55 I pingsrv.go:150> Ping RTT 212000 (avg of 259000, 217000, 160000 ns) clock skew -10500 ... RTT histogram usec : count 15 avg 144.73333 +/- 44.48 min 101 max 259 sum 2171 # range, mid point, percentile, count >= 101 <= 110 , 105.5 , 26.67, 4 > 110 <= 120 , 115 , 40.00, 2 ... # target 50% 130
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。


来自真实用户的反馈,见证轩辕镜像的优质服务