release: cut v2.1
This commit is contained in:
89
reports/perf/T11.1_PERF_REPORT.md
Normal file
89
reports/perf/T11.1_PERF_REPORT.md
Normal file
@@ -0,0 +1,89 @@
|
||||
# T11.1 性能基准报告
|
||||
|
||||
日期:2026-06-12
|
||||
仓库:`/home/long/project/gaokao-volunteer-system`
|
||||
目标:T6.1 FastAPI 管理后台骨架
|
||||
|
||||
## 1. 测试范围
|
||||
|
||||
使用 `locustfile.py` 对以下端点进行 10 并发基准:
|
||||
|
||||
- `POST /api/auth/login`
|
||||
- `GET /api/auth/me`
|
||||
- `GET /api/meta`
|
||||
- `GET /api/orders`
|
||||
- `GET /api/orders/{id}`(404 视为成功路径)
|
||||
- `GET /api/stats/orders`
|
||||
- `GET /health`
|
||||
|
||||
用户模型:
|
||||
|
||||
- `AdminBrowseUser`:已登录后台浏览用户
|
||||
- `LoginBurstUser`:登录高峰用户
|
||||
|
||||
## 2. 测试环境
|
||||
|
||||
- Python: 3.11.13
|
||||
- Locust: 2.42.4
|
||||
- 服务启动命令:`python3 -m admin.app --host 127.0.0.1 --port 18081`
|
||||
- 测试命令:`locust -f locustfile.py --host http://127.0.0.1:18081 --headless -u 10 -r 2 -t 30s --csv reports/perf/t11_1`
|
||||
- 数据库:`/home/long/project/gaokao-volunteer-system/.tmp/t11_1_admin.db`
|
||||
- JWT secret:本地临时测试值(64 个 `x`)
|
||||
|
||||
## 3. 发现与修复
|
||||
|
||||
首次执行失败,根因是 `AuthenticatedHttpUser` 作为基类未标记为抽象类,Locust 会把它当成可实例化用户,导致:
|
||||
|
||||
- 异常:`No tasks defined on AuthenticatedHttpUser`
|
||||
- 结果:进程退出码 1,压测结果不可信
|
||||
|
||||
已修复:
|
||||
|
||||
- `locustfile.py` 中为 `AuthenticatedHttpUser` 增加 `abstract = True`
|
||||
|
||||
修复后重新执行,压测正常结束,`failures.csv` 与 `exceptions.csv` 均为空。
|
||||
|
||||
## 4. 结果摘要
|
||||
|
||||
总体:
|
||||
|
||||
- 总请求数:327
|
||||
- 失败数:0
|
||||
- 错误率:0.00%
|
||||
- 平均吞吐:11.27 req/s
|
||||
- 聚合中位延迟:2 ms
|
||||
- 聚合平均延迟:4.62 ms
|
||||
- 聚合 P95:27 ms
|
||||
- 聚合 P99:36 ms
|
||||
- 聚合最大值:43.53 ms
|
||||
|
||||
分端点:
|
||||
|
||||
| 端点 | 请求数 | 失败 | 平均延迟(ms) | P95(ms) | 最大(ms) | 吞吐(req/s) |
|
||||
| -------------------------- | -----: | ---: | -----------: | ------: | -------: | ----------: |
|
||||
| POST /api/auth/login | 27 | 0 | 28.53 | 38 | 43.53 | 0.93 |
|
||||
| GET /api/auth/me | 71 | 0 | 2.52 | 3 | 4.49 | 2.45 |
|
||||
| GET /api/meta | 55 | 0 | 2.38 | 3 | 3.37 | 1.90 |
|
||||
| GET /api/orders | 105 | 0 | 2.51 | 3 | 4.44 | 3.62 |
|
||||
| GET /api/orders/{id} [404] | 15 | 0 | 2.61 | 4 | 3.98 | 0.52 |
|
||||
| GET /api/stats/orders | 44 | 0 | 2.51 | 3 | 4.19 | 1.52 |
|
||||
| GET /health | 10 | 0 | 1.77 | 2 | 2.04 | 0.34 |
|
||||
|
||||
## 5. 结论
|
||||
|
||||
结论:在本地单机、10 并发、30 秒 headless Locust 基准下,T6.1 管理后台骨架表现稳定,0 失败,所有 GET 路由 P95 ≤ 4ms,登录接口 P95 为 38ms,满足“先建立可压测基线”的 T11.1 目标。
|
||||
|
||||
当前限制:
|
||||
|
||||
- 这是本地 SQLite + 单进程 uvicorn 基线,不代表生产容量上限。
|
||||
- 当前业务仍是 T6.1 骨架,`/api/orders`、`/api/stats/orders` 返回占位数据;后续真实业务逻辑接入后需重跑基准。
|
||||
- 当前测试时长为 30 秒,适合基线验证;若要做发布前容量评估,建议补 5 分钟持续压测与更高并发阶梯测试。
|
||||
|
||||
## 6. 产物
|
||||
|
||||
- `locustfile.py`
|
||||
- `reports/perf/T11.1_PERF_REPORT.md`
|
||||
- `reports/perf/t11_1_stats.csv`
|
||||
- `reports/perf/t11_1_stats_history.csv`
|
||||
- `reports/perf/t11_1_failures.csv`
|
||||
- `reports/perf/t11_1_exceptions.csv`
|
||||
1
reports/perf/t11_1_exceptions.csv
Normal file
1
reports/perf/t11_1_exceptions.csv
Normal file
@@ -0,0 +1 @@
|
||||
Count,Message,Traceback,Nodes
|
||||
|
1
reports/perf/t11_1_failures.csv
Normal file
1
reports/perf/t11_1_failures.csv
Normal file
@@ -0,0 +1 @@
|
||||
Method,Name,Error,Occurrences
|
||||
|
9
reports/perf/t11_1_stats.csv
Normal file
9
reports/perf/t11_1_stats.csv
Normal file
@@ -0,0 +1,9 @@
|
||||
Type,Name,Request Count,Failure Count,Median Response Time,Average Response Time,Min Response Time,Max Response Time,Average Content Size,Requests/s,Failures/s,50%,66%,75%,80%,90%,95%,98%,99%,99.9%,99.99%,100%
|
||||
GET,GET /api/auth/me,71,0,2,2.523277889081264,1.5841139829717577,4.48689199401997,144.0,2.4466548941768274,0.0,2,3,3,3,3,3,4,4,4,4,4
|
||||
GET,GET /api/meta,55,0,2,2.3830690172458575,1.2161129852756858,3.3656150044407696,461.0,1.8952960447848664,0.0,2,3,3,3,3,3,3,3,3,3,3
|
||||
GET,GET /api/orders,105,0,2,2.5105509222374254,1.2903409951832145,4.43644801271148,2.0,3.618292449134745,0.0,2,3,3,3,3,3,4,4,4,4,4
|
||||
GET,GET /api/orders/{id} [404],15,0,2,2.613766002468765,1.9536199979484081,3.9837899967096746,231.0,0.5168989213049635,0.0,2,3,3,3,3,4,4,4,4,4,4
|
||||
GET,GET /api/stats/orders,44,0,2,2.507629911468195,1.0961600055452436,4.19115400291048,109.0,1.516236835827893,0.0,2,3,3,3,3,3,4,4,4,4,4
|
||||
GET,GET /health,10,0,2,1.7654583003604785,1.2791189947165549,2.0439459767658263,145.0,0.3445992808699757,0.0,2,2,2,2,2,2,2,2,2,2,2
|
||||
POST,POST /api/auth/login,27,0,28,28.52843043985087,22.156253980938345,43.52652397938073,254.0,0.9304180583489343,0.0,28,28,29,29,38,38,44,44,44,44,44
|
||||
,Aggregated,327,0,2,4.621693528836183,1.0961600055452436,43.52652397938073,160.11620795107032,11.268396484448205,0.0,2,3,3,3,4,27,29,36,44,44,44
|
||||
|
27
reports/perf/t11_1_stats_history.csv
Normal file
27
reports/perf/t11_1_stats_history.csv
Normal file
@@ -0,0 +1,27 @@
|
||||
Timestamp,User Count,Type,Name,Requests/s,Failures/s,50%,66%,75%,80%,90%,95%,98%,99%,99.9%,99.99%,100%,Total Request Count,Total Failure Count,Total Median Response Time,Total Average Response Time,Total Min Response Time,Total Max Response Time,Total Average Content Size
|
||||
1781251791,0,,Aggregated,0.000000,0.000000,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,0,0,0,0.0,0,0,0
|
||||
1781251792,2,,Aggregated,0.000000,0.000000,2,2,38,38,44,44,44,44,44,44,44,6,0,2,14.866700997420898,1.2903409951832145,43.52652397938073,180.33333333333334
|
||||
1781251793,4,,Aggregated,0.000000,0.000000,3,3,36,38,38,44,44,44,44,44,44,13,0,3,13.504982072985372,1.2903409951832145,43.52652397938073,144.92307692307693
|
||||
1781251794,6,,Aggregated,4.000000,0.000000,2,3,29,31,38,38,44,44,44,44,44,24,0,2,11.799663666655155,1.2903409951832145,43.52652397938073,177.29166666666666
|
||||
1781251795,8,,Aggregated,4.500000,0.000000,3,3,23,28,36,38,44,44,44,44,44,34,0,2,10.288498705074957,1.2903409951832145,43.52652397938073,171.85294117647058
|
||||
1781251796,10,,Aggregated,5.666667,0.000000,3,3,23,26,31,38,44,44,44,44,44,48,0,3,9.592486706120932,1.2903409951832145,43.52652397938073,178.9375
|
||||
1781251797,10,,Aggregated,6.750000,0.000000,2,3,4,24,29,38,38,44,44,44,44,60,0,2,8.91246349880627,1.2903409951832145,43.52652397938073,185.55
|
||||
1781251798,10,,Aggregated,7.600000,0.000000,3,3,3,4,28,36,38,44,44,44,44,71,0,3,7.98847935118214,1.2903409951832145,43.52652397938073,186.50704225352112
|
||||
1781251799,10,,Aggregated,8.166667,0.000000,3,3,3,4,28,31,38,44,44,44,44,83,0,3,7.185863492959908,1.2903409951832145,43.52652397938073,171.78313253012047
|
||||
1781251800,10,,Aggregated,8.571429,0.000000,2,3,3,3,28,31,38,44,44,44,44,94,0,2,6.878889744179918,1.2791189947165549,43.52652397938073,178.29787234042553
|
||||
1781251801,10,,Aggregated,8.875000,0.000000,2,3,3,3,28,29,38,38,44,44,44,110,0,2,6.229009380595843,1.2791189947165549,43.52652397938073,171.1818181818182
|
||||
1781251802,10,,Aggregated,9.555556,0.000000,2,3,3,3,27,29,38,38,44,44,44,120,0,2,6.133288874116261,1.2791189947165549,43.52652397938073,179.81666666666666
|
||||
1781251803,10,,Aggregated,9.700000,0.000000,2,3,3,3,24,29,38,38,44,44,44,131,0,2,5.826537418916807,1.2791189947165549,43.52652397938073,179.35114503816794
|
||||
1781251804,10,,Aggregated,10.700000,0.000000,2,3,3,3,23,28,38,38,44,44,44,145,0,2,5.491272874923166,1.2791189947165549,43.52652397938073,168.82758620689654
|
||||
1781251805,10,,Aggregated,11.100000,0.000000,2,3,3,3,23,28,36,38,44,44,44,154,0,2,5.473512369049289,1.2791189947165549,43.52652397938073,165.54545454545453
|
||||
1781251806,10,,Aggregated,11.400000,0.000000,2,3,3,3,23,28,36,38,44,44,44,165,0,2,5.437436156595747,1.2791189947165549,43.52652397938073,168.8
|
||||
1781251807,10,,Aggregated,11.900000,0.000000,2,3,3,3,23,28,36,38,44,44,44,179,0,2,5.3285276193715445,1.2791189947165549,43.52652397938073,162.72625698324023
|
||||
1781251808,10,,Aggregated,11.800000,0.000000,2,3,3,3,23,28,36,38,44,44,44,190,0,2,5.157791936040954,1.2791189947165549,43.52652397938073,161.5157894736842
|
||||
1781251809,10,,Aggregated,11.900000,0.000000,2,3,3,3,23,28,31,38,44,44,44,201,0,2,5.251868059354792,1.2791189947165549,43.52652397938073,160.5870646766169
|
||||
1781251810,10,,Aggregated,12.000000,0.000000,2,3,3,3,23,28,31,38,44,44,44,210,0,2,5.14158705232798,1.2791189947165549,43.52652397938073,160.3761904761905
|
||||
1781251811,10,,Aggregated,11.900000,0.000000,2,3,3,3,4,28,31,38,44,44,44,223,0,2,5.090079448450014,1.2791189947165549,43.52652397938073,159.96860986547085
|
||||
1781251812,10,,Aggregated,11.500000,0.000000,2,3,3,3,4,28,31,38,44,44,44,235,0,2,4.947939795625218,1.0961600055452436,43.52652397938073,158.68085106382978
|
||||
1781251813,10,,Aggregated,11.500000,0.000000,2,3,3,3,4,28,31,38,44,44,44,247,0,2,4.933227951188764,1.0961600055452436,43.52652397938073,160.04453441295547
|
||||
1781251814,10,,Aggregated,11.200000,0.000000,2,3,3,3,4,28,29,38,44,44,44,258,0,2,4.820793891251593,1.0961600055452436,43.52652397938073,157.42635658914728
|
||||
1781251815,10,,Aggregated,11.500000,0.000000,2,3,3,3,4,28,29,38,44,44,44,273,0,2,4.69094451266126,1.0961600055452436,43.52652397938073,159.91575091575092
|
||||
1781251816,10,,Aggregated,11.800000,0.000000,2,3,3,3,4,27,29,38,44,44,44,283,0,2,4.613383886833797,1.0961600055452436,43.52652397938073,162.8939929328622
|
||||
|
Reference in New Issue
Block a user