What can make Linux unresponsive for minutes when browsing certain websites?
What can make Linux so unresponsive?
Overcommitting available RAM, which causes a large amount of swapping, can definitely do this. Remember that random access I/O on your mechanical HDD requires moving a read/write head, which can only do around 100 seeks per second.
It's usual for Linux to go totally out to lunch, if you overcommit RAM "too much". I also have a spinny disk and 8GB RAM. I have had problems with a couple of pieces of software with memory leaks. I.e. their memory usage keeps growing over time and never shrinks, so the only way to control it would have been to stop the software and then restart it. Based on the experiences I had during this, I am not very surprised to hear delays over ten minutes, if you are generating 3GB+ of swap.
You won't necessarily see this in all cases where you have more than 3GB of swap. Theory says the key concept is thrashing. On the other hand, if you are trying to switch between two different working sets, and it requires swapping 3GB in and out, at 100MB/s it will take at least 60 seconds even if the I/O pattern can be perfectly optimized. In practice, the I/O pattern will be far from optimal.
After the difficulty I had with this, I reformatted my swap space to 2GB (several times smaller than before), so the system would not be able to swap as deeply. You can do this even without messing around resizing the partition, because mkswap
takes an optional size parameter.
The rough balance is between running out of memory and having processes get killed, and having the system hang for so long that you give up and reboot anyway. I don't know if a 4GB swap partition is too large; it might depend what you're doing. The important thing is to watch out for when the disk starts churning, check your memory usage, and respond accordingly.
Checking memory usage of multi-process applications is difficult. To see memory usage per-process without double-counting shared memory, you can use sudo atop -R
, press M and m, and look in the PSIZE column. You can also use smem
. smem -t -P firefox
will show PSS of all your firefox processes, followed by a line with total PSS. This is the correct approach to measure total memory usage of Firefox or Chrome based browsers. (Though there are also browser-specific features for showing memory usage, which will show individual tabs).
AFAIK, bloatware shouldn't make the OS unresponsive, so I wouldn't consider or even accept that the bloatware is the root cause of the problem
You're not going to like this, but I think bloatware is your problem (although I'm not sure if it's memory or disk which is the problem). Unfortunately, the Linux kernel is awful at handling high memory pressure situations, and is known to basically require a reboot once memory is exhausted. There are three things which lead me to believe your issue is resource exhaustion:
- Your disk space on root (/) and DATA is almost full. I'm not sure what you use DATA for, but I've ran into issues before with resizing my root partition too small and my system becoming inoperable.
- You have high-memory pressure, meaning that your RAM is almost full. When RAM starts to get full you will start to get page faults. Page faults happen when the kernel is unable to allocate enough memory for a process and must instead use some of the systems much slower swap space. This leads us to our last observation:
- Your swap space is almost full. There's clearly some high memory pressure on your system since both RAM and swap are almost full.
Basically, put these three together and your system doesn't have enough resources available to do much of anything. As for it's unfortunate how poorly Linux handles low-memory situations (compared to, say, the NT kernel in Windows) but that seems to be how it is. You can find more discussion in this Reddit thread and its linked mailing list.
As for how to fix your situation, I would say increasing your swap size is a good idea, but since you're low on disk space that will be a problem. Unless your Minecraft server has a ton of people, I think it would be safe to reduce its memory to something around 1024m (I personally use 1024m with about 10 people and it works fine). I would also use spigot or paper for your Minecraft server since they tend to be more performant.
Good luck!
What's the output of free -m
? The amount of RAM you have is pointless if we don't know how much you're using. That and I'm interested to know how much swap space is being used.
I do think you've answered your own question, though. Having open "many tabs" open in your browser can definitely slow down your system if you're never closing them, as they'll continue to consume memory regardless; when your system freezes, how many do you have open at a time?
It also makes sense if your system is freezing up from other memory-intensive tasks such as "generating a very large graph from a very complex UML diagram". That will absolutely slow down your system as it generates the graph, so that's hardly a surprise.
It really sounds like this is the way your system is supposed to behave. Either that or I'm missing something here.
By the way, HDD stats don't matter when it comes to your system becoming unresponsive since a lack of memory is almost always the culprit.