How much swap space for a 32 GB RAM system?
paul at kraus-haus.org
Wed Jul 23 13:15:01 UTC 2014
On Jul 22, 2014, at 12:05, Arthur Chance <freebsd at 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… 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 “for servers configure 2+ times your RAM as swap” 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 “backing store” 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’s book, “Sun Performance and Tuning” 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 “read the source”, 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 at kraus-haus.org
More information about the freebsd-questions