Disk Space Health Check Component Design
Design a disk space health check component that monitors filesystem usage, inode counts, and write capability for applications that rely on local storage.
Component Checks
Detailed Explanation
Disk Space Health Check
Disk space checks prevent silent failures when your application writes logs, temporary files, uploads, or database files to local storage.
Response Component
{
"disk-space": {
"status": "UP",
"duration": "2ms",
"message": "Disk usage within limits",
"details": {
"path": "/data",
"totalGB": 100,
"usedGB": 45,
"freeGB": 55,
"utilization": "45%"
}
}
}
What to Check
- Disk usage percentage: Primary indicator
- Free space in absolute terms: Percentage alone can be misleading on large disks
- Inode usage: Running out of inodes prevents file creation even with free space
- Write capability: Can you actually write to the filesystem?
Health Thresholds
| Metric | Healthy | Degraded | Unhealthy |
|---|---|---|---|
| Disk usage | < 75% | 75-90% | > 90% |
| Inode usage | < 80% | 80-95% | > 95% |
| Write test | Success | N/A | Failure |
| Free space | > 5GB | 1-5GB | < 1GB |
Common Disk Space Issues
| Issue | Cause | Solution |
|---|---|---|
| Log file growth | Unrotated logs | Log rotation, external logging |
| Temp file accumulation | Unclean uploads | Periodic cleanup job |
| Database growth | Normal operations | Volume expansion, archival |
| Container overlay | Image layers | Clean up unused images |
Kubernetes Ephemeral Storage
In Kubernetes, check ephemeral storage usage to prevent pod evictions:
resources:
limits:
ephemeral-storage: "2Gi"
requests:
ephemeral-storage: "1Gi"
Exceeding ephemeral storage limits causes Kubernetes to evict the pod, which may not be caught by standard disk health checks.
Use Case
Applications that write to local filesystems for logging, file uploads, temporary processing, or embedded databases (SQLite), especially in containerized environments with limited ephemeral storage.