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

Re: swap space size



On 2004-10-21, Gilbert, Joseph <jgilbert@insuresuite.com> wrote:

> taken for rote.  I was told back when I first started working with Unix that
> the swap space needed to be at least twice the size of physical memory in
> order to ensure a stable system.

I believe this was just a rule of thumb when memory was so expensive.

Think about it, if you want to dramatically improve the performance
of a system then you add so much memory to it that the system stops
swapping. And if it stops swapping, then what purpose does having
"two times 'so much'" swap space have? Well, none, 'cos you've
deliberately ensured that it won't be used.

But some programs are so inactive that they'll get pushed in to swap
(by some user's 'qsort() routine or other short-lived memory eater)
and may never come back because they're waiting for something that may
never happen (e.g. 'at' daemon waiting for next 'at' job when nobody
actually uses 'at'), so adding memory to stop processes like these
being swapped (out, once) in the first place is a waste of money;
it brings no performance increase.

Of course there should always be swap space, because you *cannot*
guarantee that someone won't run perl in slurp mode, or qsort on
a massive data set, etc, and, generally, "I don't want to ever
encounter the error message 'out of memory'" is a hard requirement,
but the comparatively (very) slow access speeds of swap space should
give you some idea of how often you should actually be regularly
(by which I mean swapping in and out, not just out) using it, and
when disk space is so cheap then, hell, you can make the swap ten
times the memory and probably not notice less disk space. It's a
small price to pay to meet that hard requirement.

Harder is working out the memory requirements.

I would say one needs some experience of how many users you get,
what they sort of thing they run, how often, for how long, in order
to get a 'feel' for how much memory and swap are required.

Maybe formulating some statements about your requirements is
helpful. E.g.  the aforementioned "I never want to run out of memory",
(which really means swap) but also something more real-worldly soft
requirements like "If 95% of user processes, do not get swapped 95%
of the time then that is acceptable."

Maybe run 'sar' and archive the logs monthly (otherwise they'll be
overwritten) and then you can try to work out the memory and swap
required to meet your requirements.

And talk to your users, then you'll know if the requirements you've
set are actually acceptable.

Alexis



Reply to: