Linux Performance Tools
Also Known As
strace
perf
iostat
htop
vmstat
ltrace
TL;DR
Essential tools for diagnosing CPU, memory, IO, and network performance on Linux — top, htop, vmstat, iostat, perf, strace, and ltrace.
Explanation
CPU: top / htop (real-time process stats), mpstat (per-CPU stats), perf top (CPU profiling by function). Memory: free -h (overview), vmstat -s (detailed), smem (per-process). Disk IO: iostat -x (saturation and utilisation), iotop (per-process IO). Network: nethogs (per-process bandwidth), iftop (per-connection traffic), ss -s (socket summary). Tracing: strace -p PID (system calls made by a process — what is it doing?), ltrace (library calls). For PHP: strace on a stuck PHP-FPM worker shows exactly which system call it's blocked on.
Common Misconception
✗ top is the only tool needed for performance analysis — top shows CPU and memory snapshot but misses: disk IO saturation, network bottlenecks, and which specific system calls are blocking — iostat, nethogs, and strace fill these gaps.
Why It Matters
A slow PHP response that looks fine in CPU and memory metrics may be blocked on a slow NFS mount or disk IO — strace shows exactly which read() or write() call is taking seconds.
Common Mistakes
- Only looking at CPU usage — IO wait shows as CPU idle but means processes are blocked on disk.
- Not knowing strace -p for live process inspection — invaluable for hung process diagnosis.
- Running strace in production on a busy process — overhead can be 10-100x; use carefully.
- Confusing %iowait (CPU waiting for IO) with disk utilisation — %iowait doesn't directly show disk saturation.
Code Examples
✗ Vulnerable
# Performance analysis by guesswork:
# 'The server is slow'
# Restart PHP-FPM (sometimes works, doesn't fix root cause)
# Check top: CPU 30% — nothing obvious
# Give up, ticket to sysadmin
# Hours wasted
✓ Fixed
# Systematic performance investigation:
# 1. CPU and load:
htop # Real-time, with color
mpstat 1 5 # Per-CPU every second for 5 seconds
# 2. Memory:
free -h # Quick overview
vmstat 1 5 # Including swap activity
# 3. Disk IO:
iostat -x 1 5 # Is any disk at 100% util?
iotop # Which process is using IO?
# 4. What is a stuck PHP-FPM worker doing?
strace -p $(pgrep php-fpm | head -1) -e trace=network,file -T
# Shows: connect() to DB taking 3.5 seconds — DB is the bottleneck!
References
Tags
🤝 Adopt this term
£79/year · your link shown here
Added
16 Mar 2026
Edited
22 Mar 2026
Views
37
🤖 AI Guestbook educational data only
|
|
Last 30 days
Agents 0
No pings yet today
No pings yesterday
Amazonbot 13
Perplexity 5
Unknown AI 3
Ahrefs 3
Google 2
ChatGPT 1
Majestic 1
Also referenced
How they use it
crawler 28
Related categories
⚡
DEV INTEL
Tools & Severity
🟡 Medium
⚙ Fix effort: Medium
⚡ Quick Fix
Use htop for process monitoring, iotop for disk I/O, nethogs for per-process network, and vmstat 1 5 for overall system health — these identify whether PHP, DB, or OS is the bottleneck
📦 Applies To
any
web
cli
🔍 Detection Hints
Performance issue without identifying whether CPU IO or memory bound; no system-level metrics alongside PHP-level metrics
Auto-detectable:
✓ Yes
htop
iotop
nethogs
vmstat
perf
sar
⚠ Related Problems
🤖 AI Agent
Confidence: Low
False Positives: High
✗ Manual fix
Fix: Medium
Context: File