plan-capacity
정보
이 스킬은 과거 메트릭과 선형 예측 모델을 활용하여 자원 요구량을 예측함으로써 데이터 기반 용량 계획을 수행합니다. 제약 조건을 식별하고 여유 용량을 계산하며, 포화 상태를 방지하기 위한 확장 조치를 권장합니다. 트래픽 급증이나 제품 출시 전, 또는 분기별 검토 시 사용률이 상승하는 시점에 사용하십시오.
빠른 설치
Claude Code
추천npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/plan-capacityClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
容量規劃
依資料驅動之容量規劃,預測資源需求並防止飽和。
適用時機
- 季節性流量高峰前(節慶、促銷活動)
- 規劃新功能上線時
- 季度容量檢視期間
- 資源使用率呈上升趨勢時
- 預算規劃週期前
輸入
- 必要:歷史指標(CPU、記憶體、磁碟、網路、每秒請求數)
- 必要:趨勢分析之時間範圍(至少 4 週)
- 選擇性:業務成長預測(預期使用者成長、功能上線)
- 選擇性:預算限制
步驟
步驟一:蒐集歷史指標
向 Prometheus 查詢關鍵資源指標:
# CPU usage trend over 8 weeks
avg(rate(node_cpu_seconds_total{mode!="idle"}[5m])) by (instance)
# Memory usage trend
avg(node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) by (instance)
# Disk usage growth
avg(node_filesystem_size_bytes - node_filesystem_free_bytes) by (instance, device)
# Request rate growth
sum(rate(http_requests_total[5m])) by (service)
# Database connection pool usage
avg(db_connection_pool_used / db_connection_pool_max) by (instance)
匯出以分析:
# Export 8 weeks of CPU data
curl -G 'http://prometheus:9090/api/v1/query_range' \
--data-urlencode 'query=avg(rate(node_cpu_seconds_total{mode!="idle"}[5m])) by (instance)' \
--data-urlencode 'start=2024-12-15T00:00:00Z' \
--data-urlencode 'end=2025-02-09T00:00:00Z' \
--data-urlencode 'step=1h' | jq '.data.result' > cpu_8weeks.json
預期: 各資源之乾淨時間序列資料,無大幅缺漏。
失敗時: 資料缺漏將降低預測準確度。檢查指標保留期與抓取間隔。
步驟二:以 predict_linear 計算成長率
以 Prometheus 之 predict_linear() 預測飽和:
# Predict when CPU will hit 80% (4 weeks ahead)
predict_linear(
avg(rate(node_cpu_seconds_total{mode!="idle"}[5m]))[8w:],
4*7*24*3600 # 4 weeks in seconds
) > 0.80
# Predict disk full date (8 weeks ahead)
predict_linear(
avg(node_filesystem_size_bytes - node_filesystem_free_bytes)[8w:],
8*7*24*3600
) > 0.95 * avg(node_filesystem_size_bytes)
# Predict memory pressure (2 weeks ahead)
predict_linear(
avg(node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes)[8w:],
2*7*24*3600
) / avg(node_memory_MemTotal_bytes) > 0.90
# Predict request rate capacity breach (4 weeks ahead)
predict_linear(
sum(rate(http_requests_total[5m]))[8w:],
4*7*24*3600
) > 10000 # known capacity limit
建立預測儀表板:
{
"dashboard": {
"title": "Capacity Forecast",
"panels": [
{
"title": "CPU Saturation Forecast (4 weeks)",
"targets": [
{
"expr": "predict_linear(avg(rate(node_cpu_seconds_total{mode!=\"idle\"}[5m]))[8w:], 4*7*24*3600)",
"legendFormat": "Predicted CPU"
},
{
"expr": "0.80",
"legendFormat": "Target Threshold (80%)"
}
]
},
{
"title": "Disk Full Date",
"targets": [
{
"expr": "(avg(node_filesystem_size_bytes) - predict_linear(avg(node_filesystem_free_bytes)[8w:], 8*7*24*3600)) / avg(node_filesystem_size_bytes)",
"legendFormat": "Predicted Usage %"
}
]
}
]
}
}
預期: 清晰之視覺化,顯示資源何時將觸及門檻。
失敗時: 若預測結果有異(負值、劇烈波動),檢查:
- 歷史不足(至少需 4 週)
- 階梯式尖峰(部署、遷移)扭曲趨勢
- 線性模型未捕捉之季節性
步驟三:計算當前餘裕
定飽和前之安全邊際:
# CPU headroom (percentage remaining before 80% threshold)
(0.80 - avg(rate(node_cpu_seconds_total{mode!="idle"}[5m]))) / 0.80 * 100
# Memory headroom (bytes remaining before 90% usage)
avg(node_memory_MemAvailable_bytes) - (avg(node_memory_MemTotal_bytes) * 0.10)
# Request rate headroom (requests/sec before saturation)
10000 - sum(rate(http_requests_total[5m]))
# Time until saturation (weeks until CPU hits 80%)
(0.80 - avg(rate(node_cpu_seconds_total{mode!="idle"}[5m]))) /
deriv(avg(rate(node_cpu_seconds_total{mode!="idle"}[5m]))[8w:]) /
(7*24*3600)
製作餘裕摘要報告:
cat > capacity_headroom.md <<'EOF'
# Capacity Headroom Report (2025-02-09)
## Current Utilization
- **CPU**: 45% average (target: <80%)
- **Memory**: 62% (target: <90%)
- **Disk**: 71% (target: <95%)
- **Request Rate**: 4,200 req/s (capacity: 10,000)
## Headroom Analysis
- **CPU**: 35% headroom → ~12 weeks until saturation
- **Memory**: 28% headroom → ~16 weeks until saturation
- **Disk**: 24% headroom → ~8 weeks until full
- **Request Rate**: 5,800 req/s headroom → ~20 weeks until capacity
## Priority Actions
1. **Disk**: Implement log rotation or expand volume within 4 weeks
2. **CPU**: Plan horizontal scaling in next quarter
3. **Memory**: Monitor but no immediate action needed
EOF
預期: 各資源之量化餘裕,附飽和時間估計。
失敗時: 若餘裕已為負,已陷被動模式。需立即擴容。
步驟四:建模成長情境
納入業務預測:
# Example Python script for scenario modeling
import pandas as pd
import numpy as np
# Load historical data
df = pd.read_json('cpu_8weeks.json')
# Calculate weekly growth rate
growth_rate_weekly = df['value'].pct_change(periods=7).mean()
# Scenario 1: Current trend
weeks_ahead = 12
current_trend = df['value'].iloc[-1] * (1 + growth_rate_weekly) ** weeks_ahead
# Scenario 2: 2x user growth (marketing campaign)
accelerated_trend = df['value'].iloc[-1] * (1 + growth_rate_weekly * 2) ** weeks_ahead
# Scenario 3: New feature launch (+30% baseline)
feature_launch = (df['value'].iloc[-1] * 1.30) * (1 + growth_rate_weekly) ** weeks_ahead
print(f"Current Trend (12 weeks): {current_trend:.1%} CPU")
print(f"2x Growth Scenario: {accelerated_trend:.1%} CPU")
print(f"Feature Launch Scenario: {feature_launch:.1%} CPU")
print(f"Threshold: 80%")
預期: 多種情境,呈現業務變動對容量之影響。
失敗時: 若情境超出容量,於事件前優先擴容。
步驟五:產生擴容建議
擬定可執行之建議:
## Capacity Scaling Plan
### Immediate Actions (Next 4 Weeks)
1. **Disk Expansion** [Priority: HIGH]
- Current: 500GB, 71% used
- Projected full date: 2025-04-01 (8 weeks)
- Action: Expand to 1TB by 2025-03-15
- Cost: $50/month additional
- Justification: 5 weeks lead time needed
2. **Log Rotation Policy** [Priority: MEDIUM]
- Current: Logs retained 90 days
- Action: Reduce to 30 days, archive to S3
- Savings: ~150GB disk space
- Cost: $5/month S3 storage
### Near-Term Actions (Next Quarter)
3. **Horizontal Scaling - API Tier** [Priority: MEDIUM]
- Current: 4 instances, 45% CPU
- Projected: 65% CPU by 2025-05-01
- Action: Add 2 instances (to 6 total)
- Cost: $400/month
- Trigger: When CPU avg exceeds 60% for 7 days
4. **Database Connection Pool** [Priority: LOW]
- Current: 50 max connections, 40% used
- Projected: 55% by Q3
- Action: Increase to 75 in Q2
- Cost: None (configuration change)
### Long-Term Planning (Next 6 Months)
5. **Migration to Auto-Scaling** [Priority: MEDIUM]
- Current: Manual scaling
- Action: Implement Kubernetes HPA (Horizontal Pod Autoscaler)
- Timeline: Q3 2025
- Benefit: Automatic response to load spikes
預期: 已排序之清單,附成本、時程與觸發條件。
失敗時: 若建議因成本被否,重新檢視門檻或接受風險。
步驟六:設置容量告警
對低餘裕設置告警:
# capacity_alerts.yml
groups:
- name: capacity
interval: 1h
rules:
- alert: CPUCapacityLow
expr: |
(0.80 - avg(rate(node_cpu_seconds_total{mode!="idle"}[5m]))) / 0.80 < 0.20
for: 24h
labels:
severity: warning
annotations:
summary: "CPU headroom below 20%"
description: "Current CPU headroom: {{ $value | humanizePercentage }}. Scaling needed within 4 weeks."
- alert: DiskFillForecast
expr: |
predict_linear(avg(node_filesystem_free_bytes)[8w:], 4*7*24*3600) < 0.10 * avg(node_filesystem_size_bytes)
for: 1h
labels:
severity: warning
annotations:
summary: "Disk projected to fill within 4 weeks"
description: "Expand disk volume soon."
- alert: MemoryCapacityLow
expr: |
avg(node_memory_MemAvailable_bytes) < 0.15 * avg(node_memory_MemTotal_bytes)
for: 6h
labels:
severity: warning
annotations:
summary: "Memory headroom below 15%"
預期: 告警於飽和前觸發,留下主動擴容之時間。
失敗時: 若告警過頻(告警疲勞)或過遲(被動應急),調整門檻。
驗證
- 歷史指標至少涵蓋 8 週
-
predict_linear()查詢回傳合理預測(無負值) - 已對所有關鍵資源計算餘裕
- 成長情境已納入業務預測
- 擴容建議附成本與時程
- 容量告警已設置並測試
- 報告已與工程領導及財務檢視
常見陷阱
- 歷史不足:線性預測需至少 4 週資料;不足則預測不可靠。
- 忽略階梯變動:部署、遷移或功能上線造成之尖峰將扭曲趨勢,宜過濾或標註。
- 線性假設:並非所有成長皆線性;指數成長(病毒式產品)需另行建模。
- 遺忘前置時間:雲端配置雖快,採購、預算與遷移需數週。早作規劃。
- 未對齊預算:未取得預算共識之容量規劃將導致最後關頭之倉促;應及早納入財務。
相關技能
setup-prometheus-monitoring—— 蒐集容量規劃所用之指標build-grafana-dashboards—— 視覺化預測與餘裕optimize-cloud-costs—— 在容量規劃與成本最佳化間取得平衡
GitHub 저장소
연관 스킬
executing-plans
디자인executing-plans 스킬은 검토 체크포인트가 포함된 통제된 배치로 실행할 완전한 구현 계획이 있을 때 사용합니다. 이 스킬은 계획을 불러와 비판적으로 검토한 후, 소규모 배치(기본값 3개 작업)로 작업을 실행하면서 각 배치 사이에 진행 상황을 아키텍트 검토를 위해 보고합니다. 이를 통해 내재된 품질 관리 체크포인트를 갖춘 체계적인 구현이 보장됩니다.
requesting-code-review
디자인이 스킬은 코드 변경 사항을 요구 사항에 따라 분석하기 위해 코드 리뷰어 하위 에이전트를 호출합니다. 작업 완료 후, 주요 기능 구현 후, 또는 메인 브랜치에 병합하기 전에 사용해야 합니다. 이 리뷰는 현재 구현체와 원래 계획을 비교하여 문제를 조기에 발견하는 데 도움이 됩니다.
connect-mcp-server
디자인이 스킬은 개발자들이 HTTP, stdio 또는 SSE 전송 방식을 통해 MCP 서버를 Claude Code에 연결하는 포괄적인 가이드를 제공합니다. GitHub, Notion 및 사용자 정의 API와 같은 외부 서비스를 통합하기 위한 설치, 구성, 인증 및 보안을 다룹니다. MCP 통합 설정, 외부 도구 구성 또는 Claude의 모델 컨텍스트 프로토콜 작업 시 활용하세요.
web-cli-teleport
디자인이 스킬은 작업 분석을 기반으로 개발자가 Claude Code 웹 인터페이스와 CLI 인터페이스 중 선택할 수 있도록 돕고, 두 환경 간 원활한 세션 텔레포트를 가능하게 합니다. 웹, CLI 또는 모바일 환경 전환 시 세션 상태와 컨텍스트를 관리하여 워크플로를 최적화합니다. 다양한 단계에서 서로 다른 도구가 필요한 복잡한 프로젝트에 사용하세요.
