Configuring CPU Affinity for Virtual Machines and ContainersIf your physical server has several processors installed, you can bind a virtual machine or Container to specific CPUs so that only these CPUs are used to handle the processes running in the virtual machine or Container. The feature of binding certain processes to certain CPUs is known as CPU affinity . Establishing CPU affinity between virtual machines and Containers and physical processors can help you increase your system performance up to 20%.
By default, any newly created virtual machine and Container can consume the CPU time of all processors installed on the physical server. To bind a virtual machine or Container to specific CPUs, you can use the
# pctl set MyVM --cpumask 0,1,3,4-6 The VM has been successfully configured. # pctl set 101 --cpumask 0,1,3,4-6 --save Saved parameters for Container 101 You can specify the CPU affinity mask—that is, the processors to bind to virtual machines and Containers—as separate numbers (0,1,3) or as ranges (4-6). If you are setting the CPU affinity mask for a running virtual machine or Container, the changes are applied on the fly.
To undo the changes made to the
# pctl set MyVM --cpumask all The VM has been successfully configured. # pctl set 101 --cpumask all --save Saved parameters for Container 101 |
||||
|