rwadurian/backend/services/identity-service/test/performance-test.md

57 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 性能测试计划
## 工具推荐
- **Artillery** - HTTP 负载测试
- **K6** - 现代化负载测试工具
- **Apache JMeter** - 传统但功能强大
## 测试场景
### 1. 账户创建性能
```bash
# 使用 k6 测试
k6 run --vus 100 --duration 30s account-creation-test.js
```
- 目标100 并发用户,持续 30 秒
- 指标:
- 平均响应时间 < 500ms
- P95 响应时间 < 1000ms
- 错误率 < 0.1%
- TPS (每秒事务数) > 200
### 2. 登录/刷新 Token 性能
- 目标200 并发用户
- 指标:
- 平均响应时间 < 200ms
- P95 < 500ms
### 3. 助记词恢复性能
- 目标50 并发用户计算密集型操作
- 指标
- 平均响应时间 < 2000ms
- 不应该阻塞其他请求
### 4. 数据库连接池测试
- 测试连接池耗尽场景
- 测试连接泄漏检测
### 5. 内存泄漏测试
- 长时间运行测试24小时
- 监控内存使用趋势
## 压力测试
```bash
# 逐步增加负载直到系统崩溃
k6 run --stages \
"5m:100" \ # 5分钟内增加到100用户
"10m:500" \ # 10分钟内增加到500用户
"5m:1000" \ # 5分钟内增加到1000用户
"10m:0" \ # 10分钟内降回0
stress-test.js
```
找到系统的极限
- 最大并发用户数
- 最大 TPS
- 崩溃点