CPU Runaway Process Investigation
Identify and fix runaway CPU consumers using profiling tools across Python, JVM, Go, and Node.js.
Overview
Overview
A CPU runaway process uses far more CPU than its workload should, often pinning one or more cores at 100%. It degrades co-located services and can end in OOM kills or instance failures. Unlike memory leaks, runaways are often intermittent and triggered by specific inputs, which makes them hard to reproduce in development.
The investigation has two halves. First you identify the process with top, ps or kubectl top. Then you profile it live with py-spy, async-profiler or pprof, and the profile usually points at one of four culprits: an infinite loop, lock contention, regex backtracking, or a large JSON payload in a hot path. There is also a fifth case that looks the same from outside but is not a code problem at all: a container throttled by its CPU limit.
Key concepts
- CPU Flame Graph
- CFS Throttling
- Catastrophic Backtracking
- py-spy
- async-profiler
Interview questions
- How do you profile a running Java application for CPU hotspots without restarting it?
- What is CFS throttling in Kubernetes and how do you diagnose whether it is affecting your service?
- How do you identify and fix catastrophic regex backtracking?
Sign up free to read the full topic
More Troubleshooting topics
Start free on Cariara · Coding problems · System design studio