When you see that chain of events—CPU shoots up ➜ memory shoots up ➜ app falls over—start with the quickest signals that can tell you “why” before the process dies and evidence disappears.
🚦 Immediate triage checklist (in priority order)
-
Identify which process exploded
• top, htop, ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head
• Verify it’s actually your application and not something else on the box.
-
Capture runtime evidence while the app is still alive
• Linux: sudo perf top, strace -p <pid> -c, gdb -p <pid> (quick backtrace).
• Java: jstack <pid>, jmap -histo <pid>, jcmd <pid> VM.native_memory summary.
• Python: py-spy top or py-spy dump.
• Node: kill -USR1 <pid> → examine V8 heap snapshot.
-
Grab system-level stats for the same timeframe
• sar -u 1 60, vmstat 1 60, iostat -x, dmesg | tail -50 (check for OOM-killer).
• Cloud/VM: pull the graphs from your monitoring platform (Prometheus, Datadog, CloudWatch).
-
Check the application logs at the exact second the crash happened
• Look for uncaught exceptions, “OutOfMemoryError”, segmentation faults, aborted core dumps, etc.
-
Inspect core dump / crash report (if created)
• ulimit -c unlimited to ensure future dumps are written.
• gdb <binary> core.<pid> or language-specific analyzers.
🔍 What each symptom hints at
CPU spike first → Hot loop, runaway recursion, lock contention (spin-locks).
Memory spike second → Object/array growth inside that loop, or allocations that couldn’t be freed because the loop never yields.
Crash → GC can’t reclaim fast enough (OOM), native malloc fails, or watchdog kills the process for unresponsiveness.
🎯 Common culprits & what to verify
• Infinite or accidentally quadratic algorithm on a large input.
• Recent deploy that changed a cache size or added an eager pre-loading step.
• Unbounded queue or message backlog (CPU decompressing / parsing, memory holding the queue).
• Memory leak in a 3rd-party library → watch resident set size (RSS) vs JVM heap or V8 heap to see if it’s native or managed.
• GC thrashing (high CPU) followed by OOM (memory), then JVM exits. Enable GC logs and look for “Promotion failed” or “concurrent mode failure”.
📑 Minimal “first glance” playbook
top + application logs (fast context).
- One runtime dump (thread, heap, or core) before it dies.
- System metrics for correlation.
- Roll back or disable the last code/config change and re-test.
If you capture those three things—process ID + runtime snapshot + timestamped logs—you’ll almost always have enough breadcrumbs to reproduce or at least narrow the bug without guessing.