[PVE 9] Question re: Swap Setup on Small RAM VM -- Any Downsides to Setting Swappiness to 1 to avoid small MiB swap I/O?

Sep 1, 2022
577
217
68
42
Hello,

I'm running Unifi OS Server in a VM and trying to keep the RAM footprint small since this is a 16 GIB PVE node. Unifi OS Server seems to be configured to reserve as much free RAM as it can get away with as buffer/cache, so with 2 GiB of RAM given to the VM, I end up with this sort of RAM usage:
1789876991896.png

This seems to be plenty--Unifi OS is a very fancy web server running inside Podman inside a VM--but I don't love the 100-500 MiB I see in swap.

If this were a bare metal system, I don't think I'd care. I've (finally) learned that by default, swap is used by the system even when it's not out of RAM.

But my VMs are stored on a ZFS mirror using (very nice) prosumer NVMEs, so I'd rather avoid unnecessary virtual disk I/O when I can.

Since it's not actually running out of RAM, I'm considering setting swappiness == 1 (that is, only swap to avoid running out of RAM). A couple of questions.
  1. Is there a good reason not to do this on a low RAM VM?
  2. If I do set swappiness to 1, what would b some symptoms that I've made the VM unhappy?
 
I exclusively use ZRAM in my VMs so I don't need to manage a SWAP partition/file and backups don't contain the SWAP content.
On my node(s) I use ZSWAP if possible. Since you already have a SWAP device (can't tell what kind without swapon) you could use that too.
Have you checked if SWAP is written to as much as you think? https://gist.github.com/Impact123/3dbd7e0ddaf47c5539708a9cbcaab9e3#monitor-swap-usage
Your system paged out some idle app data and as effect of that it now has more memory it can use for caching. You usually want that behavior.
I don't think a swappiness of 1 will hurt your VM but it might alter performance or how the system reacts to memory spikes/peaks.
 
Last edited: