Video in progress
You are writing a runbook for the on-call team for JVM-related incidents. What do you put in it?
Short steps ordered by symptom: first collect evidence (thread dump, GC log, JFR, NMT), then restore service (take the pod out of traffic, restart), then deep analysis. The commands must be ready to copy.
📖 Answer
At 3 a.m. a person doesn't read documents, they copy commands. So the runbook starts from the symptom, not from theory.
The structure:
- Always, before the restart: collect evidence (2 minutes). A restart wipes out all the traces.
POD=...; kubectl exec $POD -- jcmd 1 Thread.print -l > threads.txt
kubectl exec $POD -- jcmd 1 JFR.dump name=bg filename=/dumps/incident.jfr
kubectl exec $POD -- jcmd 1 GC.heap_info > heap.txt
kubectl cp $POD:/logs/gc.log ./gc.log
- Branches by symptom:
- CPU 100%, no response: are there consecutive Full GCs in the GC log? If so, go to the memory branch. If not, look at the stacks of the RUNNABLE threads in the thread dump, an infinite loop.
- Latency up, CPU normal: thread dump: BLOCKED/WAITING, waiting for a pool, the DB.
- OOMKilled / 137: NMT, container metrics, direct memory.
- Java OOM: where is the dump, and what kind is it (heap, metaspace, native thread).
- Restart loop: the last log and the hs_err file.
-
Recovery. Take the pod out of traffic (change the label), take a dump, and then delete it. Restarting the whole deployment is the last resort. If it started after a deploy, roll back immediately.
-
Escalation. When and to whom: for example, if it isn't restored in 15 minutes or there is a suspicion of data corruption.
For the runbook to work, you need preparation in advance: jcmd has to be in the image (it may be missing in JRE images, so you need a JDK or jattach), a volume for dumps, a permanent JFR recording and a GC log. Test the runbook with game days: can a new employee carry it out on their own?
Sign up to mark studied questions and save your progress.