Linux Internals
What Is Server I/O and Why It Decides Your VPS Performance
By NileVPS Team · Published · 5 min read
اقرأ المقال بالعربيMany slow servers are not short of CPU at all. The processor sits mostly idle while requests pile up, because the application is waiting for data: a database page from disk, a reply from another service, or a log write that must be flushed. That waiting is I/O (input/output), one of the most common reasons a site feels slow on a VPS that looks healthy. This guide explains what I/O is, how Linux handles it, how to measure it and how to fix it.
What counts as I/O
I/O is any transfer of data between the CPU and memory on one side and the outside world on the other:
- Disk I/O: reading and writing files, database pages, logs, swap.
- Network I/O: receiving requests, sending responses, talking to a database or API over TCP.
- Other devices: terminals, pipes between processes, and in virtual machines the virtual disk and network adapters provided by the hypervisor.
The reason I/O matters is scale. Reading from RAM takes on the order of a hundred nanoseconds. A read from a fast NVMe SSD takes tens of microseconds, a spinning hard disk needs several milliseconds to seek, and a network round trip to another continent can take a hundred milliseconds or more. A CPU can execute millions of instructions in the time it waits for one slow I/O operation.
How Linux handles I/O
When a program calls read() on a file, the kernel first checks the page cache, the part of RAM holding recently used file data. A cache hit returns immediately. A miss sends a request through the filesystem and the block layer to the storage device, and the process sleeps until the data arrives.
Writes usually land in the page cache first and are marked as dirty pages, which the kernel flushes to disk in the background. That makes writes look fast, until an application calls fsync() to guarantee durability, as databases do on every commit. Then it must wait for the device.
Blocking and non-blocking I/O
With blocking I/O, the thread stops until the operation completes. Servers that need to handle many clients at once use non-blocking I/O and an event loop, letting the kernel report which sockets are ready. On Linux this is done with epoll, explained in our article epoll explained. Newer interfaces such as io_uring extend asynchronous handling to disk operations as well.
Key metrics to understand
| Metric | Meaning | Where to see it |
|---|---|---|
iowait (wa) | Share of time the CPU was idle while I/O was pending | top, vmstat |
| IOPS | Read/write operations per second | iostat (r/s, w/s) |
| Throughput | Megabytes per second transferred | iostat (rkB/s, wkB/s) |
| Latency | Average time per request | iostat (r_await, w_await) |
| Utilisation | Share of time the device was busy | iostat (%util) |
| Blocked tasks | Processes in uninterruptible sleep, usually waiting on disk | vmstat column b |
Interpret them together. High iowait means processes are waiting on I/O, but it does not say which device or why. Note that %util near 100% is less conclusive on SSDs and NVMe drives, which serve many requests in parallel; rising await values are a better warning sign. Also remember that Linux load average counts tasks blocked on disk, so a high load with an idle CPU often points to I/O.
Measuring I/O on your server
Install the sysstat and iotop packages first (sudo apt install sysstat iotop on Ubuntu or Debian):
vmstat 1 5 # watch columns b (blocked) and wa (iowait)
iostat -xz 1 # per-device IOPS, throughput, await, %util
sudo iotop -o # processes currently doing disk I/O
pidstat -d 1 # per-process read/write rates
cat /proc/pressure/io # pressure stall information (kernel 4.20+)
ss -tin # per-connection TCP details: rtt, retransmitsFor a controlled disk test, use fio on a scratch file rather than on live data:
fio --name=randread --filename=/root/fio.test --size=1G --rw=randread \
--bs=4k --iodepth=32 --ioengine=libaio --direct=1 --runtime=30 --time_based
rm /root/fio.testRandom 4 KB reads with --direct=1 bypass the page cache and show what the storage itself delivers, which is the pattern most relevant for databases.
Common causes and fixes
- Too little RAM for the page cache. If your database working set does not fit in memory, every query hits the disk. Adding RAM or tuning buffers such as
innodb_buffer_pool_sizeor PostgreSQL'sshared_buffersoften helps more than faster storage. - Swapping. When memory runs out, the system swaps and disk I/O explodes. Check
free -hand thesi/socolumns invmstat. - Excessive logging. Debug-level logs and unrotated files create constant writes. Lower log levels and configure logrotate.
- Missing database indexes. A full table scan reads far more data than needed. Use
EXPLAINto find slow queries. - Backups during peak hours. Schedule them for quiet times and run them with
ionice -c3andnice. - Slow upstream calls. Network I/O to external APIs adds latency directly to your response time. Use timeouts, connection reuse and caching.
- Slow storage. For database-heavy workloads, NVMe-backed storage makes a clear difference compared with older disks.
A quick troubleshooting checklist
- Is CPU busy or mostly idle with high
wa? Checktopandvmstat. - Which device is busy? Run
iostat -xz 1. - Which process causes it? Run
iotop -oorpidstat -d. - Is memory short and the system swapping? Run
free -handvmstat. - Is it network rather than disk? Check
ss -tinand application timing logs.
If your current server is constantly waiting on disk, compare plans with more RAM or faster storage on our pricing page.
FAQ
Is high iowait always a problem?
Not always. Short spikes during backups, package installs or log rotation are normal. It becomes a problem when iowait stays high while users notice slow responses, or when the b column in vmstat keeps showing blocked processes. Then find the responsible process and device before changing hardware.
Will a faster disk fix my slow website?
Only if the disk is actually the bottleneck. If the CPU is saturated, the application waits on a remote API, or queries lack indexes, faster storage changes little. Measure first with vmstat, iostat and your application logs, then decide whether you need more RAM, better queries or faster storage.
What is the difference between IOPS and throughput?
IOPS counts how many separate operations a device completes per second, which matters for small random reads typical of databases. Throughput measures how many megabytes per second are transferred, which matters for large sequential work such as backups or video files. A disk can be strong in one and average in the other.