Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Oct 1996 19:16:00 -0500 (EST)
From:      "John S. Dyson" <toor@dyson.iquest.net>
To:        current@freebsd.org
Subject:   Request to add this to FAQ re: swap space
Message-ID:  <199610290016.TAA00994@dyson.iquest.net>

next in thread | raw e-mail | index | archive | help
This is some basic info that I would like to see added to the FAQ
someday...  Also, someone who knows English better than me (like
one of our non-native English speaker European friends), might want
to clean up the syntax!!! :-).  This is a more accurate (and wordy)
description of our swap space allocation reqs:

How much disk should I allocate for swap?

Each OS has different algorithms for swap memory allocation.  FreeBSD
takes maximum advantage of available RAM by fairly agressively pushing
seldom used pages out to disk.  The algorithm that is used by FreeBSD
also requires that every anonymous page in a process be backed by an
equivalent amount of swap space.  Additionally, due to the way that
the algorithm works, the swap space needs to be at least as a very
minimum, the size of physical ram.  But, ignore that statement, because
in practical terms, the minimum amount of swap space should be MUCH larger...

Some will quote a magic formula like swap space needing to be 2X RAM
or somesuch.  Well, that is sometimes low also.  In fact, imagine an
8MB machine running X windows, with a couple copies of Netscape!!! (I
know that it isn't a pretty sight, but imagine it anyway.)  That machine
will easily use up 16MB of swap space and more.  On FreeBSD, the consequences
of using up swap space are "not nice."  It doesn't usually cause a system
crash, but what the system does do is to try to protect itself by killing
off processes, largest first.

The best formula to use is to calculate the size of all of the processes
that you plan to run, and use that value (with a practical minimum of
2 times RAM.)  Figure that a heavily used X windows workstation can easily
use 100MB of swap space or more.   A moderately used X windows workstation,
even though it is idle alot of the time, can easily use 30MB of swap for
no apparent reason.  The actual reason is that at one time or another, someone
has run some large processes, or perhaps alot of pages are just sitting around
idle, and the system has pushed them out.  When the pages are brought into
memory, the space that they use is not reclaimed.  That is a performance
optimization (however minor.)

It isn't very easy to apriori determine the amount of swap space that the
system will require, but frankly a single user workstation should be
configured with at least 30MB of swap, and 50MB of swap is alot more
comfortable.  And remember, you need swap space for every anonymous page
in a process. 

For a server application, the best thing to do is to simply measure the
virtual size of each process by using ps and sum them.  That measurement
isn't entirely accurate, but shows the order of magnitude of needed
swap space.

So, to make it simple:

	swap-space = min(2*RAM, sum of the sizes of all processes);

as usual, add some space in for expansion and for process growth.

John



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610290016.TAA00994>