Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Fri Nov 21, 2003 3:59 pm 
Offline
Linode Staff
User avatar

Joined: Tue Apr 15, 2003 6:24 pm
Posts: 3090
Website: http://www.linode.com/
Location: Galloway, NJ
Your Linux machine comes with physical RAM. But, what does Linux do if it runs out of physical RAM? It swaps out some of that information in RAM to disk, usually temporarily while it uses the newly freed RAM for whatever it was doing. Your physical RAM + the size of your swap file is typically referred to as your Virtual Memory.

Not having enough physical RAM in the machine for your workload can cause Linux to constantly be swapping information in and out of the swap partition. Obviously, we don't want Linux to have to constantly swap.

On the other hand, not having a large enough swap can be much worse for performance. This is because Linux has a lot less total VM to work with. It has to swap harder and more frequently to get its jobs done.

I want to encourage everyone with a Linode to have a swap file of at least 256M (you can resize your disk images to make room). I've recently changed the suggested swap file size in the Distro wizard to 256M. I believe a lot of the problems we've encountered with disk contention is caused by Linodes with a very small swap size (64M) constantly thrashing their swap file.

Stay tuned for more performance posts!

-Chris


Top
   
PostPosted: Sat Nov 22, 2003 6:58 pm 
Offline
Junior Member

Joined: Wed Aug 20, 2003 2:13 pm
Posts: 38
Website: http://www.kotalampi.com/
AOL: r1sto
Location: Hayward, CA
caker wrote:
I want to encourage everyone with a Linode to have a swap file of at least 256M (you can resize your disk images to make room). I've recently changed the suggested swap file size in the Distro wizard to 256M. I believe a lot of the problems we've encountered with disk contention is caused by Linodes with a very small swap size (64M) constantly thrashing their swap file.

Stay tuned for more performance posts!

-Chris


If you don't have disk space available for the raw disk partition by resizing the partition, you can always create a swap file over the filesystem:

- dd if=/dev/zero of=/swap1 count=256k
(count is in the block count, not kBytes, ie 256k creates swap file of ~128MBytes)
- mkswap /swap1
- /sbin/swapon /swap1 (add this to somewhere in your rc boot files)

This probably takes a slight performance hit vs. raw partition but I haven't noticed problems with it in my linode.

Risto


Top
   
 Post subject:
PostPosted: Sat Nov 22, 2003 7:31 pm 
Offline
Senior Member
User avatar

Joined: Mon Jun 23, 2003 1:25 pm
Posts: 260
Hi,

Wouldnt it be easier to just resize the filesystem and then add the space to the swap partition.

Adam


Top
   
 Post subject:
PostPosted: Sat Nov 22, 2003 9:44 pm 
Offline
Senior Member

Joined: Wed Oct 29, 2003 12:27 pm
Posts: 50
adamgent wrote:
Hi,

Wouldnt it be easier to just resize the filesystem and then add the space to the swap partition.

Adam

Its very easy to add a swap file if you don't have the partition space. I created my Linode 64 with a 64 Mb swap and 1984 Mb main partitions. I used the defaults because I didn't know better. When I realised that I needed more swap I added a 64 Mb swap file on the main partition. That never gets close to running low. This was before we could downsize partitions. It sounds like I may be paying a small performance cost so I have two questions:

If I use the resizing utility, about how long would it take to downsize my 1984 partition to 1920 Mb? Its about 50% full.

How safe is it really? I backup the live data frequently and I'm going to try to do a total rsync backup overnight tonight but it would still be a major pita to lose everything.

Ross


Top
   
PostPosted: Sat Nov 22, 2003 9:54 pm 
Offline
Senior Member

Joined: Wed Oct 29, 2003 12:27 pm
Posts: 50
caker wrote:
On the other hand, not having a large enough swap can be much worse for performance. This is because Linux has a lot less total VM to work with. It has to swap harder and more frequently to get its jobs done.

This is really a general Linux question. I'm no expert so I'm not trying to contradict you but I would have thought if it doesn't have enough VM then the consequences would be more serious than just swapping harder and more frequently. If your physical memory plus swap is not enough to run what you're asking it to do then wouldn't things crash or simply not work? Are you talking about the effect of applications being smart enough to adjust their behaviour when they are running in limited memory?

Ross


Top
   
PostPosted: Sat Nov 22, 2003 10:03 pm 
Offline
Linode Staff
User avatar

Joined: Tue Apr 15, 2003 6:24 pm
Posts: 3090
Website: http://www.linode.com/
Location: Galloway, NJ
tetranz wrote:
This is really a general Linux question. I'm no expert so I'm not trying to contradict you but I would have thought if it doesn't have enough VM then the consequences would be more serious than just swapping harder and more frequently. If your physical memory plus swap is not enough to run what you're asking it to do then wouldn't things crash or simply not work? Are you talking about the effect of applications being smart enough to adjust their behaviour when they are running in limited memory?

You're right -- when Linux exceeds its VM, the Out-Of-Memory (OOM) Killer kicks in and decides which processes to kill to try and free up some memory. But, the OOM killer is a last resort.

What does Linux do before calling on the OOM Killer? It swaps like crazy. Linux will start to swap out more aggressively, processes have no where to go (RAM or SWAP), and you end up in a nobody-wins situation.

Having more swap means more things can be placed into the swap, without having to thrash things out (thereby consuming RAM and making matters worse) to put something else in.

-Chris


Last edited by caker on Sat Nov 22, 2003 10:30 pm, edited 3 times in total.

Top
   
 Post subject:
PostPosted: Sat Nov 22, 2003 10:08 pm 
Offline
Linode Staff
User avatar

