A server is slow: how do you troubleshoot it?
MediumLinuxTroubleshootingPerformance
Users say a Linux server is slow. How do you troubleshoot it?
TL;DR
Work methodically from broad to specific instead of guessing. First scope it: is it every request or some, and did anything change (a deploy, traffic, config)? Then check the four resources with the USE method (Utilization, Saturation, Errors) for CPU, memory, disk and network. Find the process responsible, then look at its logs and dependencies (database, downstream APIs). Mitigate first (roll back, scale, restart), then find the root cause.
Key points
A quick first-60-seconds pass:
| Check | Command | What you look for |
|---|---|---|
| Load and uptime | uptime | Load average vs core count |
| CPU | top, mpstat -P ALL 1 | High us (app), sy (kernel), wa (I/O wait), st (stolen by the hypervisor) |
| Memory | free -m, vmstat 1 | Low available, swapping (si/so), OOM kills in dmesg |
| Disk | iostat -xz 1, df -h | High %util or await, a full disk, no free inodes (df -i) |
| Network | ss -s, sar -n DEV 1 | Retransmits, connection counts, saturated bandwidth |
| Logs | journalctl -u app, dmesg -T | Errors, OOM killer, disk errors |
- A full disk is a classic culprit (logs). Find it with
du -sh /* | sort -h. - High I/O wait with low CPU means disk-bound; check which process with
iotop. - If the box looks healthy, the slowness is likely a dependency: slow queries, connection pool exhaustion, or a slow downstream API. Check APM traces.
Example
bash
uptime # load 24 on 4 cores → saturated
top -o %CPU # java at 390% CPU
dmesg -T | grep -i oom # nothing
# → profile the app or check recent deploys; GC thrash or a hot loopCommon follow-ups
- What would you look at in the app itself? Latency percentiles (p95/p99), error rates, thread or event-loop blocking, garbage collection pauses, and slow traces.
- How do you prevent this next time? Dashboards and alerts on saturation, capacity planning, and a runbook from the post-incident review.
What interviewers look for
Tip
A structured approach (scope → resources → process → dependencies) with real commands, and mitigation before root cause.
- Red flag: rebooting first and never finding out why.