Part 14 · Observability & Production Debugging
Part 14 thực hành / Deep dive
Observability và production debugging: execution labs
Bắt đầu từ user impact, tìm queue/wait đầu tiên và dùng metrics–logs–traces–profiles để chứng minh root cause.
Lab A · CPU thấp nhưng p99 cao
- Baseline load với request IDs và deployment marker.
- Inject DB row lock hoặc Hikari pool exhaustion trong khi CPU thấp.
- Thu RED metrics, pool wait/active/pending, traces, thread dump và
pg_stat_activity. - Lập timeline request→thread wait→connection wait/DB lock.
- Sửa lock path/pool/concurrency; chạy lại cùng workload.
Gate: không kết luận từ một dashboard; evidence chỉ ra queue đầu tiên tích tụ.
Lab B · SLO và burn-rate alert
SLI = valid checkout requests completed correctly within 2s
SLO = 99.9% over 30 days
alerts = fast burn + slow burn windows- Định nghĩa eligible/valid events và partial degradation.
- Inject recommendation failure (optional) rồi payment failure (critical).
- Kiểm tra error-budget accounting khác nhau.
- Tune multi-window alert để giảm noise mà vẫn bắt sustained impact.
Lab C · Trace async workflow
- Propagate trace/correlation/causation IDs HTTP→Outbox→broker→consumer.
- Inject duplicate/redelivery và queue lag.
- Không dùng high-cardinality business IDs làm metric labels; giữ trong logs/traces.
- Dashboard Outbox age, consumer lag và time-to-terminal.
Lab D · JVM diagnostic ladder
- CPU issue: OS/process→thread CPU→thread dump/JFR profile.
- Memory issue: heap usage/GC→histogram→heap dump có data handling policy.
- Thread issue: repeated dumps để phân biệt transient/stuck.
- So before/after mitigation, không tune GC từ một snapshot.
Deliverables
- Incident timeline và impact statement.
- Dashboard/queries/runbook links.
- Trace/log correlation với redaction.
- SLO definition và alert firing evidence.
- Before/after latency/saturation proof.
Execution evidence gate
- Ghi runtime/version, input và hypothesis trước khi chạy; lưu command, config, request ID và raw output.
- Inject failure tại checkpoint xác định và assert invariant từ nguồn độc lập.
- Chạy matrix phù hợp: timing, concurrency, dependency, lifecycle và mixed-version compatibility.
- Kết luận bằng mechanism, trade-off, limitation, recovery/runbook và production decision.
Completion: phân biệt specified, executed, explained và production-ready evidence. Không đánh dấu executed nếu snippet hoặc code chưa thực sự được chạy.