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

  1. Baseline load với request IDs và deployment marker.
  2. Inject DB row lock hoặc Hikari pool exhaustion trong khi CPU thấp.
  3. Thu RED metrics, pool wait/active/pending, traces, thread dump và pg_stat_activity.
  4. Lập timeline request→thread wait→connection wait/DB lock.
  5. 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
  1. Định nghĩa eligible/valid events và partial degradation.
  2. Inject recommendation failure (optional) rồi payment failure (critical).
  3. Kiểm tra error-budget accounting khác nhau.
  4. Tune multi-window alert để giảm noise mà vẫn bắt sustained impact.

Lab C · Trace async workflow

  1. Propagate trace/correlation/causation IDs HTTP→Outbox→broker→consumer.
  2. Inject duplicate/redelivery và queue lag.
  3. Không dùng high-cardinality business IDs làm metric labels; giữ trong logs/traces.
  4. Dashboard Outbox age, consumer lag và time-to-terminal.

Lab D · JVM diagnostic ladder

  1. CPU issue: OS/process→thread CPU→thread dump/JFR profile.
  2. Memory issue: heap usage/GC→histogram→heap dump có data handling policy.
  3. Thread issue: repeated dumps để phân biệt transient/stuck.
  4. So before/after mitigation, không tune GC từ một snapshot.

Deliverables

Execution evidence gate

  1. Ghi runtime/version, input và hypothesis trước khi chạy; lưu command, config, request ID và raw output.
  2. Inject failure tại checkpoint xác định và assert invariant từ nguồn độc lập.
  3. Chạy matrix phù hợp: timing, concurrency, dependency, lifecycle và mixed-version compatibility.
  4. Kết luận bằng mechanism, trade-off, limitation, recovery/runbook và production decision.
Completion: phân biệt specified, executed, explainedproduction-ready evidence. Không đánh dấu executed nếu snippet hoặc code chưa thực sự được chạy.
← Labs tổng hợpPart 14 →