NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Swap size for servers with several GB of RAM
On 2011-09-29 10:41, Luca wrote:
Hello,
In the old days, there was a rule to set the swap space twice the size
of the RAM.
I think the rule was actually three times the size of ram, but in recent
years I've often seen it stated as twice. Anyway...
Does this rule still make sens with modern hardware?
For example, how many GB should be dedicated to swap when the server has
32GB of RAM ?
No. But it does not have anything to do with "modern hardware".
To understand why the rule is no longer relevant, you have to understand
the reason for the rule in the first place. In very old Unix systems
(this goes back to pdp-11 systems, but were true on early 32-bit systems
as well), memory for a process was allocated in swap. For each running
process. When the process was executed, parts of the process memory then
were located in ram as well, but there was still always the full space
allocated in swap. You could in a way look at this as if ram were cache
memory for swap.
So, even if you had plenty of free ram, you could get into a situation
where you could not run another process because there was no memory,
because memory meant swap. And in order to make somewhat sure that all
ram could be used, you needed to have more swap. Three times the ram was
a good rule of thumb to make sure you used resources efficiently.
Now, today, the memory is handled differently. Swap is no longer
considered "memory" with ram having a copy when needed. Swap and ram are
used together as the full memory. So even if you have no swap, you can
make full use of the ram you have.
Oh, and if someone asks, the swap area was specified in the kernel, and
was active already from the start of booting, so that the system worked.
No swap, and you would not be able to run anything.
All this written from memory (no pun intended), and I might actually
remember something wrong...
Johnny
--
Johnny Billquist || "I'm on a bus
|| on a psychedelic trip
email: bqt%softjar.se@localhost || Reading murder books
pdp is alive! || tryin' to stay hip" - B. Idol
Home |
Main Index |
Thread Index |
Old Index