[lug] Swap utilization

Michael D. Hirsch mhirsch at nubridges.com
Fri Jun 11 15:27:29 MDT 2004


On Fri, 2004-06-11 at 16:52, Jeff Schroeder wrote:
> I know there's a constant whirlwind of confusion about swapping in 
> Linux, and I've read many of the articles circulating.  Now I'm paying 
> more attention to how my servers use swap, and noticed that one (which 
> is always heavily loaded) seems to be swapping in a strange way.
> 
> Checking the memory breakdown yields something like this:
> 
> # cat /proc/meminfo 
> MemTotal:       482672 kB
> MemFree:         44744 kB
> Buffers:         67340 kB
> Cached:          52836 kB
> SwapCached:      59124 kB
> Active:         199096 kB
> Inactive:        34868 kB
> 
> This is a 512MB machine; notice that almost all of the memory is being 
> used.  I've got 44MB free, which is all well and good, but there's 59MB 
> of swap being used.  The situation is fairly consistent: 50-60MB of 
> swap used at any given time, with 40-50MB of free memory sitting out 
> there.
> 
> I wonder:
> 
> 1) Why isn't some of that swapped memory getting pulled back into RAM?  
> Wouldn't it be better (where "better" is subjective) to drop the free 
> memory to, say, 10MB if I can drop swap too?

The fact that you have free memory says that there is no problem on this
box.  At some point you needed more memory, so something swapped out. 
But whatever that was has not been needed since, so it never got swapped
in again.  I betcha that your fre memory was not 44MB when the swap
first got used, so you really need it.  And as you can see, the kernel
made a very good choice in what to swap out as it hasn't been needed
since.

> 2) Would adjusting /proc/sys/vm/swappiness (which is set to the default 
> 60) be wise?  I know swap can be very handy during periods of high 
> load, so obviously I don't want to turn it off completely.
> 
> 3) Is it even worth worrying about?  The server's performance is good-- 
> it's responsive and able to handle everything I throw at it.  The load 
> average is down around 0.20, which indicates nothing is really taxing 
> the CPU.
> 
> Sometimes it's better to leave well enough alone, but I'm a little 
> confused about the situation and would love to squeeze out a little 
> more performance if I can. :)

I'd say that it is working very well for you.  Swap is there to save
you, and it looks like it is doing a very good job.  I'd leave it be.

Michael



More information about the LUG mailing list