OpenBSD Journal

[Ask OBSDJ] Swap Space on OpenBSD?

Contributed by Dengue on from the gotta-dump-somewhere dept.

george writes : "How do you compute swap space on OpenBSD? Is there a rule of thumb? For example in FreeBSD when you have 128MB RAM the installation procedure recommends 259MB (which I assume since I have not looked at the code is 2x physical RAM plus some space for indices). So how to calculate the swap space on OBSD?"

This seems to differ a lot with different OS's. I've always operated under the rule of thumb that you need *at least* as much swap as physical RAM or bad things (tm) happen. What is the definitive word on this? With today's mega ATA drives, a gig of swap is trivial, but what is the optimum setup?

(Comments are closed)


Comments
  1. By Free Bird () on

    I still find it rather weird that many people recommend 2 times the amount of physical RAM in your machine as a rule of thumb. Of course you should have at least as much swap as physical RAM (at least in my experience) but advising two times your physical RAM is stupid. That'd mean that if I'd upgrade from 256MB to 512MB I'd have to INCREASE my swapspace to 1GB, instead of decreasing it because it is less neccessary!

    My advice is: look at how much memory (physical + virtual) you will need in a worst case scenario, subtract your physical RAM amount from it, and make your swapspace that size. You might make it several MBs bigger for some overhead, but physical RAM and VM definitely needn't be linearly proportional.

    Just my €0.02

  2. By one/fs () . on mailto:.

    a swap space in size of ram plus some MB of is needed for system dump, the rest is needed to keep dump image untouched while system reboots and copies dump off the swap space, swapping is bad thing anyway - buy adequate RAM for your application requirements. ... you may have another swap space on another HD-s twice ram anyway is minimal

  3. By oobleck () nospankyou@nospam.org on mailto:nospankyou@nospam.org

    I am a Solaris admin (among other things) and have had a few classes at Sun for Sys Admin and troubleshooting. They "recommend" 2XRAM for swap.
    The only valid reason I have ever seen for this is when you have a LARGE panic dump. Some times the core can take up 1GB+.
    Some stupid companies actually require you to use 3XRAM. In my previous job I supported Sun systems with a database called "Versant". Versant support required that your machine have 3XRAM if they were going to give you tech support.

    Ever seen a big Sun box swap 4+GB? It is really sick.

    The moral of the story is to put as much swap as you would need to dump your core file too. (So Sun support can look at it and determine why your system is crashing.) OR Just run OpenBSD and don't worry about it....

  4. By Sacha Ligthert () on

    I'm running a MySQL server on 3.0 without the current threading. Hosting a chat interface use PHP/MySQL which is heavely used throughout the weak.

    So you can imagine that the load will go up to 1.5 on my Celeron 400 with 256megs of RAM in it.
    I choosen 256Megs of swap... The reasen why is because this "Swap: 0K/256M" is my average usage of swap.

    I remember one day a record in usage of swap... 24000 real K's wich lasted not long and went back to scratch shortly after.

  5. By PC () pc@superiorcommREMOVE_ME.net on mailto:pc@superiorcommREMOVE_ME.net

    Just like everyone else, I've always heard 2x or 2.5x your physical RAM. But let's be real here for a second...in this day and age where 1GB of physical RAM is common...do you really want to have the system swapping 2GB-2.5GB of memory on to your disk? How long do you think it takes for the pages in/out with that amount of disk activity?

    I usually throw in 512MB-768MB of swap space. That does the job for me.

  6. By Toaster Tester () bsdfan@hotmail.com on mailto:bsdfan@hotmail.com

    What is the right amount a swap space isn't the right question, the question is how much RAM. Amount of RAM is going to effect swapping. Where I work performance is everything, so if a server swaps it doesn't have enough RAM. Swap is big enough to handle a core, which is enough for whatever else the OS wants to put there.

  7. By RedneckAdmin () spambad@avoid.it on mailto:spambad@avoid.it

    I have two OpenBSD servers with a measly (in this day and age) 768M RAM. Hard drive space is most definitely not a problem, so I followed the 2X rule I was used to in the past on Sun boxes running Solaris. Well, after assigning all that swap, I've noticed that even in times of high load, the swap has NEVER BEEN USED. I'm talking virtual hosting for 30 sites or so per machine including DNS, web, mail, webmail, all running at the same time as a friggin' make world, and STILL no swap usage...

    Folks, I can only conclude the days of 2X for your swap are dead.

  8. By Anonymous Coward () on

    My next system will probably have 2gb of RAM. Do I even need swap? For example, the current system has 512mb of RAM and 1gb of swap, for a total of 1.5gb of memory storage. If the usage remains the same, and I move to 2gb of RAM, can I turn off swap altogether? I have never encountered "out of memory" with my 1.5gb setup, and usage will definitely not change with the new machine, because it is there for only one thing which never changes.

  9. By David M. Gaskin (87.123.66.209) David@gaskin.de on

    IMHO all of the comments are way off the mark. Paging (to and from swap) is far more efficient that file I/O so with 4Giga bytes of address space available PER PROCESS (and that is on 32 bit systems) using that address space rather than buffering on files in the file system produces far better performance.

    Therefore there is no general answer to the question "How large should SWAP be?", as the answer is very dependant on the type of processes that will be running concurrently. In the 1970's IBM where experimenting with having an operating system without files, where a FileObject (that repesented what other OSes would call file) was just a memory address (in a 48 bit address space) with a size. All of the diskspace on such a system was then basically SWAP space. The concept was used in the System/38 RDBMS and later
    on the AS/400 rdbms.

Credits

Copyright © - Daniel Hartmeier. All rights reserved. Articles and comments are copyright their respective authors, submission implies license to publish on this web site. Contents of the archive prior to as well as images and HTML templates were copied from the fabulous original deadly.org with Jose's and Jim's kind permission. This journal runs as CGI with httpd(8) on OpenBSD, the source code is BSD licensed. undeadly \Un*dead"ly\, a. Not subject to death; immortal. [Obs.]