Databases & Storage
IOPS vs Throughput vs Latency: What They Mean and How to Test
By NileVPS Team · Published · 5 min read
اقرأ المقال بالعربيDisk performance is often summarised with a single number, but no single number tells the whole story. A storage device can move huge files quickly and still feel slow for a busy database. To understand what your server is doing, you need three measurements: IOPS, throughput and latency. This guide explains each one, how they relate, and how to measure them on a Linux VPS.
The three measurements
IOPS
IOPS means input/output operations per second: how many separate read or write requests the storage completes each second. It matters most for workloads that touch many small, scattered pieces of data, such as databases, mail servers, package installs and applications that write lots of small files. An IOPS figure is meaningless without context, because a device delivers very different IOPS for 4 KB random reads than for 1 MB sequential writes.
Throughput
Throughput (also called bandwidth) is the amount of data moved per second, usually shown in MB/s. It matters for large sequential work: copying backups, restoring snapshots, streaming media files, or scanning a big log file from start to finish.
Latency
Latency is the time a single request takes, from the moment it is issued until it completes, usually measured in microseconds or milliseconds. Latency is what users feel. A database query that needs twenty dependent reads pays the latency cost twenty times, one after another, no matter how many IOPS the disk can handle in parallel.
How they are connected
The three numbers are linked by two simple relationships:
- Throughput = IOPS x block size. 10,000 IOPS at 4 KB is about 40 MB/s; the same 10,000 IOPS at 128 KB is about 1.25 GB/s.
- IOPS is roughly queue depth / latency. If each request takes 1 ms and only one request is in flight at a time (queue depth 1), you cannot exceed about 1,000 IOPS. Higher IOPS come from more parallel requests or lower latency.
This is why vendor figures can mislead. A headline IOPS number is usually measured with many requests in parallel, while real applications often issue one request, wait for it, then issue the next. For those applications, latency at low queue depth is the number that matters.
| Workload | Most important metric | Typical access pattern |
|---|---|---|
| OLTP database (PostgreSQL, MySQL) | Latency and random IOPS | Small random reads, frequent syncs |
| Web server with static files | Mostly RAM cache, then latency | Small random reads |
| Backup and restore | Throughput | Large sequential reads and writes |
| Log processing | Throughput | Large sequential reads |
| Build servers, package installs | Random IOPS | Many small files |
Measuring your disk with fio
fio is the standard Linux tool for storage testing. Install it with sudo apt install fio on Debian or Ubuntu, or sudo dnf install fio on AlmaLinux and Rocky. Run tests in a scratch directory with enough free space, and never point fio at a raw device that holds data.
Random 4 KB reads with parallel requests (an IOPS test):
fio --name=randread --filename=/root/fio.test --size=2G \
--rw=randread --bs=4k --iodepth=32 --numjobs=1 \
--ioengine=libaio --direct=1 --runtime=60 --time_based --group_reportingRandom 4 KB writes at queue depth 1 (a latency test, closer to how a database commits):
fio --name=lat --filename=/root/fio.test --size=2G \
--rw=randwrite --bs=4k --iodepth=1 --fsync=1 \
--ioengine=libaio --direct=1 --runtime=60 --time_basedSequential 1 MB reads (a throughput test):
fio --name=seqread --filename=/root/fio.test --size=2G \
--rw=read --bs=1M --iodepth=8 \
--ioengine=libaio --direct=1 --runtime=60 --time_based--direct=1 bypasses the Linux page cache so you measure the disk rather than RAM. In the output, read the IOPS= and BW= values, and look at the clat percentiles section: the 99th percentile latency tells you more about consistency than the average does. Delete the test file afterwards with rm /root/fio.test.
Watching real usage with iostat
Benchmarks show what the disk can do; iostat shows what your workload is doing right now. It is part of the sysstat package:
sudo apt install sysstat
iostat -x 2Useful columns:
r/sandw/s: read and write IOPS.rkB/sandwkB/s: throughput.r_awaitandw_await: average latency per request in milliseconds.aqu-sz: average queue length; a value that stays high means requests are waiting.%util: how often the device was busy. On SSD and NVMe devices that handle many requests in parallel, 100% does not necessarily mean saturated, so judge by latency instead.
Pair this with top or vmstat 2 and watch the wa (I/O wait) figure. High I/O wait combined with rising await values is a strong sign that storage is your bottleneck.
Practical checklist
- Identify your workload pattern first: random small I/O or large sequential I/O.
- Test with block sizes and queue depths that match that pattern, not just the largest numbers.
- Look at tail latency (p99), not only averages.
- Give the database enough RAM so hot data is served from memory; the fastest I/O is the one that never reaches the disk.
- Re-test after changes and compare like with like: same file size, same flags, same duration.
If storage turns out to be the limit, NVMe-backed plans usually give the biggest improvement for random workloads. Our guide on choosing a VPS storage type covers the hardware side, and you can compare plan resources on the pricing page.
FAQ
Is a higher IOPS number always better?
Only if your workload can use it. An application that sends one request at a time is limited by latency, not by the maximum IOPS a device reaches with 32 parallel requests. Match the test to the way your software really performs I/O.
Why are my fio results different every time?
Shared infrastructure, background tasks, caching and test parameters all affect results. Run each test several times for at least 60 seconds, use --direct=1, and keep the parameters identical between runs before drawing conclusions.
Can I run fio on a production server?
You can, but it competes with your real workload for the same disk. Use a test file rather than a raw device, keep runs short, and schedule them for quiet hours, or test on a fresh snapshot-based copy of the server instead.