Linux – Disk write speed much slower than read speed

hard driveiolinuxperformanceperformance-tuning

I have a VPS server (WiredTree), running CentOS.

After experiencing some performance issues I created a simple benchmark for disk read/write speed using the following script:

echo Write to disk
dd if=/dev/zero of=test1 bs=1048576 count=2048
echo Read from disk
dd if=test1 of=/dev/null bs=1048576

Here's a sample output:

[bizwayz@host perf]./benchmark
Write to disk
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 11.2601 seconds, 191 MB/s
Read from disk
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 0.789302 seconds, 2.7 GB/s
[bizwayz@host perf]./benchmark
Write to disk
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 3.69129 seconds, 582 MB/s
Read from disk
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 0.789897 seconds, 2.7 GB/s
[bizwayz@host perf]./benchmark
Write to disk
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 9.56615 seconds, 224 MB/s
Read from disk
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 0.882664 seconds, 2.4 GB/s
[bizwayz@host perf]./benchmark
Write to disk
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 3.52512 seconds, 609 MB/s
Read from disk
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 0.784007 seconds, 2.7 GB/s

My question is whether it's normal for the write speed to be so much slower than read.

Best Answer

You are running a VPS server. This means that there are other clients on your physical machine and how they use the disks impacts how you'll see read and write performance.

Typically on RAID10 you'll have about 1/2 the write rate as the read rate. But, since there are a lot of unknown variables, there could be another client doing a lot of writing to the disk and that is why you are seeing worse write speeds.

It can't hurt to open a ticket with them, but with a VPS, this is what you'll typically see. VPSes are for convenience and value, not for performance.

Edit: To be sure, caching is an issue here, but my point still applies.

Be sure to run the dd command with the fdatasync command to ensure it is actually flushing the file data to disk instead of just the memory, which the kernel does by default. ie:

dd bs=1M count=512 if=/dev/zero of=test conv=fdatasync