3

In follow-up to this previous question (and it's excellent answer), I am curious to know if running swap on a RAID5 might not be better than on a RAID10.

My thinking is that you might lose a bit on the performance because it wouldn't be purely striped, but if a drive goes down you can rebuild it from the missing parity bit.

Perhaps that doesn't make sense, and stripe-and-mirror would be better.

Expansion

Thanks for the comments regarding buying more RAM - however, please note that that is not what this question is about. For the sake of this question, you can presume that the system has already been maxed. I am fully aware of the preference for "real" memory vs "virtual" memory.

Several environments expect or require swap to be configured (one of note is the system I work most heavily with that requires a swap segment at least equal to the physical on the machine for the environment to be supported by the vendor). It is, therefore, prudent to consider the *best way to implement swap for such an environment.

warren
  • 17,829
  • 23
  • 82
  • 134
  • Yikes, swap equal to the RAM? Even Oracle has stopped recommending you create any more swap than 16GB. – sciurus Apr 30 '11 at 21:46
  • @sciurus - yes: it's a requirement for both the Oracle instance for the tool, and the tool itself (if not hosted on the same server) – warren May 01 '11 at 02:50
  • 1
    On a laptop (or desktop for that matter) if you plan to use hibernate under Linux than you need at least RAM-size-and-more as it doubles as the hibernate storage are that Windows keeps a separate file for. Though of course the RAID10/RAID5 question is unlikely to be relevant to a laptop... – David Spillett May 01 '11 at 20:27
  • [This answer](https://unix.stackexchange.com/a/144597/194822) suggests that it does not make any difference, as the kernel bypasses "all caching, metadata and filesystem code layer". See Andrew Mortons [comment](https://lkml.org/lkml/2005/7/7/326) on LKML.org. It's probably different with hardware RAID though. – Holger Böhnke Sep 23 '18 at 19:35

4 Answers4

6

It makes no sense no, R10 would be better, but you should really try to have enough real memory to not have to care.

Chopper3
  • 100,240
  • 9
  • 106
  • 238
4

As the others have said, buy more ram. However Chopper3's answer is not exactly correct.

Given that both provide fault tolerance, and leaving aside capacity, the reason for choosing one over the other would be all about performance - and that depends on the workload. For a system with few processes but big memory requirements (e.g. AI engines, FEA) then you want fast bandwidth - raid 5. For a system with a lot of context switching it's about reducing latency - hence raid10.

symcbean
  • 19,931
  • 1
  • 29
  • 49
  • 1
    there *does* come a time when you cannot just add more RAM - perhaps you've hit the capacity of the system (whether it's 32G in a desktop or 512G in a server) – warren Apr 30 '11 at 04:41
  • 2
    Then you could leverage an SSD drive... – ewwhite Apr 30 '11 at 18:45
  • 2
    if your RAID 5 has a failed drive, the rebuild process can kill your I/O performance in general. And on a swap usage, that would be very painful! – tegbains Apr 30 '11 at 20:39
3

Buy more RAM, or at least enough to cover your application's needs. You shouldn't worry about the speed of swap unless you plan on swapping often. You shouldn't plan on swapping often... Either way, RAID 10 is the better option.

ewwhite
  • 194,921
  • 91
  • 434
  • 799
2

For swap space I would not recommend RAID5. There is a write performance issue with RAID5 that particularly affects workloads that involve many small writes, because every updated block potentially involves an extra read so that the controller can correctly compute the new parity block [on a 3-drive (or 3-plus-hot-spare) R5 array each each stripe has three blocks, two for pure data and one for parity information]. Neither 3-drive RAID10 (not one of the standard arrangements but supported by Linux's software RAID and some hardware controllers, IBM's controllers call it RAID1E).

Of course if you do not actually expect the swap to be used for anything other than holding a few pages that haven't been accessed for days (so they are swapped out to make room for cache/buffers or other more active use), this is all moot and you should just go for what-ever arrangement is right for the rest of your expected workload.

Summary of the options:

Arrangement         Reads              Writes                             Space        Redundancy
--------------------------------------------------------------------------------------------------------------------------------------------------------------
RAID5 (3 or 3+hs)   Similar to RAID0   Often slower than bare drives      2 drives     Can survive one drive failing
RAID10 (4 drives)   Varies**           Usually similar to bare drives**   2 drives     Can survive one drive failing and 4 of the 6 "two drive" failure cases
RAID10 (3 drives)   Varies**           Usually similar to bare drives**   1.5 drives   Can survive one drive failing

** RAID1's reads are usually assumed to be around the same performance as bare drives, though an intelligent controller can improve this for both sequential and random access depending on workload pattern and array layout (the Linux RAID10 driver offers a number of layouts that can sometimes offer RAID0 like performance for some workloads). Similar for writes which are usually similar to writes to single drives. Some of the layout options for improving read performance can impact write performance (by increasing the number of head movements required or their average distance) so use the advanced options with care.

David Spillett
  • 22,534
  • 42
  • 66