Performance — Đo lường hiệu suất
Load testing, benchmarking, và profiling để đảm bảo hệ thống đáp ứng performance requirements.Cú pháp
Bảng tham chiếu nhanh
| Lệnh | Mô tả | Output |
|---|---|---|
/benchmark | Load test với scenarios tự động | Throughput, latency, error rate |
/profile | Profiling chi tiết (CPU, memory, I/O) | Bottleneck identification + recommendations |
/benchmark — Load Testing
/profile — Performance Profiling
- CPU usage per function
- Memory allocation patterns
- Database query performance (N+1 detection)
- Network I/O bottlenecks
Ví dụ thực tế
- /benchmark output
- /profile output
Performance Thresholds
| Metric | Target | Alert |
|---|---|---|
| p95 Latency | < 200ms | > 500ms |
| Error Rate | < 0.1% | > 1% |
| Requests/sec | > 500 | < 100 |
| Memory | < 512MB | > 1GB |
| CPU | < 70% | > 90% |
Khi nào dùng / không dùng
| Dùng | Không dùng |
|---|---|
| Trước deploy production | Development/staging chưa stable |
| Sau thay đổi database schema | Micro-optimization sớm |
| SLA review, capacity planning | Debug specific slow endpoint (dùng /debug) |