Ubuntu – top and htop disagree on memory usage, but swap is being used on GlusterFS server. Can this be improved

glusterfshtopmemorytopUbuntu

If I run free -m, top and htop, I get different memory uses. The system is also using a small amount of swap. I understand from this question why they are reporting different values (some of the data is considered "discardable" and so included by one system and not included by the other), but not why the system has decided to use the swap? It is a GlusterFS server running the latest version (3.4.3).

Does anyone know why it is using the swap and not clearing out the "discardable" data from the physical memory and using that instead?

Is there something I can/should do, or should I just change the monitoring system to not worry about a small amount of swap usage?

free -m:

free

top:

top

htop:

htop

Thanks for your help.

Best Answer

I wouldn't worry at all about the small swap usage. It happens that kernel drops some data from memory to swap. You can control the behavior of kernel with the swappiness option:

echo 60 > /proc/sys/vm/swappiness

This control is used to define how aggressive the kernel will swap memory pages. Higher values will increase agressiveness, lower values decrease the amount of swap. A value of 0 instructs the kernel not to initiate swap until the amount of free and file-backed pages is less than the high water mark in a zone. The default value is 60.

You will find more information about the virtual memory subsystem in the kernel documentation