Calculating filesystem stride_size and stripe_width for best performance under RAID

Published on Author gryzli2 Comments

Here is a little howto on calculating the right stride_size and stripe_width when creating new ext4 filesystem. This makes sense when you are running either on hardware or software raid under linux.

 

What is stride size and stripe width ?

These two parameters could be supplied to mkfs.ext3/ mfks.ext4, during the filesystem creation. By reading the Centos Disk Optimization FAQ (http://wiki.centos.org/HowTos/Disk_Optimization), here’s what it says:

The biggest performance gain you can achieve on a raid array is to make sure you format the volume aligned to your raid stripe size. This is referred to as the stride. By setting up the file system in such a way that the writes match the raid layout, you avoid overlap calculations and adjustments on the file system, and make it easier for the system to write out to the disk. The net result is that your system is able to write things faster, and you get better performance. To understand how the stride math actually works, you need to know a couple things about the raid setup you’re using.

 

How to calculate accurate stride size and stripe width ?

There are plenty of FAQ’s out there, which try to explain the process of accurate calculating stride size and stripe width, but most of them are little bit confusing. I will try to explain it simple, at least in a way that I was able to understand this quick.

 

Calculating accurate filesystem stride size (-E stride=)

The stride size depends on two important things:

  • Filesystem block size – This is the block size with which your filesystem was created. If you haven’t supplied any block size settings, the default value is : 4096 bytes (4K)
  • RAID chunk size – This is the chunk/extent setting on your RAID array, regardless it’s software or hardware raid.

The formula is as straight as the following:

Stride size = [RAID chunk size] / [Filesystem block size]

Here are some examples:

RAID chunk size Filesystem block size The formula with values Resulting stride size
1MB (1024K) 4K (default) stride = (1024K / 4K) stride = 256
1MB (1024K) 1K stride = (1024K  / 1K) stride = 1024

Table  – Calculating stride size based on FS block size and RAID chunk size

Calculating accurate filesystem stripe width  ( -E stripe_width=)

In order to calculate the stripe width, you will need to know the following information:

  • Filesystem stride size – The “stride size” is already calculated in the previous section
  • Number of data-bearing disks in the RAID – This number strongly depends on the type of raid you use and the number of disks in the raid

The formula for calculating the stripe width is as follows:

Stripe width = [ Stride size ] * [ Number of data-bearing disks] 

Here are the MOST mistakes when calculating Stripe width, because of non-accurate calculating the number of data bearing disks. That’s why I’ve created a table showing some good examples on Number of data bearing disks calculation table .

Type of RAID NUMBER OF DISKS (N) FORMULAfor [ Number of data-bearing disks ] (NODD) RESULTING[ Number of data-bearing disks] (NODD)
RAID 0 10 NODD = N 10
RAID 1 10 NODD = N / 2 5
RAID 5 10 NODD = N – 1 9
RAID 10 10 NODD = N / 2 5
RAID 0 4 NODD = N  4
RAID 1 4  NODD = N / 2  2
RAID 5 4  NODD = N – 1  3
RAID 10 4 NODD = N / 2 2

Table  – Calculating the number of data-bearing disks based on RAID type and Number of DISKS in array

Now that we know our NODD (Number of data-bearing disks), we can proceed with calculating the stripe width :

Stripe size RAID TYPE Number of DISKS in the RAID Number of data-bearing disks[NODD] Stripe width
256 RAID10 10 5 256 * 5 =1280
256 RAID5 4 3 256 * 3 =768

Table  – Calculating stripe width based on RAID TYPE, Stride size and number of disks

 

Link everything together – The BIG example table

The following table contains two examples of Raid 0 and Raid 10, with 4 Raid Disks, using 1MB as a RAID chunk/extent size, and also creating filesystem with block size of 4K (the default one).

 

Filesystem block size RAID Type RAID Chunk size RAID Disks Stripe Size Stripe Width mkfs command
4K  RAID10  1MB 4  256 512 mkfs -E stride=256,stripe_width=512
 4K RAID5  1MB 4  256  768 mkfs -E

stride=256,stripe_width=768

 

asdasdasd

2 Responses to Calculating filesystem stride_size and stripe_width for best performance under RAID

  1. I have a RAID 10 array with three active raid disks and zero spares. The layout is n2. So by your logic above, the number of data bearing disks is 3/2.

    My RAID chunk size is 512 kiB and the filesystem block size is 4 kiB. So I have stride=128 and NODD=3/2. Is my stripe_width in this case 192? Just confirming since NODD is not an integer.

  2. Hi,
    I’m not sure if I correctly understand you, but I suppose your RAID10 was meant to be with 6 disk (if you have good spares), but currently it is using only 3 (without spares) , so it is basically RAID 0.
    In this case your NODD is 3 ( not 3/2 ).

    So the correct answer should be: [Stride Width] = 3*128 => 384

    Hope that helps.

Leave a Reply

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

Captcha * Time limit is exhausted. Please reload CAPTCHA.