Being able to customize virtual machine (VM) priorities and knowing the ins and outs of resource sharing for XenServer VMs and CPUs can help optimize your customer’s resources in their environment. There are a number of considerations for solution providers addressed, such as balancing VM or CPU resources, in this FAQ with Sander van Vugt. Providers can also read advice on potentially troublesome tasks, such as how to get a VM to stay on dedicated CPU cores or finding hidden options on the command line interface.
1. What exactly is XenServer virtual machine (VM) resource sharing?
When several VMs are used on one physical machine, these VMs all use the same hardware, which means that a resource-sharing method between VMs is needed. Specifically, the CPU, hard disk and network card are involved, and by default, every machine gets the proper amount of resources. If some machines need more priorities in accessing these resources, there are a few parameters that you can change.
2. How are CPU resources balanced normally between systems?
Resources are shared by means of a fair-share balancing algorithm, which means there is a scheduler process that gives equal time to each of the VMs. The virtual CPU is automatically moved to the physical core that has resources available at that moment, which guarantees that a VM is granted the resources on-demand. In specific environments this may lead to a loss of performance because each time a VM gets moved, it requires time to build up cache in the new CPU core. Solution providers may find it beneficial to limit moving around VMs.
3. What can I do to make sure a VM stays on dedicated CPU cores and doesn't get moved around too often?
Your first option is to assign CPU weights to VMs to set different priorities, which is an easy method that works conveniently from the GUI.
As an alternative, you can also use the xe command on the console of your Xenserver host. This command allows you to specify a more detailed control where you would use the so-called caps to set priority to CPUs for given VMs. The command line also allows you to pin down a VM to one or more dedicated physical CPUs.
This is a great option for heavy workloads because by pinning the VM to a specific CPU you get better performance.
4. What about the usage of disk resources?
Similar to CPU cores, XenServer uses a fair-share balancing algorithm where every machine has the same priority. From the console of your XenServer host computer, you can use the xe command to change this behavior and increase priority for specific VMs on the I/O channel. This option is not as relevant as the CPU options offered, because most VMs running on XenServer will access their disk image files from a Storage Area Network (SAN) environment, and you would apply optimization technologies offered by the SAN.
5. And what about network resource using?
By default XenServer uses a fair-sharing algorithm for network resources. But the graphical user interface offers bandwidth throttling options that allow you to increase or decrease the available bandwidth for specific VMs.
Alternatively, you can design the network so that VMs are using different physical interfaces on the host. In such an environment, you could dedicate a physical network card to one or a few VMs only, which offers a hard method to reserve network resources for this machine.
6. Why are many of these options hidden to the command line interface on the server and not available from the graphical user interface?
The first reason for this is that these options are only beneficial if applied in the right way. Making them only available from the command line is a way of discouraging users to apply them too easily, which can negatively impact performance because it assumes that users who access the command line know what they’re doing. Because of the difficult nature of the commands, the person who applies them would need to spend time researching them prior to application.
About the expert
Sander van Vugt is an independent trainer and consultant living in the Netherlands. Van Vugt is an expert in Linux high availability, virtualization and performance and has completed several projects that implement all three. He is also the writer of various Linux-related books, such as Beginning the Linux Command Line, Beginning Ubuntu Server Administration and Pro Ubuntu Server Administration.