When IMAP logins start taking several seconds and Thunderbird or Outlook sits on "checking mail" for a long time, the first instinct is to blame Dovecot. Someone restarts it, things feel better for a while, and then it comes back. On a VPS, a lot of these cases have nothing to do with Dovecot's configuration. The process is simply waiting for the disk.
This guide is about checking that directly from the command line. The goal is to have a few read-only commands you run as a routine, so you know what normal looks like on your mail server and can tell quickly whether a slow period is your own disk load or contention coming from somewhere else on the host.
Why Dovecot logins depend so much on disk
An IMAP login looks like a simple username and password check, but a lot happens right after authentication. Dovecot opens the user's mailbox, reads its index files (the dovecot.index* files it keeps per mailbox), and checks for changes since the last sync. With Maildir storage, that can also mean scanning directories that hold thousands of individual message files. When a phone, a laptop, and a webmail session all sync the same account, that work repeats.
When the index files and directory entries are already in the page cache (RAM the kernel uses to keep recently read file data), this is fast. When they are not, or when every read has to queue behind other I/O, each step waits on the disk. Dovecot is not slow in that moment. It is blocked.
That is why restarting Dovecot rarely fixes anything for long. The disk queue is still there after the restart.
What iowait actually tells you
iowait (shown as wa in vmstat and %iowait in iostat) is the share of time the CPU was idle while at least one I/O request was still outstanding. It is a CPU state, not a direct disk measurement. Two things follow from that.
High iowait on an otherwise quiet CPU is a strong hint that processes are waiting on storage. Low iowait does not prove the disk is healthy, though. If the CPU is busy with other work, it is not idle, so the waiting time does not show up as iowait. That is why iowait is the place to start, and device latency from iostat is where you confirm.
The other column worth watching in vmstat is b: the number of processes in uninterruptible sleep, which on a mail server usually means stuck waiting for I/O. A steady b above zero while users complain about slow logins tells you a lot.
Start with vmstat, printing one line per second for ten seconds. The first line is an average since boot, so ignore it.
# One sample per second, ten samples. Ignore the first line (since-boot average).
vmstat 1 10
# Sample output format (illustrative values only):
# procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
# r b swpd free buff cache si so bi bo in cs us sy id wa st
# 1 3 20000 50000 10000 400000 0 0 800 1200 500 900 5 3 52 40 0
In that illustrative line, wa is high, b shows three blocked processes, and the CPU is mostly idle otherwise. That pattern points at storage. Also glance at si and so (swap in and swap out). If they are non-zero during slow periods, the server is short on memory, the page cache is being squeezed, and Dovecot's index reads are going to disk instead of RAM. That is a memory problem that looks like a disk problem, and adding faster storage will not really solve it.
The st column is CPU steal, which is a separate topic and covered in its own article. It matters here only as a hint: if both st and wa climb at the same time, the host is likely busy in general.
Read device latency with iostat
vmstat tells you the system is waiting. iostat tells you how long each request waits and how deep the queue is. It comes from the sysstat package, which you may need to install depending on your distribution.
# Extended device stats, one-second interval, five reports.
# -x adds latency and queue columns; -z hides idle devices.
iostat -xz 1 5
# Per-process disk activity, one-second interval, five reports.
# Also from sysstat. Run as root to see every process.
pidstat -d 1 5
In the iostat output, focus on these columns for the device that holds your mail (often vda or sda on a VPS, but check with df on your mail directory):
r/sandw/s: read and write requests per second, which is how much work you are asking the disk to do.r_awaitandw_await: average time in milliseconds a read or write request spent waiting and being served.aqu-sz(calledavgqu-szon older versions): average number of requests in the queue.%util: how much of the interval the device had at least one request in flight.
Be careful with %util on a VPS. Virtual disks and SSD-backed storage handle many requests in parallel, so a device can show high %util while still having room to spare. Latency (r_await, w_await) is more honest about what users feel. If reads that normally finish quickly start taking many times longer, logins will feel it regardless of what %util says.
The pidstat output answers the next question: who is doing the I/O? It lists processes with their read and write rates (kB_rd/s, kB_wr/s) and, on most current versions, an iodelay column showing how much time the process spent waiting on block I/O. On a mail server, the usual suspects are backup jobs reading every Maildir, spam filter processes updating their databases, antivirus signature updates, a local database server, Dovecot's own indexing, or log rotation compressing large files.
Pressure stall information as a second opinion
Newer kernels expose a simpler signal in /proc/pressure/io, called pressure stall information (PSI). It reports the share of time that some tasks, or all non-idle tasks, were stalled on I/O, averaged over 10, 60, and 300 seconds.
# Requires a kernel with PSI enabled; the file is absent otherwise.
cat /proc/pressure/io
# Sample output format (illustrative values only):
# some avg10=25.00 avg60=18.00 avg300=6.00 total=123456789
# full avg10=10.00 avg60=7.00 avg300=2.00 total=98765432
The some line means at least one task was waiting. The full line means every runnable task was waiting at once, which is the more serious state. The three averages make it easy to see whether a problem is happening right now (avg10 high) or has been building for a while (avg300 rising). It is also cheap to read, so it fits well in a monitoring script or a quick check during a support chat.
Your load or the neighbor's load
On shared virtualization, your VPS shares physical disks with other guests. You cannot see their processes, but you can reason from what you do see. The trick is comparing how much work you are sending to the disk with how long each request takes.
| What you see inside the VPS | Likely meaning |
|---|---|
High r/s or w/s, high await, pidstat shows a busy process | Your own load. Find and reschedule or tune that process. |
Low r/s and w/s, high await, pidstat shows nothing heavy | The disk is slow for reasons outside your guest. Host contention is a strong candidate. |
Non-zero si/so in vmstat, rising reads | Memory pressure pushing cache out. Look at RAM before storage. |
| Await normal, logins still slow | Disk probably is not the bottleneck. Look at authentication backends, DNS, or network. |
The second row is the classic noisy neighbor pattern. Your server is asking for very little, yet each request takes far longer than it does at your quiet baseline. Nothing you change inside the VPS will fix that, because the queue is on the host.
What makes this convincing, both to yourself and to whoever runs the host, is history. A single snapshot at a bad moment proves little. A set of samples taken at the same times of day, showing low request rates and latency several times higher than your usual baseline, is much harder to dismiss. If you open a ticket with your provider, include the iostat lines, the pidstat output showing no heavy local process, and the times. That is far more useful than "email is slow".
If you run the hypervisor yourself, for example on a Proxmox node, you can confirm from the host side by running the same iostat against the physical devices and checking which guests are generating the load. How you map guests to devices depends on your storage setup, so the exact steps vary.
Build a baseline and check again after changes
The commands above are most useful when you already know what normal looks like. A simple routine is enough: run vmstat 1 10, iostat -xz 1 5, and cat /proc/pressure/io at a quiet time and at your usual busy time, and save the output with the date. Do it again after any change you make.
That last part matters. If you move the nightly backup out of business hours, reduce how often a spam filter retrains, or add RAM to stop swapping, run the exact same commands during the same window afterwards. If await and PSI drop while your request rate stays similar, the change worked. If nothing moves, the cause was somewhere else, and you have saved yourself from tuning Dovecot settings that were never the problem.
For support engineers, this is also the fastest way to keep a conversation grounded. A customer reporting slow IMAP often expects a Dovecot setting to change. Showing that the disk itself is waiting, and whether that wait comes from inside or outside their server, moves the discussion to the right place quickly.
The practical takeaway: before touching Dovecot, check whether the disk is making it wait. Look at wa and b in vmstat, confirm with read and write latency in iostat, find the process with pidstat, and use your saved baseline to decide whether the load is yours or the host's. Run the same checks after every change, so you know whether the fix actually helped.