D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Bah! Disks! Bah!

 

On Fri, 5 Feb 2010, Rob Beard wrote:

Quoting Terry Hill <telbonic@xxxxxxxxxxxxxx>:

It does make sense though if possible to throw a few extra sticks of ram in
and get rid of it altogether if possible.

I was under the impression that it's a good idea to have some swap even if it's a minimal amount.

My laptop has 4GB of RAM but I still have something like 256MB swap on my hard drive, I gather the kernel is inteligent enough to swap out some things even if there is bags of memory available.

The eternal debate (or yet another holy war ;-)

In a modern Linux system, you do not need swap, however if you have some, then it may be used in some circumstances - e.g. the kernel may elect to move some processes (or data) to it if there is a need for more RAM for things like disk buffers - and this can improve performance - e.g. if your Linux distro includes getty on a text console, when was the last time you actually used it? So swap it out and you get a few MB more for disk/file buffers...

Older Linux and other *nix systems did need swap due to the way the way the virtual memory system was designed and the old rule of "double the size of main memory" was common.

These days, if you've got enough RAM you don't need swap and a modern Linux kernel is OK without it.

And after saying that, I'll add that with one exception, I always add swap to a system I build "just in-case" and it's usually double the RAM size. Old habits die hard..


This system:

  top - 11:52:05 up 8 days,  4:35,  1 user,  load average: 0.32, 0.46, 0.51
  Tasks:  91 total,   1 running,  90 sleeping,   0 stopped,   0 zombie
  Cpu0  :  2.7%us,  0.3%sy,  0.0%ni, 96.3%id,  0.7%wa,  0.0%hi,  0.0%si,  0.0%st
  Cpu1  : 12.9%us,  0.7%sy,  0.0%ni, 86.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
  Mem:   3629860k total,  3378500k used,   251360k free,   268240k buffers
  Swap:  3903672k total,        0k used,  3903672k free,  2242760k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 8405 mysql     20   0  407m 317m 5292 S    0  9.0 496:42.36 mysqld

hosts a few dozen websites including a a very busy vBulletin server. It has 4GB of RAM with swap avalable, but it never seems to put anything into swap.


The exception is my embedded devices which run with swap enabled in the kernel, but no actual swap partition... This system:

  top - 11:42:22 up 124 days, 1 min,  1 user,  load average: 0.00, 0.00, 0.00
  Tasks:  32 total,   1 running,  31 sleeping,   0 stopped,   0 zombie
  Cpu(s):  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
  Mem:    257208k total,   238644k used,    18564k free,     2516k buffers
  Swap:        0k total,        0k used,        0k free,    35164k cached

  dsx$ df -h
  Filesystem            Size  Used Avail Use% Mounted on
  /dev/ram0             136M   84M   53M  62% /
  tmpfs                 126M     0  126M   0% /lib/init/rw
  tmpfs                 126M  4.0K  126M   1% /dev/shm
  /dev/hda3             189M   95M   94M  51% /data

is running entirely in RAM with no swap. 136MB of it's 256MB is used as a ramdisk for the entire filesystem. (/data contains soundfiles and voicemail storage - it's part of a 256MB CF card)

Gordon

--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html