Diagnosing and Resolving a Full-Disk Service Outage
System DesignModel answerLast updated
A production service returns 500 errors for all requests due to local disk exhaustion; walk through triage, mitigation, root cause analysis, and prevention.
Scenario
You are the on-call engineer for a high-traffic consumer application. Your monitoring dashboard fires a critical alert: the Profile Lookup Service is returning HTTP 500 for every single request. The service is deployed on a fleet of Linux VMs behind a load balancer.
When you SSH into one of the failing machines and inspect the application logs, you find this error repeated on every line:
IOError: [Errno 28] No space left on device
What Is Expected
Walk through your end-to-end approach to this incident, covering four areas:
- Immediate Triage: How do you confirm what resource is exhausted and identify the root cause across the fleet?
- Mitigation: What actions do you take to restore service quickly without destroying important data or making the outage worse?
- Root Cause Analysis: How do you determine what generated the excessive data so the problem does not recur?
- Prevention: What monitoring, architectural, or process changes do you recommend to avoid a repeat?
Considerations
- The service relies on local disk for application logs and an internal cache layer.
- Weigh the trade-offs between deleting files and expanding storage.
- Explain how to safely inspect the file system without worsening the situation on an already-struggling host.
Hints
Hint 1
100% failure across every host suggests a fleet-wide common cause, not a single bad machine. Check for a correlated deploy or config change before diving into one host.
Hint 2
errno 28 can mean either no free disk blocks or no free inodes. A huge number of tiny cache files can exhaust inodes while block usage still looks fine.
Hint 3
Deleting a file that a process still holds open does not reclaim space. Use truncation or restart the process instead.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Immediate Triage
First, confirm the scope. Every request failing across all instances points to a fleet-wide trigger, so check disk metrics across the whole cluster rather than just the one VM you logged into. Look for a recent deploy, config push, or feature-flag change that correlates with the onset, since synchronized failures usually have a synchronized cause.
Next, verify what is actually exhausted. ENOSPC has two flavors: no free blocks or no free inodes. Run both:
df -h # block usage per mount point
df -i # inode usage — millions of tiny cache files can exhaust inodes while df -h shows free space
To find the space consumers without starving the already-struggling service, use low-priority I/O and stay on one filesystem:
sudo ionice -c3 nice -n19 du -xh --max-depth=1 /var | sort -h | tail -20
sudo find /var/log /var/cache -xdev -type f -size +500M -exec ls -lh {} \;
sudo lsof +L1 # files deleted but still held open — space not yet reclaimed
Safety rules: do not cat a 50 GB log (use tail); do not write analysis output to the full disk (use /dev/shm or your local machine); work on one host first because many tools misbehave when the disk is full. If df and du disagree significantly, the gap is almost certainly deleted-but-open files, which lsof +L1 will confirm.
Mitigation
Work through these steps in rough order of speed and safety.
Stop the bleeding. If a recent deploy correlates with the growth — debug logging turned on, a retry storm logging stack traces, a cache with no eviction — roll it back or flip the flag before doing anything else. Otherwise you free space only to watch it refill.
Classify data before touching it. Regenerable items like caches, temp files, and old rotated logs are safe to delete. Recent logs needed for root cause analysis should be compressed or copied off-host first. Anything critical or unknown gets investigated, not deleted.
Free space correctly. For a log file a process is actively writing to, truncate rather than rm: : > /var/log/app/service.log or truncate -s 0 file. Running rm only removes the directory entry; the space is not reclaimed until the process closes the handle. If space is held by already-deleted open files, either truncate through /proc/<pid>/fd/ or restart the process. Clear the cache directory through the app's own purge mechanism if one exists.
Or scale storage. On cloud VMs, grow the volume online (EBS resize followed by growpart and resize2fs or xfs_growfs). Expanding preserves all data and is low-risk, but it costs money and only buys time if growth is unbounded. Often you do both: clear regenerable data now, and expand if legitimate growth is the cause.
Roll out across the fleet carefully. Canary the fix on one host, confirm it returns 200s and passes health checks, then automate across the cluster in batches. Restart the service if it is wedged after write failures.
Verify and communicate. Watch error rate, latency, and disk-usage trend. Post updates in the incident channel.
Root Cause Analysis
Build a timeline from disk-usage metrics: when did growth start, and was it a sudden step or a steady ramp? Correlate with deploys, config changes, and traffic graphs.
Identify who is writing with iotop -o, pidstat -d 1, and lsof -p <pid>. Use find -newermt or -mmin -60 to see what was written recently.
Sample the content of the large files. A repeated stack trace points to a hidden error loop. DEBUG-level lines point to a misconfiguration. Large cache objects point to missing eviction or a key-space explosion.
Check why guardrails failed: did logrotate run? Was rotation time-based (daily) when growth happened within hours? Did rotation use create while the app never reopened its file handle, so it kept writing to a deleted file? Why did no alert fire before reaching 100%?
Also examine why disk exhaustion translated into user-facing 500s. A log or cache write failing should not fail a user request — that is a design flaw worth calling out in the postmortem.
Prevention
- Monitoring: Alert at 80% (warning) and 90% (page) for both blocks and inodes. Add rate-of-change or "predicted full in N hours" alerts to catch fast ramps.
- Log hygiene: Use size-based rotation with
maxsize,rotate N, andcompress. Ship logs off-host with Fluentd or Vector and keep minimal local retention. Rate-limit and sample repeated error logs. - Bounded caches: Enforce a maximum size with LRU eviction. Put the cache on its own volume or quota.
- Isolation: Use separate mount points for
/var/log, the cache, and root so growth in one cannot starve the others. - Graceful degradation: Use async logging that drops logs on
ENOSPCinstead of failing requests. Treat the cache as optional so the service degrades rather than crashes. - Health checks: Include a disk-space check so the load balancer drains a bad host instead of serving 500s.
- Safe deploys: Use canary releases with disk-growth checks, and require review for log-level changes.
A common follow-up: what if the data is legitimate and must be kept? Deletion is off the table. Expand storage immediately and shed or queue non-critical writes while you do. The real fix is architectural — move user data off local VM disks onto durable, horizontally scalable storage (a distributed database, blob store, or sharded tier) with capacity planning, quotas, and autoscaling. Local disk should only hold ephemeral data.