Latency on a memcached-plus-app box spikes randomly; `vmstat 1` shows non-zero `si` and `so` every second.

IntermediateTroubleshootingDisk, memory and CPU
Answer

Likely causes → The box is swapping: the working set no longer fits in RAM, so the kernel constantly pages memory in and out to disk. Each page fault on a request path costs milliseconds.

Diagnose →

vmstat 1 5          # si/so > 0 continuously = thrashing
free -m
for f in /proc/*/status; do awk '/^Name|^VmSwap/{printf $2" "}END{print ""}' $f; done 2>/dev/null | sort -k2 -nr | head

Fix → Reduce memory use (lower cache size, fewer workers) or move to a larger instance. Restarting the swapped process brings its pages back into RAM, but it's temporary.

Prevent → Size memory with headroom, set vm.swappiness=10 (or no swap on latency-sensitive hosts, with proper memory limits), and alert on swap-in rate, not only swap used.

All Real-World Interview questions Roadmap: Interview readiness

More on Disk, memory and CPU