1

I have a KVM host running several virtual machines. The hardware is comprised of 24 cores w/ 40G of ram. This is the output of the free command:

                     total      used       free     shared  buffers  cached 
Mem:                 41180500   32340344   8840156       0  2126008  36480
-/+ buffers/cache:   30177856   11002644 
Swap:                3903484    3511516    391968

Why is the system swapping if it still has a lot of free RAM? Occupation has never been above 80% (nagios never reported more than that amount). And given that 20% of the RAM is 8G, it's still much more than the available swap (which is 4G).

3 Answers 3

2

Take a look at this article. It explains the problem, provides solution and some quick benchmarks. In short some settings that should improved the situation are:

vm.swappiness=20
vm.vfs_cache_pressure=50

Explanation of what they are and what they do can be found in the article.

3
  • What problem? No problem was mentioned. Aug 28, 2017 at 13:12
  • @DavidSchwartz the "problem" is that the system is swapping when there is still free physical RAM available. While you can probably never reduce it to zero in a real-world setup, a few simple efforts to minimize the swapping will undoubtedly improve performance to some degree.
    – Doktor J
    Aug 28, 2017 at 20:52
  • @DoktorJ There's nothing in the question that suggests that the swapping is having a negative impact on performance. It's entirely possible (in fact, likely from the data in the question) that it's having a positive impact by allowing the disk cache to be larger. Aug 28, 2017 at 22:08
3

You could try changing your "swappiness" value.

Here is a howto link: https://askubuntu.com/questions/103915/how-do-i-configure-swappiness/103916#103916

0

On modern systems, swap will usually remain unused. Processes which are long-running are shifted to swap by the kernel. Some programs start working slowly because of that. You said you have ram free, so you could disable swap by running the command: swapoff -av (prefixed by sudo if you're not root)

If you don't like the swap off, you may enable it, using reverse command: swapon -av (again with sudo if necessary).

1
  • Changing swappiness as described in other answers is a much better approach, since it can handle out-of-memory problems when you DO manage to use more memory
    – nealmcb
    Dec 28, 2013 at 1:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .