VPS Disk I/O Testing Methods – Real I/O Detection Tools for VPS

VPS io test
VPS io test

The performance of a VPS host is directly influenced by the quality of its disk I/O.

When it comes to testing the performance of a VPS host, there are many script tools available that can quickly test the CPU, memory, bandwidth, and other aspects of the VPS host.

However, many users have reported significant variations in the results of disk I/O tests conducted using these script tools. Some even discovered that the purchased VPS host had very low IO performance, which severely impacted its overall performance, only after setting up their websites.

This article aims to share some real I/O detection tools for VPS hosts: DD, hdparm, Sysbench, and FIO.

I. DD Command Tool

The DD command is as follows:

dd if=/dev/zero of=test bs=8k count=256k conv=fdatasync
dd if=/dev/zero of=test bs=64k count=4k oflag=dsync

The difference between conv=fdatasync and oflag=dsync is as follows:

The sync function simply puts all modified block buffers into the write queue and returns. It does not wait for the actual disk write operations to complete.

The fsync function only works on a single file specified by the file descriptor filedes and waits for the disk write operations to complete before returning.

Therefore, performing I/O read/write tests without caching provides the actual disk read/write speed. Generally, anything below 30MB/s is considered slow.

II. Hdparm Tool

Hdparm is a command-line program for Linux used to set and view hardware parameters of ATA hard disk drives and test their performance.

First, install it:

yum install hdparm -y
apt install hdparm -y

Then identify the current hard disk:

fdisk -l

Now, you can start the test. The command is as follows:

sudo hdparm -tT /dev/sda2

The test result will be displayed as shown in the figure:

III. Sysbench Tool

Website:
https://github.com/akopytov/sysbench
Sysbench is a stress testing tool that can test the hardware performance of a system and also be used for benchmarking databases.

Sysbench supports various tests, including CPU performance tests, memory allocation and transfer speed tests.

First, install it:

sudo apt install sysbench

Then generate the necessary test files. After completion, many small files will be created in the current directory.

sysbench --test=fileio --num-threads=20 --file-total-size=1G --file-test-mode=rndrw prepare

To execute the test:

sysbench --test=fileio --num-threads=20 --file-total-size=1G --file-test-mode=rndrw run

After the test is completed, you can view the relevant read/write speeds.
To clean up the generated files during the test:

sysbench --test=fileio --num-threads=20 --file-total-size=1G --file-test-mode=rndrw cleanup

IV. Fio Testing Tool

Fio is an open-source IOPS testing tool for Linux primarily used for stress testing and performance verification of disks.

It can generate multiple threads or processes to perform user-specific types of I/O operations. Testing actions can be executed by writing job files or direct commands. It is a multi-threaded I/O generation tool used to generate various IO patterns to test the performance of disk devices.

First, install it:

sudo apt install fio


Read test command:

fio --name TEST --eta-newline=5s --filename=temp.file --rw=read --size=2g --io_size=10g --blocksize=1024k --ioengine=libaio --fsync=10000 --iodepth=32 --direct=1 --numjobs=1 --runtime=60 --group_reporting


Write test command:

fio --name TEST --eta-newline=5s --filename=temp.file --rw=write --size=2g --io_size=10g --blocksize=1024k --ioengine=libaio --fsync=10000 --iodepth=32 --direct=1 --numjobs=1 --runtime=60 --group_reporting


Random read/write test command:

fio --name TEST --eta-newline=5s --filename=temp.file --rw=randrw --size=2g --io_size=10g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --direct=1 --numjobs=1 --runtime=60 --group_reporting

The explanations for the command options are as follows:

-rw=randwrite: Read and write mode, with random write testing. Other modes include sequential read (read), sequential write (write), random read (randread), mixed read/write, etc.
-ioengine=libaio: libaio refers to asynchronous mode. If it’s synchronous, sync should be used.
-direct=1: Indicates whether to use directIO.
-thread: Uses pthread_create to create threads. The alternative is using fork to create processes. Processes have higher overhead compared to threads, so thread testing is generally preferred.
-numjobs=1: Each job represents 1 thread. The number specified here determines how many threads will be used for each task specified with -name. Therefore, the total number of threads is equal to the number of tasks multiplied by numjobs.
-iodepth=64: The queue depth is set to 64.
-filename=/dev/sdb4: The data will be written to /dev/sdb4, which is a block device. It can be a filename, partition, or SSD.
-size=10G: Each thread will write 10GB of data.
-name=job1: The name of a task. The name can be chosen arbitrarily, and it’s okay to have duplicate names.
-offset=0MB: Writing will start from the offset address of 0MB.
-bs=4k: Each Block I/O (BIO) command will contain 4KB of data. This is typically set for 4KB IOPS testing.
-output TestResult.log: The log will be output to TestResult.log.

V.Conclusion

When testing the I/O of a hard disk, you can also use the command to monitor the disk’s load.

The command is: iostat -x 1 10.

If it’s not installed, you can execute: yum install sysstat.

The main metrics to look at are %util and %idle. If %util approaches 100%, it indicates that there are too many I/O requests and the I/O system is overloaded. If %idle is less than 70%, there is significant I/O pressure, and there is likely a high wait time for read operations.

The tools DD, Hdparm, Sysbench, and FIO may produce different results.

The DD command is more intuitive but may not be highly accurate. Sysbench and FIO are comprehensive testing tools that provide a holistic understanding of the disk’s I/O performance, and they are recommended for use.

Share on:

Leave a Comment