Skip to contentSkip to conversation

How many threads should a kvm vm be starting?

DISCUSSION Thomas Fjellstrom 3 participants 5 messages Sep 27, 2011 – Sep 28, 2011 KVM

lore
Share & tools
lore
#0 lore raw

I just noticed something interesting, a virtual machine on one of my servers seems to have 69 threads (including the main thread). Other guests on the machine only have a couple threads.

Is this normal? or has something gone horribly wrong?

Signature · 2 lines
Thomas Fjellstrom
[email protected]
#1 lore raw
Quoted 6 lines · Thomas Fjellstrom

I just noticed something interesting, a virtual machine on one of my servers seems to have 69 threads (including the main thread). Other guests on the machine only have a couple threads.

Is this normal? or has something gone horribly wrong?

It's normal if the guest does a lot of I/O. The thread count should go down when the guest idles.

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#2 lore raw
Quoted 9 lines · Avi Kivity
Quoted 5 lines · Thomas Fjellstrom

I just noticed something interesting, a virtual machine on one of my servers seems to have 69 threads (including the main thread). Other guests on the machine only have a couple threads.

Is this normal? or has something gone horribly wrong?

It's normal if the guest does a lot of I/O. The thread count should go down when the guest idles.

Ah, that would make sense. Though it kind of defeats assigning a vm a single cpu/core. A single VM can now DOS an entire multi-core-cpu server. It pretty much pegged my dual core (with HT) server for a couple hours.

Signature · 2 lines
Thomas Fjellstrom
[email protected]
#3 lore raw
Quoted 6 lines · Thomas Fjellstrom
Quoted 5 lines · Avi Kivity
Quoted 4 lines · Thomas Fjellstrom

I just noticed something interesting, a virtual machine on one of my servers seems to have 69 threads (including the main thread). Other guests on the machine only have a couple threads.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Is this normal? or has something gone horribly wrong?

It's normal if the guest does a lot of I/O. The thread count should go down when the guest idles.

Ah, that would make sense. Though it kind of defeats assigning a vm a single cpu/core. A single VM can now DOS an entire multi-core-cpu server. It pretty much pegged my dual core (with HT) server for a couple hours.

You can mitigate these problems by putting each KVM process in its own cgroup, and using the 'cpu_shares' tunable to ensure that each KVM process gets the same relative ratio of CPU time, regardless of how many threads it is running. With newer kernels there are other CPU tunables for placing hard caps on CPU utilization of the process as a whole too.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#4 lore raw
Quoted 17 lines · Daniel P. Berrange
Quoted 8 lines · Thomas Fjellstrom
Quoted 7 lines · Avi Kivity
Quoted 5 lines · Thomas Fjellstrom

I just noticed something interesting, a virtual machine on one of my servers seems to have 69 threads (including the main thread). Other guests on the machine only have a couple threads.

Is this normal? or has something gone horribly wrong?

Quoted 7 lines
Quoted 2 lines

It's normal if the guest does a lot of I/O. The thread count should go down when the guest idles.

Ah, that would make sense. Though it kind of defeats assigning a vm a single cpu/core. A single VM can now DOS an entire multi-core-cpu server. It pretty much pegged my dual core (with HT) server for a couple hours.

Quoted 6 lines

You can mitigate these problems by putting each KVM process in its own cgroup, and using the 'cpu_shares' tunable to ensure that each KVM process gets the same relative ratio of CPU time, regardless of how many threads it is running. With newer kernels there are other CPU tunables for placing hard caps on CPU utilization of the process as a whole too.

I'll have to look into how to set that up with libvirt. A brief search leads me to believe its rather easy to set up, so I'll have to do that asap :)

Quoted 2 lines

Regards,
Daniel

Signature · 2 lines
Thomas Fjellstrom
[email protected]