Swap usage always maxed out

Jun 19, 2024
2
0
1
I'm running a proxmox server in a production environment, and I always see that the swap space fills up after a few days from a reboot. The host has plenty of free memory and usually sits around 80% of 768GB in use, but the swap is at 100% 8GB/8GB. I'm not noticing any performance issues, but is it constantly writing to disk?

Should I be concerned?
I'm on 8.3.3

Thanks
 
Probably it isn't writing to disk but you can check with htop or iostat. What often happens is that Linux swaps out pages that aren't used very much in order to have more cache or to make room to defragment memory. Since you have a relatively small swap for the amount of RAM you have it isn't too surprising that it fills up. As long as performance is fine I wouldn't worry.
 
I have the same issue, workaround so far is to run a cron script every hour that turns swap off and back on.

Was not a problem with 5.15 kernel, started to be a problem with 6.8 kernel
 
Using swap is definitely a problem if I don't want it to and have already set swappiness to 1. The server is using 28GB of 31GB and still has free RAM, there's no good reason to be filling up 1.6GB of swap to where I have to clear it every half hour.
 
The server is using 28GB of 31GB and still has free RAM, there's no good reason to be filling up 1.6GB of swap to where I have to clear it every half hour.
If you clear it more often, then you manually created thrashing ;). The Linux kernel rather uses the 3GB for filesystem cache than having that specific 1.6GB in memory.
I would prefer that processes did not allocate more than they really need but sometimes they do or it's because of features that I don't use. I think it's a good thing that such "mostly unused" memory gets swapped out.
Proxmox appears to be designed for at most 80% host memory used by CT/VMs, since that's when KSM (by default) and ballooning (hard-coded) kicks in. Leaving 20% for cache sounds reasonable except when the system has huge amounts of memory (or then using ZFS). In you case that would be about 25GB, and I'm not surprised about half get's swapped out.
It's of course your choice to rewrite your swap space with the same memory pages again every half hour, but why not turn off swap competely (or set swappiness to 0)? Or just let it be and get the advantance of a larged filesystem cache?
 
  • Like
Reactions: Johannes S