Table of Contents
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|