SWAP Usage

TecScott

Active Member
Mar 30, 2017
28
0
41
33
Any insight as to why SWAP is being used when there's as low as 16% RAM usage on the node?

I have one host for example which is sat at 16% RAM usage and using 25MB SWAP, another at 62% RAM usage using 2.8GB SWAP, another at 64% RAM usage using 3.6GB SWAP, another at 55% RAM usage using 1GB SWAP, etc.

vm.swappiness is set to 10
 
Are those all hosts which are up for a long time?

SWAP only gets reclaimed (i.e., moved back to memory) if required, as else it has no use. So if those are a bit longer running hosts, with memory usage peaks in the past, the swapped out memory just stayed there if it's stale.

A simple test could be to now do a: swapoff -a on a node, then wait until all the swapped out memory then re-enable it with swapon -a and check if it grows and how fast.


You can also find the top processes using most SWAP with the following "one-liner":
Code:
for file in $(find /proc/*/status -exec grep -q 'VmSwap' {} \; -print); do awk '/^(VmSwap|Pid|Name)/{printf $2 " " $3 }END{ print ""}' $file; done | sort -k 3 -n -r | head
 
All hosts have an uptime of around 10 days (in the process of upgrading from 5.3 to 6.1).

I suspect the swap would grow again given it's grown this much in only 10 days.

The top process for all servers is 4 KVM processes followed by 4 pvedaemon processes.
 

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!