Babbling about stuff
L.E.B.O.
Archives
« December 2009
SunMonTueWedThuFriSat
  
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today
Click me to subscribe
Search

Links
 

Today's Page Hits: 141

Locations of visitors to this page
« Strike! | Main | More toys please! »
Monday Oct 29, 2007
Can't swap this....

Swap partitions... how big should they be in a “modern” Linux or Unix install? This seems to be a topic of much controversy... and it seems no one can agree how much is enough, or how much is too much.

There is an interesting discussion about swap space here: http://etbe.coker.com.au/2007/09/28/swap-space/

As a long time Linux user I have always been told that I should allocate at least as much swap as RAM, and if possible go for twice the swap as RAM. I have oodles of disk space (over 2TB on my home computer) so allocating 4GB or more to swap isn't a hardship. My current setup has 4GB of swap (and 2GB RAM). For “normal” home use, I don't usually see any swap being used, but when I start to load the computer up a little... running Solaris Express Developer Edition in VirtualBox for example, I see the swap partition being used... a lot. I've had instances where I've maxed out RAM and used up almost all of the 4GB of swap. I don't know if this is a bad thing or not... (maybe I need to spring for more RAM) but I am definitely using that swap space.

So... how does this compare with what the author of the Swap Space article has to say? Who is right? How much swap space is “right”? Anyone else have experience with this and care to comment?

Posted at 10:09AM Oct 29, 2007 by cdc in Linux  |  Comments[3]

Comments:

Understanding that your question appears to be Linux based, but can be applicable to Solaris as well, which is what I work with.

To me, it really just depends on the user experience you are willing to saddle your users (or yourself) with. In very simplistic terms, swap space is just an extension of the memory that is mappable by the kernel, but it is very slow memory. And different stores backing your swap can have a significant impact on that memory experience. Using a single 7200RPM spindle for swap will be very different than using a SAN volume that is composed of multiple 15K RPM spindles and cache-fronted.

As an example, on some development machines I've used, which are T2000s with 32GB of RAM, we've added 128GB of SAN-based swap space so we're at a 1:4 ratio of RAM:swap, which can run a few dozen S10 zones with individual JVMs running app servers with large (>2GB) heaps. This allows us to consolidate a lot of low-value/low-utilization environments onto a single host, and in the end, we're saving significant amounts of power/floorspace/licensing. Now this isn't for everyone. It requires that you have a specific usage pattern where folks can live with a small delay when starting up a task, and slightly reduced throughput during competetive workload execution. If that is OK for your world, then you have a lot of opportunity for savings by utilizing large swap allocations.

I don't know that I would recommend it for someone's desktop environment. There I typically stick to the 1:1 RAM:swap ratio. And if you don't have enough RAM to keep your user experience pleasant, then go buy some more, especially with today's favourable pricing... unless it's an X option. :(

MK

Posted by Michael Kennedy on October 29, 2007 at 11:30 AM CET #

Thanks for your insight on this Michael. Yes I use Linux primarily at home, but I am also starting to use Solaris x86 (for now in a VM, but probably also a native install soon). I am planning a partition reshuffle soon, and at the same time a major OS update to the latest version of the Linux distro I use, plus a Solaris x86 install. Having a little background info and understanding of swap needs will really help me get a more efficient configuration.

Posted by cdc on October 29, 2007 at 11:40 AM CET #

Solaris != Linux

If Solaris happens to allocate swap the way ancient Unix systems used to (according to the documents references in my blog post) then having swap > RAM would be necessary.

Aside from that the different allocation methods in various OSs will affect how much you need.

Let's not assume that a SAN cures all performance problems either, you will typically not be the only user of a SAN so if you start swapping hard you may kill performance for others.

Cache on a SAN for swap is simply a losing game, cache memory on SAN devices is significantly more expensive than RAM in a host (particularly for desktop machines).

Posted by Russell Coker on October 29, 2007 at 09:03 PM CET #

Post a Comment:
  • HTML Syntax: NOT allowed