How to Benchmark VPS Disk I/O with fio Before Hosting a Database

How to Benchmark VPS Disk I/O with fio Before Hosting a Database

A database lives or dies by its disk. Queries, indexes, and write-ahead logs all become small random reads and writes, so a VPS that looks fine on paper can still slow down MySQL or PostgreSQL. That is why you should benchmark VPS disk IO with fio before you install anything. A ten-minute test tells you whether the storage can keep up, or whether you need a different plan.

fio is the standard tool for this job. It is free, it runs on any Linux VPS, and it reports the two numbers that matter for databases: IOPS and latency. A fio disk benchmark takes about ten minutes and walks you through four tests that mirror real database traffic, how to read the output, and how to decide what to do with the results.

Why disk speed matters more than CPU for a database

Most VPS buyers compare vCPU counts and RAM first. Those matter, but a database spends much of its time waiting on storage. Every uncached query reads from disk, every commit writes to the log, and every checkpoint flushes pages back to storage. When the disk is slow, queries queue up behind each other and response times grow even while CPU usage stays low.

Shared VPS storage makes this worse. Your virtual disk usually sits on a host machine shared with other tenants, so the speed you get depends on what your neighbours are doing. The only way to know what you actually bought is to measure it yourself, on your own VPS, under conditions close to your real workload. See how to choose VPS specs for RAM, CPU, and storage before picking a plan, then benchmark the one you have.

Install fio and prepare a clean test directory

Install fio from your distribution repository. On Debian and Ubuntu, run:

sudo apt update && sudo apt install fio -y

On AlmaLinux or Rocky Linux, use sudo dnf install fio -y instead.

Create a test directory on the same filesystem where the database will live. If your database data directory will sit on /var/lib/mysql or /var/lib/postgresql, test there, not on a different mount. Disk performance can differ between mounts, so testing the wrong one gives you a misleading answer.

Run the tests on an idle server with a few gigabytes free. A backup job or another tenant’s burst can skew the numbers, and a 1 GB test file needs spare room so the filesystem does not fill up mid-run.

How to benchmark VPS disk IO with fio: the four tests that matter

Databases do not read large files one after another. They read and write small blocks, often 4 KB or 8 KB at a time, in random order, with several operations in flight at once. Your benchmark should copy that pattern. These four tests cover the shapes that matter, and each one takes about a minute.

Random read: the SELECT test

Random reads are what a database does when it looks up rows through an index or scans pages that are not in memory. Run:

fio --name=randread --ioengine=libaio --rw=randread --bs=4k 
  --size=1G --numjobs=4 --iodepth=32 --runtime=60 --time_based 
  --direct=1 --group_reporting

The important flags are --bs=4k for the small block size, --numjobs=4 for four parallel workers, --iodepth=32 for queued operations, and --direct=1 so the test bypasses the page cache and measures the disk itself. Without direct=1, reads come from RAM and the numbers flatter the disk.

Random write: the INSERT and UPDATE test

Random writes mirror inserts, updates, and index maintenance. The command is the same shape with --rw=randwrite:

fio --name=randwrite --ioengine=libaio --rw=randwrite --bs=4k 
  --size=1G --numjobs=4 --iodepth=32 --runtime=60 --time_based 
  --direct=1 --group_reporting

Writes usually run slower than reads on shared storage. A large gap can point to a disk without a fast write cache or a host that throttles write bursts. If you run a write-heavy workload, this is the test to watch most closely.

Mixed read and write: the closest match to real traffic

Real databases read and write at the same time, so add a mixed test with --rw=randrw and a read/write split:

fio --name=randrw --ioengine=libaio --rw=randrw --rwmixread=70 
  --bs=4k --size=1G --numjobs=4 --iodepth=32 --runtime=60 
  --time_based --direct=1 --group_reporting

The --rwmixread=70 flag sets the mix to 70 percent reads and 30 percent writes, a reasonable starting point for many web applications. Adjust the split if your workload leans one way.

Sequential write: the backup and log test

