How much swap?
Lennart Sorensen
lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Wed Oct 25 19:38:44 UTC 2006
On Wed, Oct 25, 2006 at 03:09:57PM -0400, Robert Brockway wrote:
> Hi Ian. You took the words right out of my mouth. Ram being cheap is not
> sufficient reason not to put swap in the system for exactly the reason
> that you mention.
>
> Allowing unused apps to swap and thus allowing the system to reclaim the
> memory and use it for cache and buffering is an overall win for
> performance, even after factoring in the need to swap apps back in from
> time to time.
>
> As for the original poster's query - the old "swap must equal 2x ram"
> formula was derived from the swapping algorithms used on some versions of
> Unix in the past. This is not and has never been necessary on Linux[1].
I believe 2.4.0-2.4.10 may in fact have had such a requirement. Or at
least swap > ram had to be the case if you had any swap, since I think
its VM did in fact back all ram with swap at all times. I may have
misunderstood it at the time though. I do remember the VM in those
versions really didn't work very well and a complete replacement was put
in for later 2.4 kernels which was a major improvement.
> Basically the amount of ram+swap should be higher than you would
> reasonably expect the system to demand. On systems with lots of ram (say
> 4GB) I'll throw in a few GB of swap (disk is cheap too). Watch out for
> runaway processes that gobble lots of memory - having swap can prevent the
> OOM killer[2] coming in to play and the OOM killer is nobody's friend.
>
> On a side note I highly recommend setting per process limits. See
> limits.conf and ulimit.
>
> [1] Actually there was one kernel which had a bug which meant that if swap
> was not at least 2x ram the system would not swap at all. This was
> quickly fixed and was entirely unintentional.
>
> [2] Out Of Memory killer. ROARRR!!!!
Yes, randomly killing a process does not seem like the best move.
--
Len Sorensen
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list