Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > Your Distro > Redhat / Fedora Linux Help > Realistic SWAP space sizes

Forgot Password?
 Redhat / Fedora Linux Help   Help and discussion related to Redhat and Fedora Linux.

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Reply
 
Thread Tools Display Modes
Old 07-31-2008   #1 (permalink)
Just Joined!
 
Join Date: Jul 2008
Posts: 4
Realistic SWAP space sizes

Reading the OLD swap standard that is quoted everywhere on the web :
"The size of your swap should be equal to twice your computer's physical RAM for up to 2 GB of physical RAM. For physical RAM above 2 GB, the size of your swap should be equal to the amount of physical RAM above 2 GB. The size of your swap should never less than 32 MB."
This doesn't seem reasonable with large servers and new kernels. I have a system with 64GB of memory in it and based on this formula I should have a 66GB swap partition ((2 x 2GB) + (62 x 1GB)).

Running RHEL5 on mirrored 146GB drives with 64GB of memory, I don't ever expect to touch the swap space. Setting aside 66GB (45%) of my disk space for something I don't ever plan to use seems ridiculous.

I was told that a Kernel dump should never exceed 2GB.

I was also told that you should never set aside more than 2GB for swap unless you have special circumstances that require a large amount of swap.

I was also told that Linus Torvalds once said something like "You should use the same amount of swap space as you have physical memory up to 2GB, but no additional swap space after 2GB of physical memory."

I have done brief searches to try to determine the sources for the 3 statements above but haven't found them yet, but I believe them to be true.

Any light you can shed on the subject would be appreciated as I'd like to have a firm reference point to base my future server installs upon.
ne1scott is offline  


Reply With Quote
Old 07-31-2008   #2 (permalink)
Linux Engineer
 
Join Date: Nov 2007
Posts: 1,135
HROAdmin26 is offline   Reply With Quote
Old 07-31-2008   #3 (permalink)
Just Joined!
 
Join Date: Jul 2008
Posts: 4
That post is similar to mine, but I am asking additional questions and mentioned things I was told (which I hoped to be corrected on or to have vindicated by another source). Thanks for the link though, I'll continue to read both posts.

I was hoping to get some people offering up ways to calculate how much swap I really need to for people to send me links to pages where experts have recommended "no Swap" or "2GB max swap" etc....
ne1scott is offline   Reply With Quote
Old 07-31-2008   #4 (permalink)
Linux Engineer
 
Join Date: Nov 2007
Posts: 1,135
There is no "magic formula." If you are not satisfied with taking someone else's suggestion, then you need to get an understanding of how Linux uses swap (which is not identical to other *Nix's), what applications YOU are running, and how the two relate.

This is circa 2004, and I would say that swap has become even more obselete since then.

If I have a 64GB system that I needed top performance out of, I would have no swap and change the swappiness to 0. I can always add swap later. (And assuming my apps run easily inside that 64GB. I can only see something like large DB servers running TB-sized tables going through that - and that also can be controlled via DB tuning.)

For smaller systems (2-8GB RAM), I still create ~1GB swaps just for reasons mentioned in the article above. I typically see less than 100MB going into swap, even after months of uptime.

A 4GB *desktop* system after 45 days of uptime (used everyday) - with the default "swappiness":

Code:
Tasks: 169 total,   3 running, 166 sleeping,   0 stopped,   0 zombie
Cpu0  :  1.7%us,  1.2%sy,  0.0%ni, 96.5%id,  0.6%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :  2.1%us,  1.7%sy,  0.0%ni, 96.0%id,  0.2%wa,  0.1%hi,  0.0%si,  0.0%st
Mem:   4018640k total,  3829492k used,   189148k free,    56544k buffers
Swap:        0k total,        0k used,        0k free,  2180796k cached
Code:
uptime
  4:40pm  up 45 days  3:50,  8 users,  load average: 0.23, 0.27, 0.21
Code:
cat /proc/sys/vm/swappiness 
60
HROAdmin26 is offline   Reply With Quote
Old 07-31-2008   #5 (permalink)
Just Joined!
 
Join Date: Jul 2008
Posts: 4
As a coincidence, these systems (8 & 16 core x86_64) will be running a large DB Cluster with very large tables on an external storage array.
I am installing and tuning the OS for it's needs and will let the DB experts tune the system settings more for the DB's needs.

Nice article link by the way

Most servers I install/configure have 4 - 8 GB of RAM and don't run Oracle so I am looking for swap information to cover those systems as well.

I'm also not sure if the number of processor cores would have an effect on how much swap to allocate either (1 - 32 cores) in an x86_64 environment so I guess that is another question. I would assume "NO" at this point since the kernel shouldn't use swap differently when more cores are present, but I don't claim to be an expert on kernels or swap.
ne1scott is offline   Reply With Quote
Old 08-01-2008   #6 (permalink)
Just Joined!
 
Join Date: Mar 2005
Location: Lincoln, NE
Posts: 1
Send a message via AIM to solussd
2GB of swap is plenty. Here's why:
  • The OS itself will not have enough utilities/daemons running to come close
    to occupying 2GB of swap w/ rarely used pages.
  • The reason for having 64GB of memory on servers _is_ for cache/buffers to
    store recently used pages from disk, and in the case of a database server,
    buffered transactions and cached disk writes.
  • A server will be running a handful of programs that will be using the
    majority of the memory in the form of cache/buffers. These programs may have
    some pages that can be swapped out, but-- using a DB server as an example
    again, the DB program executable _itself_ isn't what has the big memory
    footprint.

This would be different in the case of a desktop system with 1GB of memory where you might be running several dozen userspace programs. 2GB of swap in this usage scenario makes sense as many of the programs may be idle and having their unused pages in memory is wasteful. Those pages are better used for cache and buffers.

Having 66GB of swap is a complete waste of space, especially on a server. What
could you possibly be swapping (ok, paging out-- subtle clarification) that is
even close to that big? I'm willing to bet all of the services/daemons,
programs (even many instances of the same program), etc on the entire server don't add up to 66GB (their data files don't count as they would never end up in swap).

I think 2GB is plenty and I doubt it would ever be fully utilized. If that
_just_ doesn't seem like enough, then make it 4GB. 66GB of swap is just
ridiculous.
solussd is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 09:41 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2