r/linuxquestions • u/Aresharmajee • 17d ago
Why can a Linux system have plenty of free RAM but still become extremely slow under heavy disk I/O?
I'm trying to understand Linux performance beyond basic CPU and memory utilization.
Imagine a system with low CPU usage and plenty of available RAM, but applications are responding slowly during heavy disk activity.
How would you distinguish between I/O wait, filesystem bottlenecks, memory pressure, and processes stuck in uninterruptible sleep?
Which metrics would you check first, and why?
12
Upvotes
14
u/ipsirc 17d ago
6
u/aieidotch 17d ago
ps -ef?
htop
strace -p
netstat
what storage? what filesystem? number of files in single directory?
can be everything…
3
u/Aresharmajee 17d ago
Just to clarify above post, I’m interested in the diagnostic approach rather than troubleshooting one particular machine.
What makes this interesting to me is that low CPU utilization and plenty of available RAM can make a system appear healthy at first glance, even when application latency is terrible.
I’d probably start by correlating iostat, vmstat, PSI (/proc/pressure/io), and process states before digging into filesystem or application-specific behavior.
Curious if anyone has encountered a case where the obvious I/O metrics looked normal but the actual bottleneck turned out to be somewhere unexpected.
7
u/_Lost-In-The-Weeds_ 17d ago
If you are talking about spinning rust the issue is likely limited IOPS of the disk. Does not actually have much to do with Linux at all but a mechanical limitation of the read/write heads. Can only be so many places in a second.
Pooled drives mitigates this some.
2
u/RandomUser3777 17d ago
If you queue up enough writes to hit the dirty_cache limit then ALL writes will get paused until enough writes are written. the ratio with values is 10% of ram and 20% of ram, when you hit 20% then writes will stop until you get down to 10%. I have when having issues switch to the _bytes setting (it uses one setting or the other) and lowered the spread between the 2 values such that the freeze is much shorter.
Ie 10% of ram on a 16gb machine is 1.6gb of writes and on a spinning disk that is 15-30 seconds, on a sata connected ssd that is still a few seconds.
sysctl -a | grep -i dirty | grep -E 'bytes|ratio' ; grep -i write /proc/meminfo
vm.dirty_background_bytes = 0
vm.dirty_background_ratio = 10
vm.dirty_bytes = 0
vm.dirty_ratio = 20
Writeback: 0 kB
WritebackTmp: 0 kB
4
u/brighton_it 17d ago
cat /proc/pressure/iocat /proc/pressure/cpucat /proc/pressure/memoryhttps://docs.kernel.org/accounting/psi.html
1
u/usecornercase 17d ago
One thing worth adding to your list: free RAM doesn't protect you from stalls caused by dirty page writeback. When a process writes faster than the disk can flush, the kernel throttles it in balance_dirty_pages, so it sleeps in D state even though nothing looks wrong in CPU or memory. You can see it with grep -E 'Dirty|Writeback' /proc/meminfo during the slowdown, and the vm.dirty_background_bytes / vm.dirty_bytes sysctls control when it kicks in. Also, for the 'is it the disk or something else' question, look at await and aqu-sz in iostat -x, and compare the 'some' and 'full' lines in /proc/pressure/io: full means every runnable task was stalled on I/O, not just one. For D-state tasks, cat /proc/<pid>/stack as root or the wchan column in ps -eo pid,stat,wchan:32,cmd tells you whether they're stuck in the block layer, a filesystem journal, or NFS.
2
u/Interesting_Debate57 17d ago
netstat -n
And then look from there. top (or ps) will tell you which processes are using the most CPU and RAM and which are spending the most time idle.
There's also iostat which will help you watch disk flurries.
There's plenty built into the system to help you see what's happening.
Probably the thing that requires the least intelligence to use is "top" and then sort by whichever column you're interested in.
This will all make more sense after reading the relevant man pages.
1
u/symcbean 17d ago
'top' is a good place to start.
High CPU usage - CPUs too slow
High user/sys load - not enough CPUs
High memory / some swap uage - fire up vmtat to check how much swapping is going on
Hi iowait - disk bottleneck
1
u/token_curmudgeon 17d ago
https://access.redhat.com/solutions/103833
1
u/tabbekavalkade 17d ago
1
u/throttlemeister 17d ago
Linux is largely optimized for server use, ie throughput prioritization. For desktop use you want latency prioritization. You can fix that somewhat with tools and settings but since there is no single set of desktop processes it is always possible to trigger said behavior even with ssd or nvme and tuning.
0
u/allunia333 17d ago
Why do you need to distinguish common sense? I/O storage is orders of magnitude slower than system RAM which in turn is orders of magnitude slower than cache...
This has always been the bottleneck in all computers and still is...