Interesting Insights in Linux Swap Configuration

I was listening to my team discuss the configuration of new virtual appliance, based on Suse Enterprise, that would be created and delivered to the customers in .ovf format.   The software engineers had requested that the size be as small as possible for delivery reasons.  One of the heated discussion items became how much swap space should be created.  There are a lot of opinions on this and much of the “knowledge” the team had pointed to about 1.5x the amount of ram allocated to the VM.  In this case, the appliance is preconfigured to use 4GB of ram so 6GB to 8GB seemed to be the answer, a disappointment because the engineers had hoped the entire appliance would be 10GB.

This interested me, because I really didn’t know the answer.  Obviously, it is very important in a consolodated server environment to size these things right because your swap space is actually very expensive SAN space.  This article and its comments was very interesting on the topic. It boiled down to this formula as the easy standard:

  1. Swap space == Equal RAM size (if RAM < 2GB)
  2. Swap space == 2GB size (if RAM > 2GB)

The later comments were pretty good though, and they pointed out that Linux may be a bit dangerous in that when you run out of swap, processes start to be killed off to free up memory.  Also, that there are use case scenarios where using swap space is OK or at the very least preferable to random processes being killed.  Another thing to worry about is if you need to collect a kernel dump and where that might be going. It gets interesting when you treat disk as an expensive resource.  At home or in dedicated server environment, disk space is pretty cheap but in enterprise virtualization, where you might spin up tens or hundreds of the same image for testing etc., disk space is really expensive!

Windows appears to be down to about 1x memory size for swap now, which is good.  I still go for 1.5x there, myself.

If you happened to be curious about what they settled on for swap space with 4GB of ram, the answer is 5GB.

–Nat

4 thoughts on “Interesting Insights in Linux Swap Configuration

  1. Dave

    TeamDave
    A blog from Iowa about the stuff Nat was talking about in the last few posts

    I didn’t understand any of it….but technically I didn’t read most of it…..I’m sure its good…..but not as good as posts about Asian Malls and Asian Texas Roadhouses.

    -Dave

  2. Nat Post author

    There will soon be more non technical blog posts. I appreciate your endorsement 🙂

    Would you like to create a really real TeamDave?

    Nat

  3. Dave

    TeamDave
    A blog from Iowa about the comment that Nat wrote in response to the blog comment I wrote about his blog.

    I don’t need a really real TeamDave blog, since I only use it to write comments about your blog. By the way, got out at 12:30 today, thank you snow!

    -Dave

Leave a Reply

Your email address will not be published. Required fields are marked *