/ Ubuntu 12.04 LTS

Speed up your KVM virtual machine

Disk speed

When you create a virtual machine (VM) with virt-manager it will by default create a raw image file with IDE as disk bus. In the configuration file this will look like

Switching the disk bus to virtio will greatly improve the performance and virt edit will show something like this:

A simple test inside the virtual machine with

dd bs=1M count=1024 if=/dev/zero of=test conv=fdatasync

results in a speed of 208 MB/s with virtio on my test system, with the IDE setting it was only 32.3 MB/s (in comparison, the actual server performes around 224 MB/s).

To switch to virtio in virt-manager, shut down the VM, then double click on the virtual machine name and go to View -> Details. Select the virtual disk, open advanced options and set Disk Bus to Virtio. Then start the VM again.

Of course you can also edit the configuration file directly with virsh edit but the graphical interface of virt-manager makes a lot of things easier, especially when you are only starting with KVM virtualization.

Network throughput

Using virtio as virtual network interface also brings a huge speed improvement. Downloading a 100MB test file directly on my server and in a virtual machine with virtio as device model takes 10 seconds. With the default Realtek rtl8139 driver it took a whopping 25 seconds to download the same file.
To test the performance you can download a test file via the command line from any major hosting provider with a datacenter close to your server, for example from Softlayer (click on a data center at the bottom of the page) or Leaseweb (look further down the page for the 100MB and 1000MB test files). Use either wget (installed by default on most Linuxes):

wget -O /dev/null http://speedtest.dal01.softlayer.com/downloads/test.zip

or curl (might need to be installed first but has nicer output):

curl -o /dev/null http://speedtest.dal01.softlayer.com/downloads/test.zip

Speed up your KVM virtual machine
Share this