How much swap?
Robert Brockway
rbrockway-wgAaPJgzrDxH4x6Dk/4f9A at public.gmane.org
Wed Oct 25 19:09:57 UTC 2006
On Wed, 25 Oct 2006, Ian Petersen wrote:
> Chances are, there are a bunch of processes on your system that spend
> most of their time idling. If you have no swap, these idle processes
> _must_ reside in real RAM, which eats away at the amount of RAM that
> can be used for caching and buffering. On the other hand, if you
> allow the kernel to swap out mostly-idle processes, it has more room
> for these speed-enhancing uses of physical memory.
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].
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!!!!
Rob
--
Robert Brockway B.Sc. Phone: +1-905-821-2327
Senior Technical Consultant Urgent Support: +1-416-669-3073
OpenTrend Solutions Ltd Email: support-wgAaPJgzrDxH4x6Dk/4f9A at public.gmane.org
Web: www.opentrend.net
--
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