Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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

share|improve this answer
    
Hi, thanks, that makes sense. What value would you suggest we should start alerting again on swap usage? –  Luke Cousins Apr 17 at 10:23
1  
Swap usage size by itself doesn't mean that much. More important is to know about the pageins/pageouts, this will actually tell you if the system is really swapping/paging. High number of pagein/pageout would mean that you are running out of memory and have to push parts of active processes to swap(disk) and then read them again to memory (from disk). This is what really impacts your system performance. You can check this out with vmstat tool. On the other hand it's also a problem when you run out of swap space, so it's good to monitor the usage to, but I wouldn't worry till 70% ;) –  b13n1u Apr 17 at 11:17
    
@LukeCousins I have Nagios alert me whenever ANY swap is used on production servers. –  Joel E Salas Apr 17 at 11:44
    
Ok, thanks for the explanation @b13n1u, I'll check out vmstat. @Joel E Salas, that's what we have too which was why I was trying to get rid of it, but it seems in this case that it is, in itself now a problem. We'll build some alerts with vmstat and set the swap alert a bit higher. Thanks though. –  Luke Cousins Apr 17 at 13:54

The memory usage you are observing is just the same between free, top and htop. Let's calculate it from the top view:

8171728-(341276+2195864+4061972) / 1024 = 1535

which practically matches what you get in htop.

Also when you convert top values from KB to MB you'll see that the free values do match as well.

The swap usage you are panicking over about is probably just some bored daemon swapped out to disk, no worries about that.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.