How to Fine-tune Virtual CPU Management

 Summary

This document describes how to fine-tune the virtual CPU management of virtual machines (VMs) running on a Citrix XenServer .

Background

In the default setup of XenServer, physical CPU resources are split between virtual machines using a fair-share balancing algorithm. This ensures all of the virtual machines get their share of the system’s CPU resources. XenServer has a smart CPU load balancing scheduler that automatically moves the virtual machine CPUs between physical CPU cores to provide the best performance for all virtual machines. In some situations it might be necessary to modify the default setup to grant virtual machines more or less resources to optimize the use of processor resources.

XenServer enumerates physical CPUs in a depth-first fashion. For a system with both hyperthreading and multiple cores, this would be all thehyperthreads on a given core, then all the cores on a given socket, and then all sockets. For example: On a two socket, dual-corehyperthreaded Xeon, the CPU order would be:

 

               

socket0

socket1

core0

core1

core0

core1

ht0

ht1

ht0

ht1

ht0

ht1

ht0

ht1

#0

#1

#2

#3

#4

#5

#6

#7

Procedure

The following section describes the procedure to modify the default setup with some example commands.

The virtual CPU (vCPU) behaviour can be modified by altering the VCPUs-params parameter of a virtual machine like the following:

vCPU pinning is the term for mapping vCPUs of a VM to specific physical resources.

You can tune a vCPU's pinning with the following command:

[root@xenserver ~]# xe vm-param-set uuid=<VM UUID> VCPUs-params:mask=1,3,7

The VM from the above example will then run on physical CPUs 1, 3, and 7 only.

The VCPU priority weight parameters can also be modified to grant a specific VM more CPU time than others.

[root@xenserver ~]# xe vm-param-set uuid=<VM UUID> VCPUs-params:weight=512

The VM from the above example with a weight of 512 will get twice as much CPU as a domain with a weight of 256 on a busy XenServer Host where all CPU resources are in use.

Valid weights range from 1 to 65535 and the default is 256.

The CPU cap optionally fixes the maximum amount of CPU a VM can use.

[root@xenserver ~]# xe vm-param-set uuid=<VM UUID> VCPUs-params:cap=80

The VM from the above example with a cap of 80 will only be able to use 80 percent of one physical CPU even if the XenServer Host has idle CPU cycles.

The cap is expressed in percentage of one physical CPU: 100 is one physical CPU, 50 is half a CPU, 400 is 4 CPUs, and so on. The default, 0 (zero), means there is no upper cap.

你可能感兴趣的:(xenserver,vcpu)