<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Linux: Should You Use Twice the Amount of Ram as Swap Space?</title> <atom:link href="http://www.cyberciti.biz/tips/linux-swap-space.html/feed" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/tips/linux-swap-space.html</link> <description>This is a Linux sys admin journal by Vivek about sys admin work, Linux tips &#38; tricks, hacks, news and more.</description> <lastBuildDate>Fri, 10 Feb 2012 20:37:43 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Mason</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-179025</link> <dc:creator>Mason</dc:creator> <pubDate>Tue, 07 Feb 2012 00:52:37 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-179025</guid> <description>I have an Athlon x4 system running Mint Debian edition right now, and I use swap space on the installed drive as well as a seperate older 40gb drive exclusively for backup swap space, I can EASILY use 16 GB on my 8GB memory system, so a &quot;twice ram in swap&quot; baseline is perfactly in line, I for one have over 75 GB of swap space and frequently go into that 40GB backup reserve, but you can tell when it does, it slows the system down dramatically, telling me it&#039;s time for a reboot.</description> <content:encoded><![CDATA[<p>I have an Athlon x4 system running Mint Debian edition right now, and I use swap space on the installed drive as well as a seperate older 40gb drive exclusively for backup swap space, I can EASILY use 16 GB on my 8GB memory system, so a &#8220;twice ram in swap&#8221; baseline is perfactly in line, I for one have over 75 GB of swap space and frequently go into that 40GB backup reserve, but you can tell when it does, it slows the system down dramatically, telling me it&#8217;s time for a reboot.</p> ]]></content:encoded> </item> <item><title>By: Wolf</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-178854</link> <dc:creator>Wolf</dc:creator> <pubDate>Fri, 20 Jan 2012 19:07:38 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-178854</guid> <description>There are always processes that require extraordinary amounts of memory - yet not all of this memory has be be accessible instantaneously. Take 3D image file processing such as in CAT scans. A 4000-cubed volume has some 64G-pixels and depending on a particular software processing - such as modern nonlinear tomographic reconstruction methods - you may easily reach 1TB of storage for those pixels, raw input data, and related matrix information. Smart processing will focus on sub-regions while other regions are kept in swap space.
Even smaller reconstructions, when several of them are to be processed concurrently on an MP system, have similar appetite for memory. Writing swap routines for intermediate data storage (as I have done in the past) definitely slows down development of these kind of high accuracy algorithms and should be avoided.
Interestingly, it seems that under those conditions - a swap space several times the size of RAM (say in the &gt;100GB range) - some swap space management algorithms &quot;paint themselves&quot; into a corner and kill processes before they have made use of the available swap space (time delays/pauses in writing to virtual memory can save the day - avoiding process kills).
In summary - just filling the RAM to the physical MAX may not solve the issue for a given machine  nor is it efficient in terms of computing resources. Thus the question remains - how much swap space may/should you safely allow for. Would that not remain a problem specific issue?</description> <content:encoded><![CDATA[<p>There are always processes that require extraordinary amounts of memory &#8211; yet not all of this memory has be be accessible instantaneously. Take 3D image file processing such as in CAT scans. A 4000-cubed volume has some 64G-pixels and depending on a particular software processing &#8211; such as modern nonlinear tomographic reconstruction methods &#8211; you may easily reach 1TB of storage for those pixels, raw input data, and related matrix information. Smart processing will focus on sub-regions while other regions are kept in swap space.</p><p>Even smaller reconstructions, when several of them are to be processed concurrently on an MP system, have similar appetite for memory. Writing swap routines for intermediate data storage (as I have done in the past) definitely slows down development of these kind of high accuracy algorithms and should be avoided.</p><p>Interestingly, it seems that under those conditions &#8211; a swap space several times the size of RAM (say in the &gt;100GB range) &#8211; some swap space management algorithms &#8220;paint themselves&#8221; into a corner and kill processes before they have made use of the available swap space (time delays/pauses in writing to virtual memory can save the day &#8211; avoiding process kills).</p><p>In summary &#8211; just filling the RAM to the physical MAX may not solve the issue for a given machine  nor is it efficient in terms of computing resources. Thus the question remains &#8211; how much swap space may/should you safely allow for. Would that not remain a problem specific issue?</p> ]]></content:encoded> </item> <item><title>By: Eugene</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-175502</link> <dc:creator>Eugene</dc:creator> <pubDate>Tue, 08 Nov 2011 05:04:37 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-175502</guid> <description>I&#039;ve noticed that in a heavily loaded vm environment where 65 to 85+ percent of the RAM is allocated/utilized, having less swap space than the amount of RAM tends to crash some of the virtual machines at times, so I tend to stick with the 2x rule just to be on the safe side.</description> <content:encoded><![CDATA[<p>I&#8217;ve noticed that in a heavily loaded vm environment where 65 to 85+ percent of the RAM is allocated/utilized, having less swap space than the amount of RAM tends to crash some of the virtual machines at times, so I tend to stick with the 2x rule just to be on the safe side.</p> ]]></content:encoded> </item> <item><title>By: Walter</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-172912</link> <dc:creator>Walter</dc:creator> <pubDate>Sun, 31 Jul 2011 10:01:10 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-172912</guid> <description>A bit outdated ... but at least when you intend to hibernate / suspend your system, you want
physical RAM + little more for swap space. Because that swap space is used to save
your memory content ...</description> <content:encoded><![CDATA[<p>A bit outdated &#8230; but at least when you intend to hibernate / suspend your system, you want<br
/> physical RAM + little more for swap space. Because that swap space is used to save<br
/> your memory content &#8230;</p> ]]></content:encoded> </item> <item><title>By: jack</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-170204</link> <dc:creator>jack</dc:creator> <pubDate>Mon, 21 Mar 2011 15:55:20 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-170204</guid> <description>So, we just installed some IBM X3950 M3&#039;s in a cluster with 1 Terabyte of RAM. You&#039;re suggesting how much swap space?</description> <content:encoded><![CDATA[<p>So, we just installed some IBM X3950 M3&#8242;s in a cluster with 1 Terabyte of RAM. You&#8217;re suggesting how much swap space?</p> ]]></content:encoded> </item> <item><title>By: Dude</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-168468</link> <dc:creator>Dude</dc:creator> <pubDate>Thu, 27 Jan 2011 10:31:47 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-168468</guid> <description>Ubuntu defaults to 136% of physical RAM for swap.  My netbook has Ubuntu 10.04, 2gb of RAM and about 3gb of swap space.  It NEVER uses more than 500mb of swap space.  Disk space isn&#039;t cheap when you are using an SSD drive.  Anything over 1gb of swap is a waste on my netbook SSD drive.  I never use the Suspend feature, because Linux boots fast (unlike Windows).
My desktop system has 4gb of RAM and an Ubuntu 10.04 variant.  I forced it to use about 1.3gb once.  I ran 2 VirtualBox session with Redhat and Fedora, Firefox, Gimp and VLC all at the same time.  This was when I was using a 30gb SSD drive for swap space.  I never even got the system to use 2gb of swap space.  Ok, maybe it used more than 1.3gb for a few microseconds, but the average was much less.  Typically, my desktop uses less than 500mb as well.
Try the command &#039;vmstat -s&#039; to see how much swap space is used.  Most of the time it&#039;s 0 k on both of my systems.  I tend to agree that swap space isn&#039;t really needed if you have enough RAM.  I think the Ubuntu default of 136% of RAM is more than enough.</description> <content:encoded><![CDATA[<p>Ubuntu defaults to 136% of physical RAM for swap.  My netbook has Ubuntu 10.04, 2gb of RAM and about 3gb of swap space.  It NEVER uses more than 500mb of swap space.  Disk space isn&#8217;t cheap when you are using an SSD drive.  Anything over 1gb of swap is a waste on my netbook SSD drive.  I never use the Suspend feature, because Linux boots fast (unlike Windows).</p><p>My desktop system has 4gb of RAM and an Ubuntu 10.04 variant.  I forced it to use about 1.3gb once.  I ran 2 VirtualBox session with Redhat and Fedora, Firefox, Gimp and VLC all at the same time.  This was when I was using a 30gb SSD drive for swap space.  I never even got the system to use 2gb of swap space.  Ok, maybe it used more than 1.3gb for a few microseconds, but the average was much less.  Typically, my desktop uses less than 500mb as well.</p><p>Try the command &#8216;vmstat -s&#8217; to see how much swap space is used.  Most of the time it&#8217;s 0 k on both of my systems.  I tend to agree that swap space isn&#8217;t really needed if you have enough RAM.  I think the Ubuntu default of 136% of RAM is more than enough.</p> ]]></content:encoded> </item> <item><title>By: Greg Zeng</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-154087</link> <dc:creator>Greg Zeng</dc:creator> <pubDate>Thu, 04 Mar 2010 08:04:39 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-154087</guid> <description>Using OpenSuse, latest, default 2gb swap file included &amp; used.  Boot: 5.75 gb.  Home: 7.12 gb. [checked by freeware Partition Wizard 4.2.2].
OpenSuSe swap usage?  How do  I measure it?
Main op sys is VISTA (HP PAVILLION notebook DV6514TX, 320 GB HDD, 3GB RAM).  Vista has a 4gb partition, with operating set swap drive.  At the moment (48 processes, physical ram 78 %), it uses 1 gb swap disk. [Freeware: Process Explorer].  Linux is used to correct Windows crashes.
Windows is preferred because of better applications: Dragon Naturally Speaking, latest hardware, Servant Salamander, Cobian Backup, Omnipage, ....
Windows &amp; applications make use of &quot;temp&quot; directories.  I put all my temp folders (4 of them in Windows) on the first partition of my fastest drive.  Being a common notebook, it has only one, not counting the slow external USB drives.
Greg Zeng, Australian Capital Territory</description> <content:encoded><![CDATA[<p>Using OpenSuse, latest, default 2gb swap file included &amp; used.  Boot: 5.75 gb.  Home: 7.12 gb. [checked by freeware Partition Wizard 4.2.2].</p><p>OpenSuSe swap usage?  How do  I measure it?</p><p>Main op sys is VISTA (HP PAVILLION notebook DV6514TX, 320 GB HDD, 3GB RAM).  Vista has a 4gb partition, with operating set swap drive.  At the moment (48 processes, physical ram 78 %), it uses 1 gb swap disk. [Freeware: Process Explorer].  Linux is used to correct Windows crashes.</p><p>Windows is preferred because of better applications: Dragon Naturally Speaking, latest hardware, Servant Salamander, Cobian Backup, Omnipage, &#8230;.</p><p>Windows &amp; applications make use of &#8220;temp&#8221; directories.  I put all my temp folders (4 of them in Windows) on the first partition of my fastest drive.  Being a common notebook, it has only one, not counting the slow external USB drives.</p><p>Greg Zeng, Australian Capital Territory</p> ]]></content:encoded> </item> <item><title>By: Tony</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-151721</link> <dc:creator>Tony</dc:creator> <pubDate>Mon, 16 Nov 2009 21:10:46 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-151721</guid> <description>There is a lot of confusion out there about swap space and setting up the correct size. For desktop systems, you&#039;re just fine with no swap and a lot of RAM.
For server environments, it is a different story.
You see, while you never want to &lt;b&gt;use&lt;/b&gt; swap space (in the I/O sense), the system has some interesting issues that it has to deal with when handing out memory, and &lt;b&gt;the default choice Linux makes is very bad for reliable environments&lt;/b&gt;.
Here is a summary:
When a program asks for memory (via malloc, or indirectly via fork(), which has to make a copy of the running process), Linux &lt;b&gt;assumes&lt;/b&gt; that the request is larger than it really needs. This is a reasonable assumption in the majority of cases. For example, in a shell, every time you run a command, the data set of the shell itself is marked copy-on-write, and is therefore a potential memory sink if that new shell were to continue running. In reality, the next thing that happens in 99% of the cases is an exec(2), so that those potential memory drains are immediately thrown out.
Basically, in order to run with little or no swap, the kernel has to lie and tell all comers that memory is available. If that turns out to be wrong, then it KILLS whatever program ends up actually needing the memory at some future time when none is available.
The problem is that there is no way to make a memory &quot;guarantee&quot; with this policy. It&#039;s a bit like selling too many tickets for an airplane: you don&#039;t know who is going to get bumped. So, say your Java VM calls a native method that does a fork() of a 1GB process, gets a bunch of copy-on-write pages, and then starts to to touch them like made...something is going to break, and it may not be the JVM. That is the problem. If the timing is wrong, it could be your production database that gets the axe!
People talk about &quot;old&quot; or &quot;vintage&quot; UNIX systems that made you have twice the amount of swap as RAM.
&lt;b&gt;This had nothing to do with small memory systems. It had to do with guarantees.&lt;/b&gt;
Those UNIX systems were written to be very predictable in their runtime behavior, and the only way to do that is to cause memory allocation to &lt;b&gt;fail in cases where there is nowhere to store the data&lt;/b&gt;. So, the idea is this: &quot;Only tell me I can have the memory if it is really there (via RAM + swap)&quot;, but the &lt;b&gt;performance assumption&lt;/b&gt; was (as Linux assumes) that programs will ask for more than they need (which is common because of the whole fork()/exec()/copy-on-write model).
Classic UNIX &lt;b&gt;requires predictability&lt;/b&gt; (and therefore a lot of swap space), and assumes that performance will be good because no one uses all of the RAM they ask for (e.g. swapping will be infrequent).
Linux, by default, &lt;b&gt;assumes reliability&lt;/b&gt;, and hopes for good performance and behavior.
So, as an administrator of these other UNIX system, dealing with memory management goes like this: you expect to see swap in &quot;use&quot;...it means that allocations have been made against it. But it but does not mean any disk IO has happened!
What you have to do for monitoring is watch the actual swapping stats via sar or some other utility. If you are seeing swap I/O, then you need more RAM or you need fewer processes. The amount of swap &quot;in use&quot; is an almost useless number (other than if you run out, new memory allocations will fail on request).
Linux can be tuned to work in a fashion that is closer to this &quot;more reliable&quot; technique as of the 2.6 kernel line. Google on &quot;Linux Memory Overcommit&quot;. The basics are:
- Have at least 2MB + size of RAM. I&#039;d recommend the old RAM*2 number...disks are cheap. This is independent of RAM size, since what you are using swap for is guarantees, not actual storage.
- Change the Kernel parameter vm.overcommit_memory to 2 in sysctl.conf
As your systems run, watch for swap I/O, which is a little difficult and misleading.
sar -B has numbers about paging, but unfortunately, paging is how all I/O happens. The vm;eff is a good indicator (you want it to be high).
If you use a swap partition then you can directly monitor the reads/writes from/to that partition itself via sar -d.</description> <content:encoded><![CDATA[<p>There is a lot of confusion out there about swap space and setting up the correct size. For desktop systems, you&#8217;re just fine with no swap and a lot of RAM.</p><p>For server environments, it is a different story.</p><p>You see, while you never want to <b>use</b> swap space (in the I/O sense), the system has some interesting issues that it has to deal with when handing out memory, and <b>the default choice Linux makes is very bad for reliable environments</b>.</p><p>Here is a summary:</p><p>When a program asks for memory (via malloc, or indirectly via fork(), which has to make a copy of the running process), Linux <b>assumes</b> that the request is larger than it really needs. This is a reasonable assumption in the majority of cases. For example, in a shell, every time you run a command, the data set of the shell itself is marked copy-on-write, and is therefore a potential memory sink if that new shell were to continue running. In reality, the next thing that happens in 99% of the cases is an exec(2), so that those potential memory drains are immediately thrown out.</p><p>Basically, in order to run with little or no swap, the kernel has to lie and tell all comers that memory is available. If that turns out to be wrong, then it KILLS whatever program ends up actually needing the memory at some future time when none is available.</p><p>The problem is that there is no way to make a memory &#8220;guarantee&#8221; with this policy. It&#8217;s a bit like selling too many tickets for an airplane: you don&#8217;t know who is going to get bumped. So, say your Java VM calls a native method that does a fork() of a 1GB process, gets a bunch of copy-on-write pages, and then starts to to touch them like made&#8230;something is going to break, and it may not be the JVM. That is the problem. If the timing is wrong, it could be your production database that gets the axe!</p><p>People talk about &#8220;old&#8221; or &#8220;vintage&#8221; UNIX systems that made you have twice the amount of swap as RAM.</p><p><b>This had nothing to do with small memory systems. It had to do with guarantees.</b></p><p>Those UNIX systems were written to be very predictable in their runtime behavior, and the only way to do that is to cause memory allocation to <b>fail in cases where there is nowhere to store the data</b>. So, the idea is this: &#8220;Only tell me I can have the memory if it is really there (via RAM + swap)&#8221;, but the <b>performance assumption</b> was (as Linux assumes) that programs will ask for more than they need (which is common because of the whole fork()/exec()/copy-on-write model).</p><p>Classic UNIX <b>requires predictability</b> (and therefore a lot of swap space), and assumes that performance will be good because no one uses all of the RAM they ask for (e.g. swapping will be infrequent).</p><p>Linux, by default, <b>assumes reliability</b>, and hopes for good performance and behavior.</p><p>So, as an administrator of these other UNIX system, dealing with memory management goes like this: you expect to see swap in &#8220;use&#8221;&#8230;it means that allocations have been made against it. But it but does not mean any disk IO has happened!</p><p>What you have to do for monitoring is watch the actual swapping stats via sar or some other utility. If you are seeing swap I/O, then you need more RAM or you need fewer processes. The amount of swap &#8220;in use&#8221; is an almost useless number (other than if you run out, new memory allocations will fail on request).</p><p>Linux can be tuned to work in a fashion that is closer to this &#8220;more reliable&#8221; technique as of the 2.6 kernel line. Google on &#8220;Linux Memory Overcommit&#8221;. The basics are:</p><p>- Have at least 2MB + size of RAM. I&#8217;d recommend the old RAM*2 number&#8230;disks are cheap. This is independent of RAM size, since what you are using swap for is guarantees, not actual storage.<br
/> - Change the Kernel parameter vm.overcommit_memory to 2 in sysctl.conf</p><p>As your systems run, watch for swap I/O, which is a little difficult and misleading.</p><p>sar -B has numbers about paging, but unfortunately, paging is how all I/O happens. The vm;eff is a good indicator (you want it to be high).</p><p>If you use a swap partition then you can directly monitor the reads/writes from/to that partition itself via sar -d.</p> ]]></content:encoded> </item> <item><title>By: Roger Wolff</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-151098</link> <dc:creator>Roger Wolff</dc:creator> <pubDate>Sun, 18 Oct 2009 10:53:30 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-151098</guid> <description>Ram keeps getting cheaper. Disks keep getting cheaper. If you stick to the swap=2xRAM rule, you&#039;ll be spending about 1% of the value of the RAM on disk space allocated for swap. That sounds reasonable.
Although you can nowadays easily PLAN not to use any swap, someday, somehow, you&#039;ll run some app that happens to use a lot of memory, and you&#039;ll need some swap.
If you&#039;re lucky, and you&#039;ve got (enough) swap space configured the app will silently push some stuff to disk, when it needs the memory, and it will be almost-unused data, that you don&#039;t notice when it has moved to disk for a while.
If you&#039;re unlucky, you&#039;ll notice your machine becoming slow to work with. You are then faced with a choice. You can stop the application that consumes &quot;more than expected&quot; memory. Or you can suspend it and continue it later. Especially if you decide to do this last option, having the swap space means a lot.</description> <content:encoded><![CDATA[<p>Ram keeps getting cheaper. Disks keep getting cheaper. If you stick to the swap=2xRAM rule, you&#8217;ll be spending about 1% of the value of the RAM on disk space allocated for swap. That sounds reasonable.</p><p>Although you can nowadays easily PLAN not to use any swap, someday, somehow, you&#8217;ll run some app that happens to use a lot of memory, and you&#8217;ll need some swap.</p><p>If you&#8217;re lucky, and you&#8217;ve got (enough) swap space configured the app will silently push some stuff to disk, when it needs the memory, and it will be almost-unused data, that you don&#8217;t notice when it has moved to disk for a while.</p><p>If you&#8217;re unlucky, you&#8217;ll notice your machine becoming slow to work with. You are then faced with a choice. You can stop the application that consumes &#8220;more than expected&#8221; memory. Or you can suspend it and continue it later. Especially if you decide to do this last option, having the swap space means a lot.</p> ]]></content:encoded> </item> <item><title>By: valqk</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-149816</link> <dc:creator>valqk</dc:creator> <pubDate>Sat, 01 Aug 2009 10:12:40 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-149816</guid> <description>If you want to have a nice working and quick database access you should NEVER EVER get to swap usage. SWAP is SLOW and is there to save your ass when there is no memory left so that the kernel won&#039;t start killing random processes... fine tune your db to use the memory you have.</description> <content:encoded><![CDATA[<p>If you want to have a nice working and quick database access you should NEVER EVER get to swap usage. SWAP is SLOW and is there to save your ass when there is no memory left so that the kernel won&#8217;t start killing random processes&#8230; fine tune your db to use the memory you have.</p> ]]></content:encoded> </item> <item><title>By: Bala</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-149798</link> <dc:creator>Bala</dc:creator> <pubDate>Fri, 31 Jul 2009 15:59:48 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-149798</guid> <description>I have a question here, can somebody clarify me:
In real time,  we have a UNIX server which host about ~10 databases which are used by web and other applications.  Will the swap spaces be created so that the space is dedicated to one database?</description> <content:encoded><![CDATA[<p>I have a question here, can somebody clarify me:<br
/> In real time,  we have a UNIX server which host about ~10 databases which are used by web and other applications.  Will the swap spaces be created so that the space is dedicated to one database?</p> ]]></content:encoded> </item> <item><title>By: Solar Winds</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-149545</link> <dc:creator>Solar Winds</dc:creator> <pubDate>Fri, 17 Jul 2009 18:20:32 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-149545</guid> <description>According to the normal computer hardware details a processor having a Address bus of 32 bits (Which is very less for a server but for a desktop), the processor cannot use the total memory of 512MB total memory. Remove a RAM of suppose 256MB the computer will never use more then 256MB. Thus theory of
swap=2*RAM is failing.
Thus it is better to look at your usage then taking some general rules.</description> <content:encoded><![CDATA[<p>According to the normal computer hardware details a processor having a Address bus of 32 bits (Which is very less for a server but for a desktop), the processor cannot use the total memory of 512MB total memory. Remove a RAM of suppose 256MB the computer will never use more then 256MB. Thus theory of<br
/> swap=2*RAM is failing.<br
/> Thus it is better to look at your usage then taking some general rules.</p> ]]></content:encoded> </item> <item><title>By: Luis Alvaro Araujo²</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-148139</link> <dc:creator>Luis Alvaro Araujo²</dc:creator> <pubDate>Thu, 16 Apr 2009 06:37:47 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-148139</guid> <description>The amount of swap isn&#039;t relative to the amount of memory.
The amount of swap is relative to the amount of programs used!!
I have an FreeBSD 6.3 running on an old Duron 1Ghz, 256 MB RAM and although the computer has 256 MB of swap, it never used the swap because it only runs NAT, firewall, DHCP and Apache.
If I install more RAM, will I increase the size of swap space?
If I install more RAM, the swap should decrease, as more RAM will be available and less swap will be needed.</description> <content:encoded><![CDATA[<p>The amount of swap isn&#8217;t relative to the amount of memory.<br
/> The amount of swap is relative to the amount of programs used!!</p><p>I have an FreeBSD 6.3 running on an old Duron 1Ghz, 256 MB RAM and although the computer has 256 MB of swap, it never used the swap because it only runs NAT, firewall, DHCP and Apache.</p><p>If I install more RAM, will I increase the size of swap space?<br
/> If I install more RAM, the swap should decrease, as more RAM will be available and less swap will be needed.</p> ]]></content:encoded> </item> <item><title>By: Intellignix</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-147552</link> <dc:creator>Intellignix</dc:creator> <pubDate>Thu, 05 Mar 2009 11:14:41 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-147552</guid> <description>If you are running a desktop PC you WILL want to have more the amount of RAM you are using in case you need to use the hibernate feature on your computer.  As far as servers go since they are meant to stay up, if you provision them correctly you shouldn&#039;t need swap space at all.  But you should have swap just in case for safety reasons, but how much really depends on what your doing.
intelliginix.com</description> <content:encoded><![CDATA[<p>If you are running a desktop PC you WILL want to have more the amount of RAM you are using in case you need to use the hibernate feature on your computer.  As far as servers go since they are meant to stay up, if you provision them correctly you shouldn&#8217;t need swap space at all.  But you should have swap just in case for safety reasons, but how much really depends on what your doing.</p><p>intelliginix.com</p> ]]></content:encoded> </item> <item><title>By: Lirio</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-147430</link> <dc:creator>Lirio</dc:creator> <pubDate>Wed, 25 Feb 2009 06:26:16 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-147430</guid> <description>Hi guys, do you know how much RAM Redhat 9 can accomodate? I have a system which runs only with RH9 and I want to upgrade it with new hardware but I&#039;m not sure how much RAM it can detect. Redhat 9 is x86 only.
Thanks</description> <content:encoded><![CDATA[<p>Hi guys, do you know how much RAM Redhat 9 can accomodate? I have a system which runs only with RH9 and I want to upgrade it with new hardware but I&#8217;m not sure how much RAM it can detect. Redhat 9 is x86 only.</p><p>Thanks</p> ]]></content:encoded> </item> <item><title>By: IT_Architect</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-147358</link> <dc:creator>IT_Architect</dc:creator> <pubDate>Sat, 21 Feb 2009 03:01:07 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-147358</guid> <description>This same decision at present as well.
- First, high performance hard drive space is not cheap.
- Second, with server consolidation, you don&#039;t want your VMs taking up space unnecessarily.
- Third, prudent use of hard drive space yields more options for floating your virtual machines to other servers.
- Fourth, prudent sizing of hard drive space for VMs reduces backup space, bandwidth, and time requirements spent backing up to low cost drives where gigs tend to add up making them not quite so cheap if you are paying by the month from a hosting company.
- Lastly, if you run out of memory, applications will malfunction and there may be OS problems as well.  But can you actually fix that with hard disk space?
My thoughts:
1.  High-speed processes normally found on servers cannot actively swap anywhere near a gig and provide usable performance.  Unless you typically load a lot of dead wood loaded that you can park, it will be tough to leverage much space.  (Maybe a bunch of VMs that aren&#039;t doing anything.)  As server loads go up, programs that dynamically spawn processes or threads as needed require more memory because the processes run longer and thus more are needed at a time.  Swap soon ends up being a performance governor since no matter how much physical RAM you have, the amount of virtual memory you can use will be limited by the speed at which you can move memory contents between disk and RAM, and the time it takes to manage the virtual memory.  With the processor speeds vs. disk speeds today, the amount of useful virtual memory would be a pretty low number.  You may be able to limit the number of threads or processes these types of programs can spawn so as not to render other applications unusable, however, that simply passes the delay to the service requesters in the form of timeouts in the client apps.  This means the only way out is more memory and or CPU is required, and more swap space cannot help.  Thus the a diminishing ratio between RAM and swap makes sense as RAM increases.
Let&#039;s take this thought process to the next level.  At one point in time, the biggest advantage of a hard drive over a floppy drive was not speed, it was capacity.  Later, as processors and disks improved, there was a very big difference in speed.  The hard drive felt as fast as RAM.  The problem up to this point was the processor no matter how much people talked about &quot;slow speed peripherals&quot;.  I remember the president of SUN confidently stating at a keynote at a COMDEX, &quot;The 486 is the fastest CISC processor that will ever be made&quot;  That&#039;s before he knew anything about it.  His reasoning was no processor with varying length instruction sets could never be pipelined.  The 486 dropped the bomb on that supposition and could do far more at 25 MHZ than the hottest AMD 386 could do at 40 MHZ.  A CISC instruction that required 6 clock cycles could accomplish the same work that took the RISCs 200, which is why the CISC, even considering pipeline flushes, is still around today.  Ever since the 486, feeding the processor from RAM has been a major problem.  However, for the most part, all the way through the Pentium III, 512 megs of RAM is all they would support, and 256 was more common.  Things have changed a lot since then.  A few years ago AMD gave Intel in incredible beating when Intel couldn&#039;t adequately feed their processors from memory.  Intel has only recovered from that in the past year or so.  So if feeding the processor at RAM speeds is such a huge problem today, how is it that we can somehow make use of gigabytes of disk space to compensate for RAM shortages?  Either I&#039;m missing something here, or the hard drive could only help for small snippets that need to be accessed very infrequently.  Forget using the hard drive for swap, can you even imagine today&#039;s processors getting anything done without using substantial RAM for disk caching?  Is it possible that 2 times RAM was meant for the Pentium III and earlier where memory sizes and CPU speeds allowed virtual memory on the hard drive to be of practical benefit?
2.  Workstations should be able to benefit more from swap that servers.  Users cannot switch tasks 1000 times a second, thus large amounts of virtual memory can be practically used to for editing large files and parking large chunks of many programs that were loaded but doing nothing most of the time.  Swap times of 2 to 4 tenths of a second are of no consequence in an environment where user programs switch every 20 seconds or more, or the occasional search and replace on a large file takes 15 seconds to complete, or minimized Photoshop pictures that take a second to reload.
For me, I think I&#039;m going to challenge some OS developers to explain to me where all of the dead wood is coming from that they can store in swap because it surely cannot be from active processes.</description> <content:encoded><![CDATA[<p>This same decision at present as well.<br
/> - First, high performance hard drive space is not cheap.<br
/> - Second, with server consolidation, you don&#8217;t want your VMs taking up space unnecessarily.<br
/> - Third, prudent use of hard drive space yields more options for floating your virtual machines to other servers.<br
/> - Fourth, prudent sizing of hard drive space for VMs reduces backup space, bandwidth, and time requirements spent backing up to low cost drives where gigs tend to add up making them not quite so cheap if you are paying by the month from a hosting company.<br
/> - Lastly, if you run out of memory, applications will malfunction and there may be OS problems as well.  But can you actually fix that with hard disk space?</p><p>My thoughts:<br
/> 1.  High-speed processes normally found on servers cannot actively swap anywhere near a gig and provide usable performance.  Unless you typically load a lot of dead wood loaded that you can park, it will be tough to leverage much space.  (Maybe a bunch of VMs that aren&#8217;t doing anything.)  As server loads go up, programs that dynamically spawn processes or threads as needed require more memory because the processes run longer and thus more are needed at a time.  Swap soon ends up being a performance governor since no matter how much physical RAM you have, the amount of virtual memory you can use will be limited by the speed at which you can move memory contents between disk and RAM, and the time it takes to manage the virtual memory.  With the processor speeds vs. disk speeds today, the amount of useful virtual memory would be a pretty low number.  You may be able to limit the number of threads or processes these types of programs can spawn so as not to render other applications unusable, however, that simply passes the delay to the service requesters in the form of timeouts in the client apps.  This means the only way out is more memory and or CPU is required, and more swap space cannot help.  Thus the a diminishing ratio between RAM and swap makes sense as RAM increases.</p><p>Let&#8217;s take this thought process to the next level.  At one point in time, the biggest advantage of a hard drive over a floppy drive was not speed, it was capacity.  Later, as processors and disks improved, there was a very big difference in speed.  The hard drive felt as fast as RAM.  The problem up to this point was the processor no matter how much people talked about &#8220;slow speed peripherals&#8221;.  I remember the president of SUN confidently stating at a keynote at a COMDEX, &#8220;The 486 is the fastest CISC processor that will ever be made&#8221;  That&#8217;s before he knew anything about it.  His reasoning was no processor with varying length instruction sets could never be pipelined.  The 486 dropped the bomb on that supposition and could do far more at 25 MHZ than the hottest AMD 386 could do at 40 MHZ.  A CISC instruction that required 6 clock cycles could accomplish the same work that took the RISCs 200, which is why the CISC, even considering pipeline flushes, is still around today.  Ever since the 486, feeding the processor from RAM has been a major problem.  However, for the most part, all the way through the Pentium III, 512 megs of RAM is all they would support, and 256 was more common.  Things have changed a lot since then.  A few years ago AMD gave Intel in incredible beating when Intel couldn&#8217;t adequately feed their processors from memory.  Intel has only recovered from that in the past year or so.  So if feeding the processor at RAM speeds is such a huge problem today, how is it that we can somehow make use of gigabytes of disk space to compensate for RAM shortages?  Either I&#8217;m missing something here, or the hard drive could only help for small snippets that need to be accessed very infrequently.  Forget using the hard drive for swap, can you even imagine today&#8217;s processors getting anything done without using substantial RAM for disk caching?  Is it possible that 2 times RAM was meant for the Pentium III and earlier where memory sizes and CPU speeds allowed virtual memory on the hard drive to be of practical benefit?</p><p>2.  Workstations should be able to benefit more from swap that servers.  Users cannot switch tasks 1000 times a second, thus large amounts of virtual memory can be practically used to for editing large files and parking large chunks of many programs that were loaded but doing nothing most of the time.  Swap times of 2 to 4 tenths of a second are of no consequence in an environment where user programs switch every 20 seconds or more, or the occasional search and replace on a large file takes 15 seconds to complete, or minimized Photoshop pictures that take a second to reload.</p><p>For me, I think I&#8217;m going to challenge some OS developers to explain to me where all of the dead wood is coming from that they can store in swap because it surely cannot be from active processes.</p> ]]></content:encoded> </item> <item><title>By: Keld Simonsen</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-146832</link> <dc:creator>Keld Simonsen</dc:creator> <pubDate>Thu, 22 Jan 2009 00:17:42 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-146832</guid> <description>For a desktop it is very nice to have quite some swap space. I have been running a desktop which got trashing because of firefox etc, and I was using the 2 X rule of thumb. However, my firefox does not exceed sy 500 MB som 2 GB should be enough.
Another issue is to use raid for swap. If you do that, your system can survive and continue running, if one of the disks that you use for swap fails. Given that we are talking about 2 Gb partitions, which is not much on todays huge disks, you can use more than 2  disks  to use, 3 could be useful to survive 2 disk failures.
And for performance I would use the raid10,f2 or raid10,f3 layouts. The &quot;far&quot; layout of raid10 gives almost raid0 performance for sequential readning, and raid10 with the &quot;far&quot; layout is overall the best performing raid-1 like raid type.  More on linux raid can be found at http://linux-raid.osdl.org and specifically setting up a system with swap on raid on http://linux-raid.osdl.org/index.php/Preventing_against_a_failing_disk</description> <content:encoded><![CDATA[<p>For a desktop it is very nice to have quite some swap space. I have been running a desktop which got trashing because of firefox etc, and I was using the 2 X rule of thumb. However, my firefox does not exceed sy 500 MB som 2 GB should be enough.</p><p>Another issue is to use raid for swap. If you do that, your system can survive and continue running, if one of the disks that you use for swap fails. Given that we are talking about 2 Gb partitions, which is not much on todays huge disks, you can use more than 2  disks  to use, 3 could be useful to survive 2 disk failures.</p><p>And for performance I would use the raid10,f2 or raid10,f3 layouts. The &#8220;far&#8221; layout of raid10 gives almost raid0 performance for sequential readning, and raid10 with the &#8220;far&#8221; layout is overall the best performing raid-1 like raid type.  More on linux raid can be found at <a
href="http://linux-raid.osdl.org" rel="nofollow">http://linux-raid.osdl.org</a> and specifically setting up a system with swap on raid on <a
href="http://linux-raid.osdl.org/index.php/Preventing_against_a_failing_disk" rel="nofollow">http://linux-raid.osdl.org/index.php/Preventing_against_a_failing_disk</a></p> ]]></content:encoded> </item> <item><title>By: Intelliginix</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-146546</link> <dc:creator>Intelliginix</dc:creator> <pubDate>Sat, 03 Jan 2009 09:20:50 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-146546</guid> <description>I try to get enough RAM so swapping is not necessary , but depending on the size of the server I would usually have some swap space available just in case.  On servers that don&#039;t have enough physical memory swap is absolutely necessary, but again you have to calculate how much memory  your server (or workstation) is using and will need.  For instance you have a server with a database, and for performance reasons you may have databases cached in memory.  In this you would be better off have enough RAM where swapping isn&#039;t necessary during peak hours of operations. However, due to upkeep and maintenance you may have other process that run during off-time hours (for instance backups and other things) that may push the limits of your physical RAM for a period of time.  In this case swap is necessary to avoid &quot;out of memory&quot; situations.
I tend to design modularly so I good grasp on what to provision them for, and the age of virtualization has made some these easier in ways, and more difficult in others.  Good virtualization software will allow you to dictate how much memory you will use for your virtual machines (which makes it easier to manage machines running over a host OS).
I good monitoring tool also helps with the proper thresholds set to alert the admin if there is any sign of possible trouble.</description> <content:encoded><![CDATA[<p>I try to get enough RAM so swapping is not necessary , but depending on the size of the server I would usually have some swap space available just in case.  On servers that don&#8217;t have enough physical memory swap is absolutely necessary, but again you have to calculate how much memory  your server (or workstation) is using and will need.  For instance you have a server with a database, and for performance reasons you may have databases cached in memory.  In this you would be better off have enough RAM where swapping isn&#8217;t necessary during peak hours of operations. However, due to upkeep and maintenance you may have other process that run during off-time hours (for instance backups and other things) that may push the limits of your physical RAM for a period of time.  In this case swap is necessary to avoid &#8220;out of memory&#8221; situations.</p><p>I tend to design modularly so I good grasp on what to provision them for, and the age of virtualization has made some these easier in ways, and more difficult in others.  Good virtualization software will allow you to dictate how much memory you will use for your virtual machines (which makes it easier to manage machines running over a host OS).</p><p>I good monitoring tool also helps with the proper thresholds set to alert the admin if there is any sign of possible trouble.</p> ]]></content:encoded> </item> <item><title>By: Biff</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-146409</link> <dc:creator>Biff</dc:creator> <pubDate>Wed, 24 Dec 2008 03:29:32 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-146409</guid> <description>Folks, the old swap = 2x RAM dates back to when eight MEGAbytes was a lot of RAM on a multiuser system, and there was an enormous difference in $/MB between disk and RAM. Back then, you would often set up a machine using the assumption that you would be swapping to disk on a routine basis. The rule of thumb stuck, but few people understood that it was just a guideline and was not a requirement.
These days, with RAM so cheap, if you are hitting swap, just buy more RAM!
The amount of swap that you should use is entirely dependent on how the system is used. If you have lots of users running unpredictable codes, then configure more swap. If you have a reasonable RAM cushion for your system&#039;s usage pattern, you may well never touch swap. I ran a 32 GB RAM system for quite a few years using 8 GB of swap, and in all that time, the swap was never needed.
Our shop bought quite a few 1-4 GB RAM workstations from SGI over the years. They shipped pre-configured with either 128 MB or 256 MB of swap (I forget exactly which). Again, never a problem.
That said, as disks became very cheap, we started setting up new Unix workstations with 1 GB swap unless there was a specific reason that we would want to add more, and for servers, we&#039;d typically just allocate 4 GB for swap, no matter how much RAM the boxes had. This was a high-performance environment, and again, never a problem.
We also kept a close eye on system performance (including swap usage) using sar and also SGI&#039;s Performance Co-Pilot product (free for Linux, by the way), and that gave us more confidence in ignoring the traditional &quot;Rules of Thumb.&quot;</description> <content:encoded><![CDATA[<p>Folks, the old swap = 2x RAM dates back to when eight MEGAbytes was a lot of RAM on a multiuser system, and there was an enormous difference in $/MB between disk and RAM. Back then, you would often set up a machine using the assumption that you would be swapping to disk on a routine basis. The rule of thumb stuck, but few people understood that it was just a guideline and was not a requirement.</p><p>These days, with RAM so cheap, if you are hitting swap, just buy more RAM!</p><p>The amount of swap that you should use is entirely dependent on how the system is used. If you have lots of users running unpredictable codes, then configure more swap. If you have a reasonable RAM cushion for your system&#8217;s usage pattern, you may well never touch swap. I ran a 32 GB RAM system for quite a few years using 8 GB of swap, and in all that time, the swap was never needed.</p><p>Our shop bought quite a few 1-4 GB RAM workstations from SGI over the years. They shipped pre-configured with either 128 MB or 256 MB of swap (I forget exactly which). Again, never a problem.</p><p>That said, as disks became very cheap, we started setting up new Unix workstations with 1 GB swap unless there was a specific reason that we would want to add more, and for servers, we&#8217;d typically just allocate 4 GB for swap, no matter how much RAM the boxes had. This was a high-performance environment, and again, never a problem.</p><p>We also kept a close eye on system performance (including swap usage) using sar and also SGI&#8217;s Performance Co-Pilot product (free for Linux, by the way), and that gave us more confidence in ignoring the traditional &#8220;Rules of Thumb.&#8221;</p> ]]></content:encoded> </item> <item><title>By: devx</title><link>http://www.cyberciti.biz/tips/linux-swap-space.html#comment-146029</link> <dc:creator>devx</dc:creator> <pubDate>Mon, 08 Dec 2008 01:28:24 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/?p=3586#comment-146029</guid> <description>Swap is, as you know a &quot;emergency&quot; memory space: linux runs fully in the memory otherwise, until it runs out of ram. Depending on what programs you run, you may find it viable (check how much free ram you have often.) Its best to keep one in any case for emergencies (like memory leaks or whatnot).
As others said, swap is also used if you configured your kernel to make core dumps for debugging or if you plan to &quot;sleep to disk&quot;.
Some programs do cache to disk using swap but if you don&#039;t have any, most (like VIM) run fine fully within RAM. Swap is addressable by all programs for cache once running. Someone who does more memory management stuff can help you here.
In terms of need/reliability: For some machines, which have a rare/fixed amount of RAM that is a little small, its a must (hacked TiVO recorders or Playstation 2 running linux are examples, the latter with 256 and 32 MB of ram fixed. Yetch!) Certainly all machines, as long as your disk is good will continue to run stable abeit somewhat slower (if you use faster hdds or multiple swap on different drives this may be less noticable.)</description> <content:encoded><![CDATA[<p>Swap is, as you know a &#8220;emergency&#8221; memory space: linux runs fully in the memory otherwise, until it runs out of ram. Depending on what programs you run, you may find it viable (check how much free ram you have often.) Its best to keep one in any case for emergencies (like memory leaks or whatnot).</p><p>As others said, swap is also used if you configured your kernel to make core dumps for debugging or if you plan to &#8220;sleep to disk&#8221;.</p><p>Some programs do cache to disk using swap but if you don&#8217;t have any, most (like VIM) run fine fully within RAM. Swap is addressable by all programs for cache once running. Someone who does more memory management stuff can help you here.</p><p>In terms of need/reliability: For some machines, which have a rare/fixed amount of RAM that is a little small, its a must (hacked TiVO recorders or Playstation 2 running linux are examples, the latter with 256 and 32 MB of ram fixed. Yetch!) Certainly all machines, as long as your disk is good will continue to run stable abeit somewhat slower (if you use faster hdds or multiple swap on different drives this may be less noticable.)</p> ]]></content:encoded> </item> </channel> </rss>
