Re: Why would my server be swapping...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Wouter van Vliet wrote:
>              total       used       free     shared    buffers     cached
> Mem:        515536     196040     319496          0      22448     120144
> -/+ buffers/cache:      53448     462088
> Swap:      1052248     151476     900772
> 
> Hope the mail brings it over nice and columny. Anyway, what it shows
> is 311 megabytes of free memory and 147MB used swap space. Isn't that
> a bit odd, and shouldn't the server only be swapping when all (or at
> least most) of the RAM is in use?

You've had a number of theories, but I don't think anyone has yet
mentioned the obvious one.

If you've had a large program (or several large programs) taking up
memory, you're likely to see the swap file being used. If they quit,
they'll probably have been using a fair bit of real memory, and this
will be returned to the "free" pool.

And you'll get a picture looking vaguely like the one you posted.

Now, if any of that stuff in swap is actually used by a running program,
it will be read back into real memory. If data is physically read from
disk, some of that memory will be used to buffer it. And, of course, if
new or existing programs need to make use of that memory, they can.

But if the stuff in swap isn't being used, it might as well stay in
swap. If the data read from the filesystem is mostly buffered anyway,
then the memory won't be needed for buffering. And if the workload is
pretty constant, you won't need the free memory for that.

So the picture stays the way it is simply because, at that point in
time, Linux has no better use for that memory.

I think you said that the server had a peak of usage a while back. That
might well get the server into that state. (Doesn't Apache spawn more
httpd processes when it needs to?)

Incidentally, it often makes sense to swap out memory pages used by
programs if the program, in fact, isn't currently accessing those pages.
If the disk is being hammered and more buffers would help, then the
memory can be better used as buffers.

You may want to read up on /proc/sys/vm/swappiness.

Hope this helps,

James.

-- 
E-mail address: james | DON'T be put off by "horror stories" spread by
@westexe.demon.co.uk  | others.  People who talk about death and serious
                      | injury are very rarely the ones who have actually
                      | suffered such things.  -- Adrian Plass


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux