The Challenge
My home server uses a RAID 1 configuration. I was very disappointed in the performance and wanted to find a way to make it faster. After browsing the Internet one day, I came across news headlines that said CentOS 7 supports LVM cache. I found an old USB thumb drive and decided to take the cache challenge and see how it performs.
The Journey
Here is a simple DD test prior to enabling cache:
dd if=/dev/zero of=/tmp/1G bs=1M count=1000
1048576000 bytes (1.0 GB) copied, 6.27698 s, 167 MB/s
dd if=/dev/zero of=/tmp/1G bs=1M count=1000
1048576000 bytes (1.0 GB) copied, 5.04032 s, 208 MB/s
dd if=/dev/zero of=/tmp/1G bs=1M count=1000
1048576000 bytes (1.0 GB) copied, 3.41007 s, 307 MB/s
dd if=/dev/zero of=/tmp/1G bs=1M count=1000
1048576000 bytes (1.0 GB) copied, 2.94413 s, 356 MB/s
Average write speed: 256.5 MB/s
Time to enable caching and try to make the system perform better:
vgextend vg /dev/sdc
lvcreate -L 1G -n cache_metadata /dev/sdc
lvcreate -L 8G -n cache_vol /dev/sdc
lvconvert –type cache-pool –poolmetadata vg/cache_metadata vg/cache_vol
lvconvert –type cache –cachepool vg/cache_vol vg/original_volume_name
The write results with caching enabled:
# dd if=/dev/zero of=/tmp/1G bs=1M count=1000
1048576000 bytes (1.0 GB) copied, 3.73197 s, 281 MB/s
# dd if=/dev/zero of=/tmp/1G bs=1M count=1000
1048576000 bytes (1.0 GB) copied, 1.70449 s, 615 MB/s
# dd if=/dev/zero of=/tmp/1G bs=1M count=1000
1048576000 bytes (1.0 GB) copied, 3.91247 s, 268 MB/s
]# dd if=/dev/zero of=/tmp/1G bs=1M count=1000
1048576000 bytes (1.0 GB) copied, 2.18025 s, 481 MB/s
Average write speed: 411.25 MB/s
Conclusion:
When I originally built this machine from used parts on Amazon, I decided to reuse two old Western Digital Green drives which offer low performance and power usage. I had no idea that they would perform poorly in RAID 1. I was surprised and glad that a cheap USB flash drive helped me get a significant increase in write performance by an average of 155 MB/s. I find it fascinating how the Linux ecosystem helps people recycle old junk and put it to good use. Hooray.