13.5. Optimizing virtual machine I/O performance
The input and output (I/O) capabilities of a virtual machine (VM) can significantly limit the VM’s overall efficiency. To address this, you can optimize a VM’s I/O by configuring block I/O parameters.
13.5.1. Tuning block I/O in virtual machines Copier lienLien copié sur presse-papiers!
When multiple block devices are being used by one or more VMs, it might be important to adjust the I/O priority of specific virtual devices by modifying their I/O weights.
Increasing the I/O weight of a device increases its priority for I/O bandwidth, and therefore provides it with more host resources. Similarly, reducing a device’s weight makes it consume less host resources.
Each device’s weight value must be within the 100 to 1000 range. Alternatively, the value can be 0, which removes that device from per-device listings.
Procédure
To display and set a VM’s block I/O parameters:
Display the current
<blkio>parameters for a VM:# virsh dumpxml VM-nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the I/O weight of a specified device:
virsh blkiotune VM-name --device-weights device, I/O-weight
# virsh blkiotune VM-name --device-weights device, I/O-weightCopy to Clipboard Copied! Toggle word wrap Toggle overflow For example, the following changes the weight of the /dev/sda device in the liftrul VM to 500.
virsh blkiotune liftbrul --device-weights /dev/sda, 500
# virsh blkiotune liftbrul --device-weights /dev/sda, 500Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.5.2. Disk I/O throttling in virtual machines Copier lienLien copié sur presse-papiers!
When several VMs are running simultaneously, they can interfere with system performance by using excessive disk I/O. Disk I/O throttling in KVM virtualization provides the ability to set a limit on disk I/O requests sent from the VMs to the host machine. This can prevent a VM from over-utilizing shared resources and impacting the performance of other VMs.
To enable disk I/O throttling, set a limit on disk I/O requests sent from each block device attached to VMs to the host machine.
Procédure
Use the
virsh domblklistcommand to list the names of all the disk devices on a specified VM.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Find the host block device where the virtual disk that you want to throttle is mounted.
For example, if you want to throttle the
sdbvirtual disk from the previous step, the following output shows that the disk is mounted on the/dev/nvme0n1p3partition.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set I/O limits for the block device using the
virsh blkiotunecommand.virsh blkiotune VM-name --parameter device,limit
# virsh blkiotune VM-name --parameter device,limitCopy to Clipboard Copied! Toggle word wrap Toggle overflow The following example throttles the
sdbdisk on therollin-coalVM to 1000 read and write I/O operations per second and to 50 MB per second read and write throughput.virsh blkiotune rollin-coal --device-read-iops-sec /dev/nvme0n1p3,1000 --device-write-iops-sec /dev/nvme0n1p3,1000 --device-write-bytes-sec /dev/nvme0n1p3,52428800 --device-read-bytes-sec /dev/nvme0n1p3,52428800
# virsh blkiotune rollin-coal --device-read-iops-sec /dev/nvme0n1p3,1000 --device-write-iops-sec /dev/nvme0n1p3,1000 --device-write-bytes-sec /dev/nvme0n1p3,52428800 --device-read-bytes-sec /dev/nvme0n1p3,52428800Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Informations complémentaires
- Disk I/O throttling can be useful in various situations, for example when VMs belonging to different customers are running on the same host, or when quality of service guarantees are given for different VMs. Disk I/O throttling can also be used to simulate slower disks.
- I/O throttling can be applied independently to each block device attached to a VM and supports limits on throughput and I/O operations.
-
Red Hat ne prend pas en charge l'utilisation de la commande
virsh blkdeviotunepour configurer la limitation des E/S dans les machines virtuelles. Pour plus d'informations sur les fonctionnalités non prises en charge lors de l'utilisation de RHEL 9 en tant qu'hôte de VM, voir Fonctionnalités non prises en charge dans la virtualisation RHEL 9.
13.5.3. Enabling multi-queue virtio-scsi Copier lienLien copié sur presse-papiers!
When using virtio-scsi storage devices in your virtual machines (VMs), the multi-queue virtio-scsi feature provides improved storage performance and scalability. It enables each virtual CPU (vCPU) to have a separate queue and interrupt to use without affecting other vCPUs.
Procédure
To enable multi-queue virtio-scsi support for a specific VM, add the following to the VM’s XML configuration, where N is the total number of vCPU queues:
<controller type='scsi' index='0' model='virtio-scsi'> <driver queues='N' /> </controller>
<controller type='scsi' index='0' model='virtio-scsi'> <driver queues='N' /> </controller>Copy to Clipboard Copied! Toggle word wrap Toggle overflow