Use Cases
- Capacity assessment before major promotions / events
- Routine scaling decisions
- Cost optimization
- Resource estimation for new services
- Annual capacity budget
Core Principles
1. 数据驱动
基于历史指标预测,不靠猜
2. Buffer 预留
目标利用率 60~70%,不是 100%
-
Bottleneck First Find the resource that gets overwhelmed first
-
Cost Awareness Scaling has costs; more is not always better
-
Regular Review Review monthly / quarterly
## 容量评估公式
```text
所需实例 = 峰值 QPS / 单实例 QPS × Buffer
示例:
峰值 QPS = 10000
单实例 QPS = 500(压测得出)
Buffer = 1.5(50% 余量)
实例数 = 10000 / 500 × 1.5 = 30
按 N+2 容灾:
实际部署 = 32
Workflow
1. 收集当前指标
- CPU / Memory / QPS / 连接数
- 历史峰值
- 增长趋势
2. 预测未来负载
- 线性增长 / 季节性
- 大促倍数
3. 压测单实例容量
- k6 / JMeter
- 找拐点
4. 计算所需资源
5. 成本评估
6. 扩缩容方案
- 手动 / HPA / KEDA
7. 验证(压测)
8. 文档化
Supporting Templates
templates/capacity-plan-template.md— Capacity assessment + forecasting + cost + plan
Quality Self-Check
□ 基于数据(不靠猜)
□ 压测验证
□ Buffer 预留(50%+)
□ 成本评估
□ 扩缩容方案
□ 定期评审
□ 大促提前准备
□ 瓶颈识别
Common Pitfalls
- Estimating without load testing——the numbers are unreliable
- 100% utilization——no buffer
- Looking only at CPU——the bottleneck may be in the connection pool
- Ignoring cost——over-scaling
- Irregular reviews——resource waste
Collaboration with Other Skills
上游:
devops-engineer monitoring-alerting → 指标数据
下游:
devops-engineer kubernetes-orchestration → HPA 配置
devops-engineer infrastructure-as-code → 资源申请