💾 Monitoring Disk I/O and Memory Usage
Think of your system like a restaurant kitchen: CPU = chefs doing the work, Memory (RAM) = prep space on the counters, Disk I/O = delivery of ingredients in and out of the kitchen. Monitoring disk and memory usage helps you figure out if the chefs are waiting for ingredients, the counters are overloaded, or if deliveries are slow.
Disk I/O Monitoring
Disk I/O is all about how fast your system can read/write data to storage.
Tools:
1. iostat
Shows CPU usage + I/O stats per device.
Updates every 2 seconds, 5 times. Columns to watch:
- tps → transactions per second
- kB_read/s → kilobytes read per second
- kB_wrtn/s → kilobytes written per second
2. iotop
Interactive tool showing which process is using the disk heavily.
Shows live disk read/write by processes. Use q to quit.
Memory Usage Monitoring
RAM is your system's workspace. If it's full, tasks slow down, and swap may be used (like borrowing extra prep space from another kitchen).
Tools:
1. free -h (already covered in Topic 1)
Quick snapshot of total, used, free memory.
2. vmstat
Shows memory + swap + CPU + I/O over time. Good for spotting recurring spikes.
3. top / htop
Watch processes eating up memory. Sort by memory %MEM to find offenders.
Putting it Together
Disk bottleneck: If chefs (CPU) are idle but iostat / iotop shows high I/O wait, your storage is the problem.
Memory bottleneck: If free shows almost zero free memory and swap usage is high, your workspace is too small.
Solution: Close heavy processes, add RAM, or optimize storage access.
Practical Tip
Combine tools for full picture:
# live CPU & memory
# live disk usage
# trends over time
Real-life analogy
For disk I/O: Like checking which chef is constantly asking for ingredients and slowing the kitchen. This is like standing on a balcony and seeing the entire kitchen workflow.