Interview Prep/Real-World Interview/Scaling and performance

Disk on a Linux app server keeps filling up overnight. How do you find and fix it?

BeginnerScenarioScaling and performance
Answer

Situation read → Something writes faster than it's cleaned up: logs, temp files, core dumps, or deleted files still held open.

What I'd do →

  1. Find what's big:
df -h
sudo du -xh / --max-depth=2 2>/dev/null | sort -rh | head -20
  1. If df shows full but du doesn't add up, a deleted file is still open:
sudo lsof +L1

Restart the process holding it, or truncate via /proc/<pid>/fd/<n>. 3. Check usual suspects: /var/log, the journal (journalctl --disk-usage), Docker images and volumes (docker system df). 4. Fix: logrotate with compress and maxsize, SystemMaxUse= in journald, docker system prune on a schedule, and ship logs off the box. 5. Alert at 80% disk with a predictive rule (predict_linear on node_filesystem_avail_bytes).

Why → lsof +L1 catches the case where deleting the log didn't free space.

Interview tip → The deleted-but-open file is a favourite follow-up; mention it before they ask.

All Real-World Interview questions Roadmap: Interview readiness

More on Scaling and performance