High SWAP Usage

Raid007

New Member
Feb 15, 2024
12
1
3
Hello everyone,

I'm facing an issue with understanding SWAP usage on my system and could really use some help from the community to clarify things.
My Proxmox server consistently shows very high SWAP usage, nearly 100%, after running for several days.

As far as I understand, SWAP is supposed to store less frequently accessed data to free up RAM. Currently, my RAM is about 80% utilized. In theory, I would find this acceptable if SWAP is indeed holding rarely used data. However, I'm confused why the SWAP usage indicator is displayed in red on the summary.

I'm contemplating whether it would be better to increase the SWAP size (currently 8GB, with 256GB RAM) or to configure the system to avoid SWAP usage until RAM usage reaches around 90%. What are your experiences and recommendations on this matter?

I understand that there's no one-size-fits-all solution, but I'd greatly appreciate hearing your thoughts and experiences.

Thank you in advance for any insights you can share.

Best regards,
Raid007
 
Is performance actually affected or are you just concerned by the red color?

Since your RAM is 80% full the system likely decided that some things weren't worth keeping in RAM. The way to tell if they are little-used is by how much it affects the system performance. If things are running along fine there is no need to do anything.
 
Performance is generally okay. I am currently facing some minor issues during backups, but I suspect the problem lies with my ZFS setup or the disks rather than the SWAP usage.

Honestly, the red bar does bother me and catches my attention, even though it might not be necessary.
If I increase the SWAP size, it will likely be fully utilized again, right?

I can't be the only one who gets nervous seeing such a big, red bar :)
 
In general high swap usage is not a problem, unless you recognize degraded performance. If your system notices that some pages are just not used, it moves them to the swap storage. More available RAM = more buffer and caching.

You could also reduce the swappiness factor of your PVE host: https://pve.proxmox.com/wiki/ZFS_on_Linux#zfs_swap
On PVE hosts I usually change the to 10 for PVE hosts (down from the default 60). This makes it so that it is less likely that your systems swaps memory.

A lot of PVE systems don't even have swap, since they usually come with a lot of RAM and are less prone to fluctuating RAM usage.
 
Likely adding more swap will just let it use more.

The best way to reduce the red bar would be to get more RAM or reduce the size of your VM's. You can fiddle with settings like swappiness but IMO it is just moving the deck chairs around.

I see you use ZFS. I don't but another thing to check is your ZFS setup. Depending on when you installed your machine it could use up to half the RAM for itself. Apparently newer installers set it to a lower value but older ones did not. If you had the old setting then lowering it will free up some memory. See here for example:

https://pve.proxmox.com/wiki/ZFS_on_Linux#sysadmin_zfs_limit_memory_usage
 
Hi all,

thank you for the responses. I'm aware that ZFS currently reserves 50% cache on my system, but it's new to me that newer installations now default to 10%. I haven't dared to reduce the 50% allocation so far, although I find 128GB for 8TB HDDs excessive. The change to 10% gives me confidence to try reducing it.

I will also experiment with the swappiness value since my RAM usage is consistently at 80%, and I don't find it efficient to use SSDs instead of RAM.

Hope I will find a good balance between that parameters!
 
A good rule-of-thumb for ZFS cache is 2GiB + 1GiB/TiB storage. In your case of 8TB you could start with 10GiB and go from there.
 
Great! With so much free RAM available, I don't believe I need SWAP 60 - I'll adjust it to 10. I'll keep an eye on the performance over the next few days and hope everything runs smoothly.

Thanks!
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!