Skip to main content
02

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:

CheckCommandWhat you look for
Load and uptimeuptimeLoad average vs core count
CPUtop, mpstat -P ALL 1High us (app), sy (kernel), wa (I/O wait), st (stolen by the hypervisor)
Memoryfree -m, vmstat 1Low available, swapping (si/so), OOM kills in dmesg
Diskiostat -xz 1, df -hHigh %util or await, a full disk, no free inodes (df -i)
Networkss -s, sar -n DEV 1Retransmits, connection counts, saturated bandwidth
Logsjournalctl -u app, dmesg -TErrors, 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 loop

Common 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.

Was this helpful?

Related questions