LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Best practice size for Swap partition (http://www.linuxquestions.org/questions/linux-general-1/best-practice-size-for-swap-partition-402826/)

Garp 01-13-2006 06:00 AM

Best practice size for Swap partition
 
I'm writing up some documentation for work explaining the steps for rebuilding a linux box, and on a proof read I spotted I'd written that the good practice is for swap to be the same size as system memory, something I remember reading somewhere. What I don't remember is why? I can think of various locations talking about the reccomended size of a swap file for Windows and getting everything from "half the system memory + 64mb" through to obscure ones like "total system memory + 2* your Aunt Mary's Age, divided by the number of prunes she had for dinner"; there seemed to be no concensus nor any real explanation as to where these hard and fast rules had developed from.

Is there such an explanation out there for Linux and its swap drive size? Is "same size as system memory" really good practice?

Ahmed 01-13-2006 06:05 AM

Don't know.. I heard that it's double the system memory though

-A

trickykid 01-13-2006 06:25 AM

Quote:

Originally Posted by Ahmed
Don't know.. I heard that it's double the system memory though

-A

Old rule of thumb that is..

Nowadays when desktop systems have 1GB of memory almost standard, it just all depends on how much swap you should use. It all depends on what the system is going to be used for, how much memory total it has, etc.

Heavily used server with 2GB of RAM, it probably wouldn't hurt to have a 2GB swap space. Same server lightly used and not expecting high loads, 512MB might do the job and might never get used, even the 2GB swap on high traffic server might never get used.

Poetics 01-13-2006 04:00 PM

I've generally run with 2x system memory for <1gB, 1x for >1gB

bandersnatchy 01-13-2006 09:25 PM

Quote:

Originally Posted by Garp
Is "same size as system memory" really good practice?

"Good practice" is what works for you. Long threads of logical arguments about how swap is good or not so good are interesting, but don't point to a single simple formula.

If you are "rebuilding" an existing server, there should be some idea about what works in your particular network.

If there is no idea about what is most efficient in a network, and I felt obliged to put a formula in the documentation, I wouldn't hesitate to put something about starting with 2x RAM, monitoring, and adjusting if needed.

For a desktop, Poetics' formula looks good to me, generally. More swap may be advised for putting together custom live CDs or DVDs. I've read that lots of swap is good for working with video.

A work manual? Remember KISS. Keep it as simple as possible. Don't try to explain all the issues of the Linux universe.

Good Luck!

Garp 01-14-2006 06:15 PM

Quote:

Originally Posted by bandersnatchy
"Good practice" is what works for you. Long threads of logical arguments about how swap is good or not so good are interesting, but don't point to a single simple formula.

If you are "rebuilding" an existing server, there should be some idea about what works in your particular network.

If there is no idea about what is most efficient in a network, and I felt obliged to put a formula in the documentation, I wouldn't hesitate to put something about starting with 2x RAM, monitoring, and adjusting if needed.

How does one go about monitoring the swap usage? I don't think I've ever read it anywhere.

Quote:

A work manual? Remember KISS. Keep it as simple as possible. Don't try to explain all the issues of the Linux universe.

Good Luck!
I've done my absolute hardest to keep the manual simple, but its literally a step-by-step process talking the end user exactly through installing Gentoo and then on to a fully working DVB PVR box. I can't have done too badly with it as a totally non-linux geek has just managed to do it on a test box in the office :D

bandersnatchy 01-14-2006 08:41 PM

Quote:

Originally Posted by Garp
How does one go about monitoring the swap usage? I don't think I've ever read it anywhere.

I'm really out of my league here, with servers. Maybe someone else will jump in.

Here is something less serious folk like me might do on a desktop machine... Configure a KSysGuard chart to show swap use for a half hour. Take a snapshot of this screen after a period when memory use is high. But a server administrator may not want KSysGuard anywhere near his server.

A resourceful expert could probably use "free" in a script, collecting memory use data info every few seconds, but that appears to be reinventing what surely has to already be out there.

A little googling located this James Day post in mysql forum:
"In a linux environment you should use top and vmstat to monitor swap use. For top, turn on the optional column for displaying the number of hard page faults (called nFLT in some versions). If it's a dedicated server I aim for close to zero si and so in vmstat monitoring, based on experience showing that any significant amount hurts. "
http://forums.mysql.com/read.php?24,8218,8266

But sorry, I really don't know if Mr. Day has the best answer either.

I keep finding stuff about "meminfo", but reading it is giving me an awful headache. Maybe you can do better!

Quote:

Originally Posted by Garp
I've done my absolute hardest to keep the manual simple, but its literally a step-by-step process talking the end user exactly through installing Gentoo and then on to a fully working DVB PVR box. I can't have done too badly with it as a totally non-linux geek has just managed to do it on a test box in the office :D

Whoa! You bit off a big chunk for starters. Take some time to enjoy your accomplishments. Congrats.

Garp 01-18-2006 06:32 AM

Quote:

Whoa! You bit off a big chunk for starters. Take some time to enjoy your accomplishments. Congrats.
It was and wasn't my choice :)
We really needed to be able to record off freeview (digital terrestrial in the UK), and be able to burn the recordings onto DVD for use in classrooms. After spending ages digging around I couldn't find a commercial solution that fulfilled all the requirements, dual tuners etc. etc. Decision was made amongst the team that as I had a mythtv box running at home (more or less.. was still working on it at the time), if we bought a couple of digital tv cards we could produce an in house solution. After bashing my head against brickwalls in RHES (running on other servers in-house), Fedora Core, and Slackware, I finally switched over to Gentoo like I was using at home. No hassles there :D Install took longer, sure, but it works with no hassles on the scale I was getting with the other distros.

Problem is I'm the only person on site that has ever installed Gentoo before, so documentation of install was necessary in case I get run over by a number 9 bus or something :D

Eventually, when I get time, I'll be knocking up the instructions into more of a HOWTO format than they are currently for others to use. A few of the colleges in the area have heard about our PVR and were asking how to make ones of their own...


All times are GMT -5. The time now is 11:11 AM.