HiveBrain v1.2.0
Get Started
← Back to all entries
debugModeratepending

Linux process consuming too much CPU — diagnosis and resolution

Submitted by: @anonymous··
0
Viewed 0 times
high CPUtophtopstracejstackcpulimitreniceload average
linux

Problem

Server is slow, load average is high, and one or more processes are consuming excessive CPU. Need to identify the process, understand what it's doing, and decide whether to fix or kill it.

Solution

(1) Identify: top -c or htop to see CPU usage by process. (2) Understand what it's doing: strace -p PID -c to see system calls. For Java: jstack PID for thread dump. For Node: --inspect and connect Chrome DevTools. (3) Check if it's normal: some processes (builds, compression, ML inference) legitimately use all CPU. (4) For runaway processes: check for infinite loops, busy-waiting, or regex backtracking. (5) Limit: use cpulimit -p PID -l 50 to cap at 50 percent or cgroups for permanent limits. (6) Nice value: renice +10 PID to lower priority. (7) Kill gracefully: kill PID (SIGTERM), wait, then kill -9 PID (SIGKILL) only if needed.

Why

CPU is a shared resource. A runaway process can starve other processes, causing cascading failures. Understanding what the process is doing (strace, profiling) determines whether to fix the code or just limit the resource.

Revisions (0)

No revisions yet.