Module 15 · Reproducible benchmark
Benchmark & Comparative Analysis
Thiết kế benchmark reproducible và đọc đúng latency/throughput/resource metrics.
1. Principles
- Cùng hardware/container limits.
- Cùng JVM.
- Cùng DB/dataset.
- Cùng downstream mock latency/error.
- Warm-up.
- Không chỉ nhìn requests/sec.
2. Metrics
| Nhóm | Metrics |
|---|---|
| Latency | p50, p95, p99, max |
| Capacity | throughput, error rate |
| Runtime | CPU, memory, GC, thread count |
| Reactive | event-loop delay, worker/scheduler saturation |
| Data | DB pool utilization, query latency |
3. Workloads
W1: 90% GET /orders, 10% POST W2: 50% GET, 50% POST W3: 10k SSE idle clients W4: Slow payment p95=1200ms W5: Slow DB p95=500ms W6: Blocking injection 100ms W7: CPU-heavy validation 50ms
4. Concurrency
100 → 500 → 1.000 → 5.000 clients, chỉ tăng khi level trước ổn định. Concurrency không phải throughput.
5. Blocking experiment
Inject Thread.sleep(100) vào một tỷ lệ request path và so p95/p99. Event-loop systems thường nhạy hơn với blocking handler.
6. Report template
| Scenario | WebFlux | Vert.x | Giải thích |
|---|---|---|---|
| Baseline p99 | ... | ... | ... |
| Slow payment | ... | ... | ... |
| Blocking injection | ... | ... | ... |
7. Interpretation
Không kết luận “framework X nhanh hơn” từ một workload. Kết luận phải gắn version, hardware, config và bottleneck.