Part 14 · Observability & Production Debugging
14.1 / Profiling

CPU, allocation, lock và wall-time profiles

Profile trả lời code path tiêu tài nguyên; phải đặt cùng traffic/version/GC/dependency timeline để tránh tối ưu nhầm.

Profile types

CPU samples on-CPU hotspots; wall/latency includes waiting; allocation shows object churn, not retained leak; heap dump/retained paths for retention; lock/contention; thread/async profiles. Flame graph width represents samples, not call order.

JFR

Java Flight Recorder records CPU, allocation, GC, locks, threads, socket/file events with production-suitable settings. Continuous ring buffer + dump on incident captures pre-history. Event thresholds/sampling affect detail/overhead.

Methodology

Compare healthy vs bad version/endpoint/instance; capture representative window; check sample count and safepoint/native frames; formulate hypothesis then reproduce/benchmark. CPU hotspot may be legitimate traffic, not bug.

Safety

Heap dumps large, can pause and contain sensitive data. Profilers need privileged access and retention controls. Avoid high-overhead instrumentation during severe incident without risk assessment.

Java Flight Recorder · JFR Runtime Guide
← TracingJVM/Tomcat →