[CentOS] How much SWAP Space.

Thu Jul 7 01:46:12 UTC 2011
Devin Reade <gdr at gno.org>

Kaushal Shriyan <kaushalshriyan at gmail.com> wrote:

> I have loaded CentOS 5.6 on HP DL 180G6 2U Rack Server and the
> physical RAM is 32 GB. As per
> http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-swapspace.html
> It says it should be 1 x of Physical RAM or less. Not sure about the
> "less" word in deciding swap space size

IIRC, the traditional rationale behind having at least as much swap space 
as physical memory has to do with being able to save a core file 
(on reboot) if the kernel bites it.  Different UNIX variants had 
slightly different concerns and values (in some cases 2x physical
memory).

Other things that can influence wanting a lot of swap are:
  - if you need to support hibernation
  - if you're using kexec (I think)
  - if you're using tmpfs filesystems to any degree
  - if you're using a serious amount of buffer cache (such as on
    a file server)
In all of those cases, swap will generally be used in a sensible
fashion; you may use a lot, but that doesn't imply thrashing.

Without those circumstances, you still want a reasonable amount,
but I'd be less concerned with matching the amount of physical RAM.
The rule of thumb I use to start on CentOS systems is a minimum
of 2G total or 1G per core, whichever is greater.  Despite that,
if your swap in/out parameters are consistently non-zero, you're
best to solve it with RAM.

If you put your swap on an LVM volume, you can always easily tune
it up and down as your needs change.

Devin
-- 
If you have any trouble sounding condescending, consult a UNIX user.