Why Disk I/O Performance Matters on a VPS
Storage I/O is often the most contended resource on a virtual private server. While CPU and RAM are typically dedicated to your instance, disk I/O is shared across the hypervisor’s storage subsystem. Poor I/O performance leads to slow database queries, laggy web applications, and extended deployment times. This guide walks you through benchmarking your VPS disk I/O with industry-standard tools, interpreting the results, and applying optimizations that make a measurable difference.
The first step in any optimization journey is understanding your baseline. The quality of underlying storage varies significantly between VPS providers — those using NVMe with low oversubscription deliver dramatically better I/O than older SATA SSD or HDD setups. Compare providers with transparent storage specs at virtualserversvps.com.
Benchmarking Tools: fio, hdparm, and dd
1. fio — The Gold Standard
fio (Flexible I/O Tester) is the most comprehensive disk benchmarking tool available for Linux. It supports customizable I/O patterns, queue depths, block sizes, and concurrency. Install it with sudo apt install fio and run these essential tests:
Random 4K reads (IOPS test):fio --name=randread --ioengine=libaio --iodepth=32 --rw=randread --bs=4k --direct=1 --size=1G --numjobs=4 --runtime=60 --group_reporting
Random 4K writes (IOPS test):fio --name=randwrite --ioengine=libaio --iodepth=32 --rw=randwrite --bs=4k --direct=1 --size=1G --numjobs=4 --runtime=60 --group_reporting
Sequential 1M reads (throughput test):fio --name=seqread --ioengine=libaio --iodepth=16 --rw=read --bs=1m --direct=1 --size=4G --numjobs=2 --runtime=60 --group_reporting
Sequential 1M writes (throughput test):fio --name=seqwrite --ioengine=libaio --iodepth=16 --rw=write --bs=1m --direct=1 --size=4G --numjobs=2 --runtime=60 --group_reporting
Interpreting fio Results
| Metric | Good (NVMe) | Fair (SATA SSD) | Poor (HDD) |
|---|---|---|---|
| 4K random read IOPS | >50,000 | 10,000–50,000 | <500 |
| 4K random write IOPS | >30,000 | 5,000–30,000 | <300 |
| 1M sequential read (MB/s) | >1,000 | 300–1,000 | <150 |
| 1M sequential write (MB/s) | >500 | 200–500 | <100 |
| Latency (4K random, µs) | <200 | 200–1,000 | >5,000 |
2. hdparm — Quick Cache/Transfer Tests
hdparm provides a quick buffered and cached read speed test. It’s useful for a rapid sanity check but doesn’t measure random I/O or write performance, so take results with a grain of salt:
sudo hdparm -Tt /dev/vda
The -T flag tests cached reads (RAM speed), and -t tests buffered disk reads. On NVMe VPS, expect -t results above 500 MB/s. Values below 200 MB/s suggest SATA SSD or significant hypervisor contention.
3. dd — Simple Sequential Test
The classic dd command can give a rough sequential throughput estimate. While not as precise as fio, it’s available on every Linux system:
Write test:dd if=/dev/zero of=./test bs=1M count=4096 conv=fdatasync status=progress
Read test:dd if=./test of=/dev/null bs=1M status=progress
Note: dd only measures sequential access. A provider with fast sequential reads but terrible random IOPS (common on shared HDD arrays) will look good in dd benchmarks but perform poorly under real database workloads.
Optimizing Disk I/O on Your VPS
1. Choose the Right I/O Scheduler
The I/O scheduler determines how the kernel orders and batches disk requests. For NVMe drives, the none scheduler (multi-queue block layer) offers the lowest latency. For SATA SSDs, mq-deadline provides a good balance. Check your current scheduler with cat /sys/block/vda/queue/scheduler and change it temporarily with echo none | sudo tee /sys/block/vda/queue/scheduler. Make it permanent via GRUB_CMDLINE_LINUX="elevator=none" in /etc/default/grub.
2. Filesystem Selection and Mount Options
ext4 is the default choice for most Linux VPS images. It’s stable, widely supported, and offers good performance with noatime mount option to disable access time updates. Add defaults,noatime to your /etc/fstab mount options.
XFS excels at large files and parallel I/O. It’s the default on RHEL/CentOS 8+ and offers better performance for workloads with many concurrent writers. Use mount options defaults,noatime,allocsize=1m for database workloads.
btrfs with Zstd compression can improve effective throughput for compressible data (text files, logs, source code). Use compress=zstd:3 mount option. However, btrfs has higher CPU overhead and is less battle-tested than ext4/XFS on VPS.
3. Tune the Block Layer
Several sysctl parameters affect I/O performance. The most impactful are:
vm.dirty_ratio— Set to 20 (default 30) to reduce writeback bufferingvm.dirty_background_ratio— Set to 5 (default 10) to start writeback earliervm.dirty_expire_centisecs— Set to 3000 (default 30000) to flush dirty pages fastervm.vfs_cache_pressure— Set to 200 (default 100) to reclaim dentry/inode caches more aggressively
4. Database-Specific Optimizations
If your VPS runs MySQL or PostgreSQL, these additional I/O optimizations apply:
- Set
innodb_flush_method=O_DIRECT(MySQL) to bypass the page cache - Increase
innodb_io_capacityto 2000+ for NVMe (default 200) - Set
effective_io_concurrency=200(PostgreSQL) for NVMe - Place database WAL/logs on a separate disk if possible
- Use
discard=asyncmount option instead of periodic fstrim for TRIM
5. Monitor I/O Pressure
Use iostat -x 1 to monitor await (average I/O response time) and %util (percentage of time the device was busy). Values above 10ms await or 90% util indicate I/O saturation. For deeper insight, use /proc/pressure/io (Pressure Stall Information) which shows the percentage of time processes were stalled on I/O:
cat /proc/pressure/io — look at the full line. If avg60 exceeds 10%, your system is under significant I/O pressure.
Conclusion
Benchmarking your VPS disk I/O with fio gives you an objective baseline, while optimizations like the right I/O scheduler, filesystem choices, and kernel parameters can improve real-world performance by 20-40%. Remember that the most impactful factor is the underlying hardware — a VPS on NVMe with dedicated resources will always outperform shared SATA storage regardless of software tuning. For providers that offer transparent storage specifications, compare options at virtualserversvps.com.



Leave a Reply
You must be logged in to post a comment.