Back to lessons

Hosting Operations

Find the Processes Burning CPU

You need to identify which processes are using the most CPU without changing system state.

Command

ps -eo pid,ppid,stat,pcpu,pmem,comm,args --sort=-pcpu | head -n 10

What changed

Nothing changes. The command reads the process table and sorts by CPU use.

Danger

safe

When to use it

Use when load is high or the machine feels slow and you need to find CPU-heavy processes.

When not to use it

Do not use it as the only signal for long-term performance diagnosis; pair it with uptime and memory checks.

Undo or recovery

No undo needed because this command is read-only.

Expected output

A sorted process list with the highest CPU consumers near the top.

demo script

Disposable terminal steps

  1. uptime
  2. ps -eo pid,ppid,stat,pcpu,pmem,comm,args --sort=-pcpu | head -n 10

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ uptime
 12:32:44 up 18 days,  3:11,  2 users,  load average: 3.91, 2.44, 1.08
::exit-code::0
$ ps -eo pid,ppid,stat,pcpu,pmem,comm,args --sort=-pcpu | head -n 10
  PID  PPID STAT %CPU %MEM COMMAND         COMMAND
 1842     1 R    86.4  4.2  app-worker     /srv/app/worker --jobs
 1907     1 S    12.8  1.1  nginx          nginx: worker process
 2011     1 S     4.5  7.9  postgres       postgres: checkpointer
::exit-code::0

YouTube Short

Find CPU burners fast.

Before restarting services, sort the process table by CPU and identify the actual noisy process.

LinkedIn hook

A server feels slow, but you need proof before restarting anything.

Question: What is your first proof point before restarting a slow service?

experiments

A/B tests to run

Metric: save_rate

A: Before restarting anything.

B: Find the process burning CPU.