Side Channel

  • home
  • resources
Home › Blogs › angch's blog

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password

Navigation

  • Books
  • Feed aggregator

Recent blog posts

  • Ubuntu mirrors up and improved!
  • Google-jstemplate: Iterate object with unknown properties
  • nginx https proxypass for php apps
  • sugarcrm & memcache: Doing it Wrong
  • subversion and https in Ubuntu Karmic
  • Drupal: Views block delta converted to md5 hash
  • Ubuntu Server install requires PAE
  • Installing Drupal from command line
  • Drupal: Handling form field weight through CCK
  • minify javascript using Google Closure Compiler
more

angch's location

angch twitter

  • angch: Heading to Brunei. Business class for a change.
  • angch: tc qdisc htb activated on the mirror, and mirror reactivated. Hope nothing melts now.
  • angch: Hmmm, tbf doesn't work as advertised. htb does. #qos #linux
  • angch: @yoonkit me thinks #lucid is a much better tag than #lynx
  • angch: Great, you broke the dc's net and they disconnected us. Running to tpm from shah alam
more

Revisiting Linux swap space size calculations

angch's picture

angch — Wed, 29/07/2009 - 21:33

Back in the early days of Linux, the rule of thumb for sizing your swap partition is "twice the amount of RAM". But does that still apply to modern hardware where we regularly have 16 GB or more?

4 schools of thought:

  • $ram * 2 (I call it the "jurassic" method)
  • $ram > 2048 ? $ram + 2048 : $ram * 2 (aka "redhat", see below)
  • $ram <= 2 GB ? 1.5 * $ram : ($ram <= 8 GB ? $ram : 0.75 * $ram) (aka "oracle", see below)
  • 4GB (I call it "angch's")

Last school of thought is mine, and the rationale behind it includes:

  • Swapping is slow. If you're filling up 4GB of swap, that going to take quite some time. Swapping your leaky Firefox to and from disk is going to make you very annoyed.
  • If you're already swapping more than 1 gig of RAM, something is very, very wrong with your system. Adding more swap is just going to delay the inevitable OOM killer triggering.
  • 4GB ought to be enough for everyone.

Doesn't apply to netbooks, of course. And just make sure you have enough to hibernate your notebooks.


Some swap calculation resource:

  • Red Hat RHEL4 method: http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/sysadmin-gui...
  • Oracle: http://www.puschitz.com/TuningLinuxForOracle.shtml#SizingSwapSpace
  • Oracle 10gr2: http://download-east.oracle.com/docs/cd/B19306_01/install.102/b15660/pre...
  • http://dsumsky.blogspot.com/2008/12/quickly-linux-swap-space-sizing.html

    • Handy table for you to size your swap space, with swap space in MB for fdisk friendliness.

      RAM size Swap size,
      Jurassic
      Swap size,
      RedHat
      Swap size,
      Oracle
      Swap size,
      angch
      256 MB 512 MB 512 MB (n/a) 4096 MB (you're gonna upgrade your RAM soon, right?)
      512 MB 1024 MB 1024 MB (n/a) 4096 MB
      1024 MB (1GB) 2048 MB 2048 MB 1536 MB 4096 MB
      2GB 4096 MB 4096 MB 3072 MB 4096 MB
      4GB 8192 MB 6144 MB 4096 MB 4096 MB
      8GB 16384 MB 10240 MB 8192 MB 4096 MB
      16GB 32768 MB 18432 MB 12288 MB 4096 MB
      32GB 65536 MB 34816 MB 24576 MB 4096 MB

      4 GB seems to be the Mach barrier of sorts for modern operating systems:

      • if you have >= 4GB RAM, use a 64bit OS.
      • if you have >= 4GB RAM, 4GB swap should be sufficient.

      P.S. I wimped out on my own recommendation and allocated 18GB swap for the new 16GB machines (redhat method). Hypocrite.

  • linux
  • performance
  • swap
  • angch's blog
  • Add new comment


Creative Commons License

  • home
  • resources

Standard Disclaimer.