Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Jul 2014 08:49:26 -0400
From:      Paul Kraus <paul@kraus-haus.org>
To:        FreeBSD-Questions <freebsd-questions@freebsd.org>
Subject:   Re: How much swap space for a 32 GB RAM system?
Message-ID:  <C9346412-5FF3-4E98-8817-6ABC2EB847AB@kraus-haus.org>
In-Reply-To: <53CE8BB8.7030303@qeng-ho.org>
References:  <53CE8BB8.7030303@qeng-ho.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Jul 22, 2014, at 12:05, Arthur Chance <freebsd@qeng-ho.org> wrote:

> I'm getting a new machine with 32 GB of memory. The old "twice =
physical memory" sizing seems ridiculous, so how big should I make swap? =
Do I even need swap with this much memory?

Back to the original question=85 With a large amount of RAM (usually =
defined as greater than 4GB), how much swap do I really need?

I first started seeing that question back in about 1997 or 1998, but for =
Solaris boxes that had grown to over 1GB RAM. At the time both RAM and =
disk drives were expensive, and disk drives were typically 500MB (at the =
largest). The rule of =93for servers configure 2+ times your RAM as =
swap=94 and the rule for desktops was 1 to 1.5 times. This rule of thumb =
was old then.

The question then (as now) was why. Under SunOS 4.1 you could not run =
the system without swap as the kernel allocated =93backing store=94 or =
swap space for all (note that, ALL) memory allocated. This was because =
RAM was a very limited resource and swapping was common, so having the =
swap space allocated made sense.

With the release of SunOS 5 (Solaris 2.x and later) the situation =
changed and swap was no longer required*. You could run a Solaris 2 =
system with NO swap configured. This was because Solaris 2 did not swap =
in the traditional sense, it paged. In other words, entire processes =
were not swapped out (the traditional meaning of the term to swap), =
rather, as the system came under memory pressure, individual pages (8KB) =
of RAM were paged out (but the device was still called the swap device). =
If the system came under enormous memory pressure, then entire processes =
would be swapped out. Chapter 13 of Adrian Cockcroft and Richard =
Pettit=92s book, =93Sun Performance and Tuning=94 describes this quite =
clearly for SunOS version prior to 5.7 (Solaris 7), when the memory =
management sub-system was completely rewritten.

The question for FreeBSD has to go back to how memory is managed and how =
swap space is used (ignoring the crash dump function). I have not seen =
anyone post a good description of how memory management works under =
FreeBSD and I do not have the coding skills to just =93read the source=94,=
 so if someone reading this wrote that code or understands it, I would =
love to have a really good detailed description to help make decisions =
about RAM and swap.

My largest FreeBSD system has 32GB of RAM and I have 32GB of swap =
configured, but that is the exception not the rule. I have a much =
smaller server I am building right now that has 16GB and only 8GB swap. =
Remember to use multiple swap partitions and match the sizes.

* The exception, and one that was not well documented, was the use of =
Shared Memory under Solaris, at least up through Solaris 10. For every =
page of shared memory allocated a page of swap space is allocated as =
well. I do not know why, but that is the way it worked. I had a very =
large (at the time) Oracle DB server have really weird issues because we =
had very little swap (enough to hold the kernel in a crash dump) and =
were trying to use multiple GB of shared memory.

--
Paul Kraus
paul@kraus-haus.org




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C9346412-5FF3-4E98-8817-6ABC2EB847AB>