3 ms·
The problem isn't really with swap, it's that people try to use a very blunt instrument (disabling swap) to deal with with an ill-defined problem (thrashing and
by dale_glass 2y ago
The problem isn't really with swap, it's that people try to use a very blunt instrument (disabling swap) to deal with with an ill-defined problem (thrashing and the system slowing down to a crawl).
There's really no way to tune a system's swap size for ideal responsiveness. You can have a 32GB RAM + 32GB swap system perform great, and a 32 GB + 8 GB system perform miserably.
The problem is the working set, which is an often hard to predict quantity dependent on runtime factors. You can swap out 30GB of unused junk to disk and have excellent performance, but if you're constantly going through 33 GB of data on a 32 GB system, performance is going to be awful.
So really want you want to avoid this last case from hanging the system is to measure the system's responsiveness and act in response to that, instead of going for trying to get rid of the swap file. You can do that with something like systemd-oomd, which starts killing stuff when things are starting to get slow rather than when some arbitrary usage number is reached.