## 3 Algorithms to Improve the Data Write Rate
### Data Write Performance Tests Using Binary Formats
#### 3.2.5 Approach 4. Multidrive Write
Finally, the entire dataset was written into multiple equal-sized 512 MB files located in order across the three drives, resembling RAID 0 technology. A simple algorithm was implemented to ensure that, at any given time, only one file was written into a drive. This implementation aims to prevent the reduction in write performance caused by parallel writing, as discussed in Approach 3. Consequently, this approach resulted in an excellent write performance, with an average rate of 472 MB/s, which is the summed write rate of all three drives. This approach provides a solution that offers a high write performance of RAID 0 while addressing all its drawbacks, as follows:  
* Maintain all the existing data on the hard drives. * The configuration is flexible, allowing the addition or removal of a hard drive without affecting the existing data. * Data on the remaining drives are still accessible if one of the drives is damaged. * The use of hard drives with similar write rates is recommended, although the same capacity is not necessary. During the test, we observed that initially, when all three drives were operating, the overall rate equaled the sum of their individual write rates. However, HDD #3, which had the slowest write rate, required more time to complete its tasks. Consequently, the overall write rate decreased to align with that of HDD #3. To address this issue, solutions can be implemented to distribute workloads based on the write rates of each drive, as outlined below. **Solution 1: Utilizing three separated buffers, each configured for a specific drive. ** As mentioned above, the average data write rates for the three drives were 162, 172, and 138 MB/s, respectively. To ensure that all the drives can finish their work concurrently, an equal ratio of the buffer size to the write rate on each drive is required. The expected buffer size, for example, 512 MB, can be used as a reference; therefore, the buffer sizes for each drive can be configured as 482, 512, and 410 MB, respectively. The best drive, HDD #2, was assigned an expected buffer size of 512 MB, which helped minimize the workload on the other two drives, #1 and #3, which had lower write rates. To save memory, it is possible to use only one 512 MB buffer instead of three separate buffers. However, this method is complex. Accordingly, Step 3 in this approach is tailored for the writing turn of each drive, as follows: Read values from the data pack and then copy them to the buffer. Once the buffer reaches the designated value for the current drive (482, 512, or 410 MB), copy these values to a data block. **Solution 2: Multiplying the work on good drives. ** This solution is suitable when a significant difference exists in the write rates of the drives. For instance, let us assume that the write rate of drive #1 is almost the same as that of drive #2 but is approximately twice that of drive #3. In this scenario, the workloads for drives #1 and #2 should be twice that of drive #3. For this purpose, in Step 1, five folders are selected as the drives in the following order for the write cycle: (#1)-(#2)-(#3)-(#1)-(#2). Distributing the workloads based on the write rates of each drive ensures that the maximum write rate is always achieved; however, the solutions are somewhat complex. To simplify this process, the use of drives with similar write rates is recommended. Approach 4 allows for data to be written across multiple drives, resulting in a combined write rate, which is the sum of the write rates of all the drives. A configuration log file should be created to store the parameters, options, and settings for each measurement and provide sufficient information to gather individual files and combine them into one large file containing the entire measurement. Alternatively, each data file could be read independently. In addition, a configuration log file can provide an algorithm for converting binary data files into text formats. This approach facilitates data storage rates of hundreds of MS/s using HDDs and even higher rates when more drives are used.