Performance Monitoring
Performance Monitoring
7 interactive questions
What tools do you use for CPU/memory/disk performance?
CPU: top/htop (interactive), pidstat 1 (per-process), mpstat -P ALL 1 (per-core), perf top (sampling profiler). Memory: free -h, vmstat 1, smem (proportional set size). Disk: iostat -xz 1, iotop, sar -d 1. Network: sar -n DEV 1, iftop, nethogs.
What is load average and what do the 3 numbers mean?
1-min, 5-min, 15-min exponentially weighted average of runnable + uninterruptible (D state) processes. Not just CPU — includes disk wait. If >> CPU cores, system is saturated.
What is the difference between `top` and `htop`?
top — built-in, minimal deps, available everywhere. htop — interactive, scrollable, tree view, colors, mouse support, better UX. Install htop if available; top is always there.
How do you find which process is eating CPU?
pidstat 1 or top (press P to sort by CPU). For deep dive: perf top -p <PID> or perf record -g -p <PID> then perf report.
What is `iowait` and how do you troubleshoot it?
CPU % waiting for block I/O (D state). High wa% in top/vmstat. Check iostat -xz 1 — high await/svctm on a device. Find culprit: iotop -o, pidstat -d 1.
How do you profile an application with `perf`?
perf record -g -- <cmd> records call stacks. perf report shows flame graph. perf stat -- <cmd> gives summary (cycles, cache misses, branches). Use perf flamegraph for visualization.
What is `bpftrace` and when to use it?
eBPF-based dynamic tracing — safe, no kernel modules, programmable. One-liners: bpftrace -e 'tracepoint:syscalls:sys_enter_openat { printf("%s %s\n", comm, str(args->filename)); }'. Great for production debugging without restart.