Joined: Tue Apr 15, 2003 6:24 pm
Posts: 3090
Website: http://www.linode.com/
Location: Galloway, NJ
rko wrote:
- dd if=/dev/zero of=/swap1 count=256k
(count is in the block count, not kBytes, ie 256k creates swap file of ~128MBytes)

dd if=/dev/zero of=/swap1 bs=1M count=128

Will make a 128 MB empty file... a little easier to read.

adamgent wrote:
Wouldnt it be easier to just resize the filesystem and then add the space to the swap partition.

It depends -- perhaps they don't want to reboot a production system, or need to execute a large process.

-Chris


Last edited by caker on Sat Nov 22, 2003 10:32 pm, edited 2 times in total.

Top
   
 Post subject:
PostPosted: Sat Nov 22, 2003 10:14 pm 
Offline
Linode Staff
User avatar

Joined: Tue Apr 15, 2003 6:24 pm
Posts: 3090
Website: http://www.linode.com/
Location: Galloway, NJ
tetranz wrote:
If I use the resizing utility, about how long would it take to downsize my 1984 partition to 1920 Mb? Its about 50% full.

I'd guess less than 2 minutes.

tetranz wrote:
How safe is it really? I backup the live data frequently and I'm going to try to do a total rsync backup overnight tonight but it would still be a major pita to lose everything.

It's worked every time. But, never a bad idea to make backups.

-Chris


Top
   
PostPosted: Sun Nov 23, 2003 12:24 pm 
Offline
Senior Member

Joined: Sun Nov 02, 2003 2:05 pm
Posts: 58
Recommend a beginner template for us boots:

Would it be possible to make a capurted picture example under basic settup recommendations and put them on your webpage so we can actually see. Reason being i just tried to get my linode up as fast as possible when i got it and have no clue wether i did it with the right intent or purpose. I would like to know what it looks like for a basic example setup would be for maybe just a webserv or one that has many ips and many web pages and showing how the memory was setup in different cases. I read everything you guys post a couple times at least and then try to figure out how to apply it. So pictures and actual commands how they were used for basic setups would help me a great deal.

It is just an idea for you(I know how to capture pics in windows if that would help)
Linode is on the leading edge and is what i have been looking for for years and your skills here is above what I have ever seen or thought possible.


Top
   
PostPosted: Sun Nov 23, 2003 1:50 pm 
Offline
Senior Member
User avatar

Joined: Sun Nov 23, 2003 1:40 pm
Posts: 79
Website: http://www.whitehouse.gov/history/presidents/bc42.html
You_Wish wrote:
Would it be possible to make a capurted picture example under basic settup recommendations and put them on your webpage so we can actually see.


Can I assume you are speaking about values for the Control Panel ?

The following is what I have for my linode64 account

http://www.opencurve.org/~sunny/misc/linode.png
http://www.opencurve.org/~sunny/misc/linode2.png

Bill Clinton


Top
   
 Post subject:
PostPosted: Sun Nov 23, 2003 3:42 pm 
Offline
Senior Member

Joined: Sun Nov 02, 2003 2:05 pm
Posts: 58
Yup those pictures talk 100 times more to me then 3 pages of stuff that is over my head.


Thanks for that give me more pictures.


I love you man


Top
   
 Post subject:
PostPosted: Tue Feb 10, 2004 10:17 pm 
Offline
Senior Newbie

Joined: Tue Feb 10, 2004 9:44 pm
Posts: 6
Website: http://www.lansmash.com
Location: Brisbane - Australia
Just a little tip, never make a swap file on a file system. At least, not in a production system.

The kernel has a few more layers to go to access the swap (make calls to the filesystem) which is not what you want especially for something as time critical as swap.

If you need more swap, do it right. Resize the filesystems.


Top
   
 Post subject:
PostPosted: Wed Feb 11, 2004 1:22 pm 
Offline
Junior Member

Joined: Wed Aug 20, 2003 2:13 pm
Posts: 38
Website: http://www.kotalampi.com/
AOL: r1sto
Location: Hayward, CA
Cool_blade wrote:
Just a little tip, never make a swap file on a file system. At least, not in a production system.

The kernel has a few more layers to go to access the swap (make calls to the filesystem) which is not what you want especially for something as time critical as swap.

If you need more swap, do it right. Resize the filesystems.


I'm sure it's more effective to use raw file as swap vs. file over a filesystem but can anyone quantify the performance difference? Is it 0.5, 5% or 50% overhead or what kind of difference we are talking about? Any studies or tests done about this?

Risto


Top
   
PostPosted: Sun Aug 20, 2006 1:31 am 
Offline
Newbie

Joined: Sun Aug 07, 2005 2:16 pm
Posts: 3
caker wrote:
I want to encourage everyone with a Linode to have a swap file of at least 256M....

If possible, I'd prefer to avoid swapping entirely. Is it okay to operate without any swap space at all, assuming that all the software I run can fit into the RAM allocated to my Linode? I'm running only Linux itself, SSH, Stunnel, and a tiny web server that preallocates all its RAM. Here's my memory usage now:

Code:
  $ free -m
               total       used       free     shared    buffers     cached
  Mem:            92         51         41          0          2         21
  -/+ buffers/cache:         27         65
  Swap:          100          0        100

Thanks for you advice.


Top
   
 Post subject:
PostPosted: Sun Aug 20, 2006 7:26 am 
Offline
Senior Member
User avatar

Joined: Fri Oct 24, 2003 3:51 pm
Posts: 965
Location: Netherlands
caker wanted to encourage 256 MiB swap as opposed to the then-standard 64 MiB. These small swap spaces were thought to cause Linodes to thrash as they tried to make the best use of insufficient swap.

No swap is fine as long as you are confident that you will never come close to using all of your physical memory.

_________________
/ Peter


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group