Stop letting KVM disk I/O latency ruin your database performance
By Saket Jain Published Linux/Unix
Stop letting KVM disk I/O latency ruin your database performance
Technical Briefing | 11/30/2026
You move a database to a KVM guest, everything looks fine, and then your application latency spikes during heavy writes. You check the host, you check the guest, and everything seems quiet. The truth is your block layer is likely choking on the default virtio cache settings, which were designed for compatibility rather than raw performance.
Why write-back is the only mode that matters
If you are running the default cache mode, the host is waiting for a disk flush acknowledgement from the guest for every operation. This is effectively crippling your IOPS because it forces synchronous behavior that the guest kernel isn’t prepared to handle. Switching to write-back puts the host in control of flushing, which is exactly where it belongs for production workloads.
virsh edit my-database-vm && virsh destroy my-database-vm && virsh start my-database-vm
Once inside the XML editor, locate your disk definition and tweak the driver attributes. Don’t touch the bus unless you have a good reason, but definitely override the cache policy.
- Set the cache mode to writeback for the virtual block device
- Ensure your guest filesystem is configured for barriers if you care about data integrity
- Verify your io parameter is set to native rather than threads to reduce context switching
The risk here is obviously data loss if the host loses power suddenly, so pair this with a reliable UPS or a battery-backed RAID controller. If you’re on a public cloud provider, your storage fabric handles these flushes differently, but on bare metal KVM, this tweak is often the difference between a sluggish app and a snappy one.
