3 ms·
Question not related to the article: does anybody have hints or a link to some page explaining how to set up Linux so that it uses swap reaaally only if there
by zepearl 5y ago
Question not related to the article:
does anybody have hints or a link to some page explaining how to set up Linux so that it uses swap reaaally only if there is almost no free RAM available?
I have a few private servers & VMs, all having swap enabled, and all start using swap if I do a lot of I/O even if I have e.g. more than 20GBs free out of 36 being available. Usually swap is not being used just after having booted the server or VM, but after a few hours or days of doing reads & writes to disk the kernel will start writing stuff to swap - it's very little (few KBs being written every few seconds), but that accumulates and after a few days I end up having GBs of swap used.
On one hand I just personally hate seeing that happening, on the other hand some of my workloads are irregular so when the workload changes the swap is emptied (at least partially) and the whole thing starts over again.
So far I played with the values of "/proc/sys/vm/swappiness" (tried to set there 0, 1, 60, 100) and "/proc/sys/vm/vfs_cache_pressure" (tried to set there 50, 100, 200), but when doing a lot of I/O the OS always ended up using swap.
I would like to have swap available/enabled to cover potential extreme cases without having the programs crash (e.g. I might set memory limits of SW that might rarely run concurrently too high, or some database might suddenly allocate more than expected, etc...) => seeing that swap is being/was used would tell me that something is NOK in relation to the total RAM being used by my SW.. .