Linux interview question · Most asked
A Linux server has high CPU usage. How do you find the cause?
Scenario Asked in DevOps Engineer · Site Reliability Engineer (SRE) interviews
Summary
Confirm what kind of CPU time it is, then find the process and, if needed, the code path. top or htop shows
the busiest processes and the split between user (us), system (sy), I/O wait (wa) and steal (st) time;
that split decides where to look next.
Longer Answer
uptime/top: load average and the CPU split. Highusis the application; highsyis the kernel (syscalls, context switches); highwameans waiting on disk, not really CPU; highston a VM means the hypervisor is taking CPU (noisy neighbour or burst credits exhausted).- Which process: sort by CPU in
top(P),ps -eo pid,comm,%cpu --sort=-%cpu | head, andpidstat 1for per-process trends. Check threads withtop -H -p PID. - Why:
perf top -p PIDor a flame graph for native code; language tools for runtimes (jstack/ async-profiler for the JVM,py-spyfor Python). Look for a hot loop, a regex, GC pressure, or a spike in traffic. - Context: did it start with a deploy, a cron job, a traffic change? Compare with metrics history.
- Mitigate while investigating: scale out, roll back, rate-limit, or
renicea batch job.
Example
top -o %CPU # busiest processes; press 1 for per-core view
pidstat -u 1 5 # per-process CPU every second
top -H -p 4123 # threads of one process
sudo perf top -p 4123 # hottest functions
Key Points
- Read the CPU split: us, sy, wa, st.
- Find the process, then the thread, then the code path.
- High wa is I/O, high st is the hypervisor.
- Correlate with deploys and traffic; mitigate first.
Explanation
What interviewers look for
A structured path from symptom to root cause, and knowing what each CPU field means.
More Linux questions
- What do top, htop, vmstat, iostat, ss and lsof each tell you?
- Write a script that alerts when disk usage passes a threshold.
- How do you troubleshoot DNS resolution and network connectivity on Linux?
- A server keeps running out of memory and the kernel kills processes. How do you investigate?
- The disk is full, but du shows far less usage than df. What's going on?
- How do systemd units work, and how do you debug a service that won't start?
- Explain Linux file permissions, ownership and the special bits.
- What is load average, and how is it different from CPU utilisation?