Sequential writes matter for backups, transaction logs, and bulk imports. They are usually much faster than random writes. Run:

fio --name=seqwrite --ioengine=libaio --rw=write --bs=128k 
  --size=1G --numjobs=1 --iodepth=16 --runtime=60 --time_based 
  --direct=1 --group_reporting

The larger block size and single job reflect how log writes and backups actually behave. Compare it with the random-write result to see how much the disk depends on access patterns.

Save the tests as a reusable fio job file

You will want to repeat the same test later, so put the fio randread randwrite tests in one job file, such as ~/db-disk-test.fio:

[global]
ioengine=libaio
bs=4k
size=1G
numjobs=4
iodepth=32
runtime=60
time_based
direct=1
group_reporting

[randread]
rw=randread

[randwrite]
rw=randwrite

[randrw]
rw=randrw
rwmixread=70

[seqwrite]
rw=write
bs=128k
numjobs=1
iodepth=16

Run it with fio ~/db-disk-test.fio. The file documents exactly what you tested, so today’s result stays comparable with next month’s.

How to read fio output: IOPS, bandwidth, and latency

fio prints one result block per job. Look for IOPS, bandwidth, and latency. A typical read result looks like this:

read: IOPS=..., BW=... MiB/s
  lat (usec): min=..., max=..., avg=..., stdev=...
  clat percentiles (usec):
    | 50.00th=[...], 95.00th=[...], 99.00th=[...]

A vps disk iops test starts with IOPS, the count of small operations per second. Bandwidth is how much data moves per second. For a database, IOPS matters more, because the workload is many small operations, not a few large ones.

Database disk latency is the number most people skip, and it is the one your users actually feel. The avg value is the mean wait per operation. The 95th and 99th percentile values show what the slowest few percent cost: a low average with a high 99th percentile means most queries are fast but some stall badly. For database work, pay more attention to the 95th and 99th percentile latency than to the average. See diagnosing a slow VPS with htop, iotop, and vmstat to confirm the same bottleneck once the database is running.

What counts as good enough for a database

There is no single IOPS number that means “good”: the right answer depends on your workload. Use the results to answer three questions instead.

First, is latency low and stable? High or jumpy 99th percentile latency is a warning sign even if the average looks fine.

Second, does the disk hold up under parallel load? If the numbers collapse when several workers run at once, the VPS will struggle when the database, the web server, and a backup all hit the disk together.

Third, is the result consistent? Run the same job file twice, a few minutes apart. Big swings suggest noisy neighbours on a shared host, and that variability will follow you into production. If the results are poor or unstable, consider a plan with faster storage or a separate database server. How to test VPS disk and network speed helps you sanity-check the numbers first.

Common mistakes that make fio results useless

Most bad benchmarks come from a handful of avoidable errors. Check your own run against this list before you trust the numbers.

  • Forgetting direct=1. Without it, reads come from the page cache and the test measures RAM, not disk.
  • Testing a file smaller than RAM. Use at least 1 GB; a smaller file can sit entirely in cache.
  • Testing the wrong mount. Results from /tmp or the root partition say nothing about the disk your database will use.
  • Running the test on a busy server. A backup, a cron job, or another tenant’s burst during the test pollutes the result.
  • Running only one test. A single sequential read tells you almost nothing about database traffic. Run all four tests.
  • Keeping the test files. Delete them with rm when you are done.

What to do after the benchmark

Save the fio output with the date, plan, and provider name as your baseline. If the database feels slow in three months, re-run the same job file: dropped numbers are evidence to show your provider.

If the numbers look healthy, install the database. Pick the engine that fits your workload first: MySQL vs PostgreSQL on a 2 GB VPS breaks down the trade-offs for small servers, and the PostgreSQL 17 installation and tuning guide covers the setup and the settings that matter once it is running.

A ten-minute fio run will not predict every production problem, but it catches the most expensive one: a disk that cannot keep up, discovered only after migration. Test before you host, and let the numbers decide whether the VPS is ready for your database.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.