One of the most noteworthy improvements in XenServer 6.2 is the support for a significantly increased number of VMs running on a host: now up to 500 Windows VMs or 650 Linux VMs.
We needed to remove several obstacles in order to achieve this huge step up. Perhaps the most important of the technical changes that led to this was to increase in the number of event channels available to dom0 (the control domain) from 1024 to 4096. This blog post is an attempt to shed some light on what these event channels are, and why they play a key role in VM density limits.
What is an event channel?
It's a channel for communications between a pair of VMs. An event channel is typically used by one VM to notify another VM about something. For example, a VM's paravirtualised disk driver would use an event channel to notify dom0 of the presence of newly written data in a region of memory shared with dom0.
Here are the various things that a VM requires an event channel for:
- one per virtual disk;
- one per virtual network interface;
- one for communications with xenstore;
- for HVM guests, one per virtual CPU (rising to two in XenServer 6.2); and
- for PV guests; one to communicate with the console daemon.
Therefore VMs will typically require at least four dom0 event channels depending on the configuration of the VM. Requiring more than ten is not an uncommon configuration.
Why can event channels cause scalability problems when trying to run lots of VMs?
The total number of event channels any domain can use is part of a shared structure in the interface between a paravirtualised VM and the hypervisor; it is fixed at 1024 for 32-bit domains such as XenServer's dom0. Moreover, there are normally around 50--100 event channels used for other purposes, such as physical interrupts. This is normally related to the number of physical devices you have in your host. This overhead means that in practice there might be not too many more than 900--950 event channels available for VM use. So the number of available event channels becomes a limited resource that can cause you to experience a hard limit on the number of VMs you can run on a host.
To take an example: Before XenServer 6.2, if each of your VMs requires 6 dom0 event channels (e.g. an HVM guest with 3 virtual disks, 1 virtual network interface and 1 virtual CPU) then you'll probably find yourself running out of dom0 event channels if you go much over 150 VMs.
In XenServer 6.2, we have made a special case for our dom0 to allow it to behave differently to other 32-bit domains to allow it to use up to four times the normal number of event channels. Hence there are now a total of 4096 event channels available.
So, on XenServer 6.2 in the same scenario as the example above, even though each VM of this type would now use 7 dom0 event channels, the increased total number of dom0 event channels means you'd have to run over 570 of them before running out.
What happens when I run out of event channels?
On VM startup, the XenServer toolstack will try to plumb all the event channels through from dom0 to the nascent VM. If there are no spare slots, the connection will fail. The exact failure mode depends on which subsystem the event channel was intended for use in, but you may see error messages like these when the toolstack tries to connect up the next event channel after having run out:
error 28 mapping ring-refs and evtchn
message: xenopsd internal error: Device.Ioemu_failed("qemu-dm exited unexpectedly")
In other words, it's not pretty. The VM either won't boot or will run with reduced functionality.
That sounds scary. How can I tell whether there's sufficient spare event channels to start another VM?
XenServer has a utility called "lsevtchn" that allows you to inspect the event channel plumbing.
In dom0, run the following command to see what event channels are connected to a particular domain.
For example, here is the output from a PV domain with domid 36:
[root@xs62 ~]# /usr/lib/xen/bin/lsevtchn 36
1: VCPU 0: Interdomain (Connected) - Remote Domain 0, Port 51
2: VCPU 0: Interdomain (Connected) - Remote Domain 0, Port 52
3: VCPU 0: Virtual IRQ 0
4: VCPU 0: IPI
5: VCPU 0: IPI
6: VCPU 0: Virtual IRQ 1
7: VCPU 0: IPI
8: VCPU 0: Interdomain (Connected) - Remote Domain 0, Port 55
9: VCPU 0: Interdomain (Connected) - Remote Domain 0, Port 53
10: VCPU 0: Interdomain (Connected) - Remote Domain 0, Port 54
11: VCPU 0: Interdomain (Connected) - Remote Domain 0, Port 56
You can see that six of this VM's event channels are connected to dom0.
But the domain we are most interested in is dom0. The total number of event channels connected to dom0 can be determined by running
/usr/lib/xen/bin/lsevtchn 0 | wc -l
Before XenServer 6.2, if that number is close to 1024 then your host is on the verge of not being able to run an additional VM. On XenServer 6.2, the number to watch out for is 4096. However, before you'd be able to get enough VMs up and running to approach that limit, there are various other things you might run into depending on configuration and workload. Watch out for further blog posts describing how we have cleared more of these hurdles in XenServer 6.2.