loadtest

command
v0.0.1-beta.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2026 License: AGPL-3.0 Imports: 21 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

loadtest 对网关打压测:固定并发 goroutine 持续请求,支持流式首字节和非流式完整响应延迟。 用法: go run ./tools/loadtest -mode stream -addr http://127.0.0.1:8080 -key ck-xxx -concurrency 10000 -duration 5m -healthz http://127.0.0.1:8080/healthz

go run ./tools/loadtest -mode fill -fill-type users -admin-jwt <platform_admin JWT> -concurrency 2000 -duration 5m

混合压测(模型请求 + 填充 API 并发):开两个 loadtest 进程同时跑——一个 -mode stream -keys keys.txt、一个 -mode fill,各自 -out 落盘。同机交错跑 + 每请求 CPU 对比(压测机 loadavg 50+,单进程内混流会让 fill 请求被流式 长连接饿死,双进程是简单可靠的分流)。 相对原设想的修正(均标注在行内):

  • os import 用 -out 兜底:把 RESULT 摘要同时写入文件(验收记录留档)。
  • 采样 goroutine 的 elapsed 直接取真实经过时间(原设计里 time.Since 套 time.Since 的表达式恒为 ~0s,属"简化输出"占位)。
  • 首字节采样从 sync.Map 改为 mutex map(并发 CAS 实测在 Go 1.26 HashTrieMap 上高争用会活锁,压测卡死,见压测记录)。
  • 连接级失败 100-300ms 抖动退避 + -warmup 预热窗口:Windows 监听 backlog≈200,无退避的突发拨号会形成自持 RST 拒绝风暴(500 并发 无退避实测 99.4% refused)。
  • 错误明细(err_detail)输出 + -pprof goroutine 转储,便于定位压测问题。

Directories

Path Synopsis
setup 构造多租户压测数据(数据模型 + 计费字段 + intelligent routing 新契约):模板(四格式 × 随机模型池 + loadtest 固定请求模型必含)→ 公开组 → 账号(分散模板/组/上游,可选采购成本倍率 + 共享缓存域)→ 用户(可选 余额/并发区间)→ 逐个登录建 key(可选多 key/并发/额度区间),key 明文写文件 (loadtest -keys 用)。
setup 构造多租户压测数据(数据模型 + 计费字段 + intelligent routing 新契约):模板(四格式 × 随机模型池 + loadtest 固定请求模型必含)→ 公开组 → 账号(分散模板/组/上游,可选采购成本倍率 + 共享缓存域)→ 用户(可选 余额/并发区间)→ 逐个登录建 key(可选多 key/并发/额度区间),key 明文写文件 (loadtest -keys 用)。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL