SSD for swap on Ubuntu server

11,182

Solution 1

Are you hitting swap? Generally, the better solution is to avoid that entirely, or at least make it so that things which are swapped out are genuinely not in active use, so that the speed doesn't matter. Put your money into more RAM.

This is particularly true because while high-end SSD drives may improve performance, cheap ones are very troublesome in this regard.

There is a great article on this week's Linux Weekly News which I highly recommend reading: http://lwn.net/Articles/428584/. The summary is that cheap drives are very, very sensitive to access patterns, and Linux isn't currently designed to match that well. Worse, the drives don't really expose that information in a useful way, so Linux can't necessarily do the right thing. The best best is to use them with their pre-existing FAT32 filesystems, which are factory-configured to match the drive's expectations.

Or else you should buy expensive high-performance SSDs — but only when you're already maxed out on RAM. (And really, at that point, you might strongly consider just getting a newer server which supports more RAM.)

Solution 2

Yes. There are several advantages to using SSD for swap file.

90% of data accesses are to 10% of the data. Data sets often do not fit into ram. If you are hitting the swap file, the reads and writes against the swap file can either be against a hard disc with a spinning platter or against an SSD.

Hard discs have a ~150/second limit on read/write operations per second because of seek time for the mechanical head, where as a $200 128 GB SSD can perform over 5000 IO ops per second.

Almost everyone here has said "BUY MORE RAM!!!" but unfortunately, server ram (double buffered ECC) costs 3x as much as commodity/consumer ram. For certain types of usage patterns, there is a clear price/performance advantage of SSD over ram.

SSD drives do not require installing an expensive 4 socket motherboard that supports 512 GB of expensive ECC. SSD drives are cheap and easy to add to commodity servers for storing database files or using as swap partitions.

If a $200 128 GB SSD swap partition improves performance by even 50% on a $2000 server, it is cost effective. However, you should max out the ram on the server first, given how in-expensive RAM is today.

However, the advantages of SSD for swap file usage heavily depend on your swap file patterns.

Summary: If you are doing many random access reads and few writes, you will see a large performance improvement from SSD over hard disc.

Solution 3

Ram currently costs around 10-20 GBP/Gb, SSDs are 20-40 GBP/Gb - SSD is slower than RAM and wears out faster. Can you see where I'm going with this?

64Gb is a lot of swap. How much do you actually use? Why?

Solution 4

Do you actually use the swap? If so, you'll see a speed improvement using an SSD. The more you swap, the more benefit you'll see.

However I'd look at buying more RAM first.

Share:
11,182

Related videos on Youtube

grs
Author by

grs

Updated on September 17, 2022

Comments

  • grs
    grs over 1 year

    Currently I am reading SSD reviews and I wonder how much exactly I will benefit if I move the 24 GB swap from 7200rpm HDD to SSD. Does anyone implemented swap space on SSD? Is this generally good idea?

    On a side note: I read that ext4 has much better performance if the journal is on SSD. Anyone with such a setup?

    Thanks!

    Edit: Here I will answer the questions posted: Occasionally, relatively rare I am hitting the swap. I know what the swap is for and that is better to get more RAM. When the server begins to swap its performance degrades (not a surprise). The idea is if I have few memory hungry processes running, to improve the overall system performance at that time, using SSD for swap, instead of slower rotational media. At the end - I want to be able to login faster and check the server state during swapping, instead of waiting on the login prompt. And of what I see SSD is cheaper per GB than RAM.

    Would I have better server performance during swapping (as rare it is) using SSD compared to HDD? Where 10k or 15k rpm HDDs would rate in this scenario?

    Thank you all for your quick and prompt answers!

    • EEAA
      EEAA about 13 years
      If you're using enough swap to cause you to consider switching it to an SSD, you're doing something wrong. IMHO (and many others), swap is purely there as a safety net, no more, no less.
    • ThatGraemeGuy
      ThatGraemeGuy about 13 years
      I don't think using SSD for swap is money wisely spent. You're better off adding more RAM. As Erik says, if you are using swap enough that you think there may be benefit in moving it to SSD, something is very, very wrong.
    • Silverfire
      Silverfire over 12 years
      if you put your entire system on a SSD then you may get an improvement but it depends on the distro. some distros boot sequences are not threaded so hdd speed does not help (starts one program and waits for it to finish before starting the next, this is the default behavior of sysvinit, this does not happen with OpenRC). Ive herd some good results from programs that reduce random IO seeks by placing the boot programs in order on the HDD, cant remember the name of it though.
    • Sheldon Ross
      Sheldon Ross over 12 years
      Wow talk about shortsighted people. Yes a SSD will help with swap, although you should over provision it as much as possible. And to those saying more RAM, 32gb is just about the limit per cpu right now. We do statistical analysis of millions of records, and often use upwards of 50gb swap + 32gb RAM. So saying "more RAM" is not always the answer.
    • Thomas Berger
      Thomas Berger over 11 years
      Even if you use SSD fpr swap, its still swap. The kernel have to copy the content to memory to serve it to the requesting progress.
  • grs
    grs about 13 years
    Where this numbers came from? What I see is: Kingston 12.0 GB DDR3-1333 (3 x 4.0) Kit = $300, Intel X25-E Extreme (Ephraim) SSDSA2SH032G1 2.5" 32GB SATA II SLC Internal Solid State Drive (SSD) - OEM = $375.
  • slashdot
    slashdot about 13 years
    RAM will perform far better than a SSD for a number of reasons, one od which is of course much larger bandwidth that RAM has over SATA. While price differences may be arguable, I do not think that performance is really an apples to apples comparison. Swap is swap, you actually have to basically max out RAM (normally) to begin swapping. Plus, SSDs wear out, especially when you use one to swap data in and out. RAM does not have that tendency.
  • Daniel Lawson
    Daniel Lawson about 11 years
    A point about the LWN article: it is looking at the SDHC and CF type flash devices, not at SSDs. Even "cheap" modern SATA SSDs will perform substantially better than the devices talked about in the article.
  • mattdm
    mattdm about 11 years
    That's not entirely true. Read more carefully. Tht said, the information is now over two years old.
  • Daniel Lawson
    Daniel Lawson about 11 years
    I read it again, and it's true enough. But you're right - the information (and this thread) is old now. My comment was simply to provide some modern balance to an old thread.