17.5.4. 専用の IOThreads の設定
仮想マシン (VM) 上のディスクの I/O パフォーマンスを向上させるために、仮想マシンのディスクの I/O 操作を管理するために使用される専用の IOThread を設定できます。
通常、ディスクの I/O 操作はメインの QEMU スレッドの一部です。そのため、集中的な I/O ワークロードの実行時に、仮想マシン全体の応答性が低下する可能性があります。I/O 操作を専用の IOThread に分離することで、仮想マシンの応答性とパフォーマンスを大幅に向上させることができます。
手順
- 選択した仮想マシンが実行中の場合はシャットダウンします。
ホストで、仮想マシンの XML 設定に
<iothreads>タグを追加または編集します。たとえば、testguest1仮想マシンに 1 つのIOThreadを作成するには、次のようにします。# virsh edit <testguest1> <domain type='kvm'> <name>testguest1</name> ... <vcpu placement='static'>8</vcpu> <iothreads>1</iothreads> ... </domain>注記最適な結果を得るには、ホスト上の CPU ごとに 1 - 2 個の
IOThreadsのみを使用してください。仮想マシンディスクに専用の
IOThreadを割り当てます。たとえば、ID が1のIOThreadをtestguest1仮想マシン上のディスクに割り当てるには、次のように指定します。# virsh edit <testguest1> <domain type='kvm'> <name>testguest1</name> ... <devices> <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none' io='native' iothread='1'/> <source file='/var/lib/libvirt/images/test-disk.raw'/> <target dev='vda' bus='virtio'/> <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/> </disk> ... </devices> ... </domain>注記IOThreadの ID は 1 から始まります。ディスクごとに 1 つのIOThreadのみを割り当てる必要があります。通常、最適なパフォーマンスを得るには、仮想マシンごとに 1 つの専用
IOThreadで十分です。virtio-scsiストレージデバイスを使用する場合は、virtio-scsiコントローラーに専用のIOThreadを割り当てます。たとえば、ID が1のIOThreadをtestguest1仮想マシン上のコントローラーに割り当てるには、次のように指定します。# virsh edit <testguest1> <domain type='kvm'> <name>testguest1</name> ... <devices> <controller type='scsi' index='0' model='virtio-scsi'> <driver iothread='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> </controller> ... </devices> ... </domain>
検証
- 仮想マシンのパフォーマンスに対する変更の効果を評価します。詳細は、仮想マシンのパフォーマンス監視ツール を参照してください。