feat(handler): add app

This commit is contained in:
2026-01-31 15:44:56 +08:00
parent 6b68a368f1
commit 4dc46659c9
25 changed files with 2516 additions and 14 deletions

53
docs/PERF_TEST.md Normal file
View File

@@ -0,0 +1,53 @@
# 性能压测说明App 管理接口)
本仓库默认不携带外部压测工具(如 wrk/oha/hey因此提供“可复现的压测方法 + 指标口径 + 建议阈值”,并建议在 CI/CD 或预发环境执行并归档结果。
## 1) 压测对象
- `GET /platform/apps`:分页列表(典型读流量)
- `POST /platform/apps`:创建(写流量)
- `POST /platform/apps/{app_id}/status-change-requests`:写流量
## 2) 指标口径
- 吞吐RPS
- 延迟p50 / p95 / p99
- 错误率:非 2xx 比例
- 资源CPU / 内存 / DB 连接池占用
## 3) 环境准备
- 数据库完成迁移:`./scripts/db/migrate.sh && ./scripts/db/verify.sh`
- 用平台租户 token 作为压测 token必须具备 `iam:app:read` 等权限)
- 建议在压测前预填充一定数量 apps如 1k/10k
## 4) 示例wrk
若环境已安装 `wrk`
```bash
wrk -t4 -c32 -d30s \\
-H "Authorization: Bearer <token>" \\
"http://127.0.0.1:3000/platform/apps?page=1&page_size=20"
```
## 5) 示例(纯 curl 简易压测)
该方式不统计精确吞吐与分位数,但可快速验证稳定性与错误率:
```bash
for i in $(seq 1 200); do
curl -s -o /dev/null -w "%{http_code}\\n" \\
-H "Authorization: Bearer <token>" \\
"http://127.0.0.1:3000/platform/apps?page=1&page_size=20" &
done
wait
```
## 6) 建议阈值(参考)
- `GET /platform/apps`p95 < 100ms本机/ AZ错误率 < 0.1%
- `POST /platform/apps`p95 < 200ms错误率 < 0.1%
实际阈值应结合数据库规模索引网关链路与部署规格确定