Advanced Scheduling Options
This document describes advanced virtual machine scheduling strategies that you can use for specific enterprise use cases.
NUMA Support
NUMA awareness allows the operating system of a virtual machine to intelligently schedule the workloads that it runs and minimize cross-node memory bandwidth.
In order to configure NUMA nodes for a virtual machine, you need to specify hw:numa_nodes property as part of a virtual machine flavor, then use that flavor to create the virtual machine.
For example, to restrict a virtual machine's vCPUs to a single host NUMA node, set hw:numa_nodes=1as part of the VM's flavor.
You can update an existing flavor and add this as new metadata - note that it will only apply to new VMs created using the flavor after the update. To update an existing flavor using pcdctl CLI, run the following command (replace with the name of the flavor you wish to update):
pcdctl flavor set <flavor-name> --property hw:numa_nodes=1Some workloads have very demanding requirements for memory access latency or bandwidth that exceed the memory bandwidth available from a single NUMA node. For such workloads, it is beneficial to spread the virtual machine across multiple host NUMA nodes, even if the VM's RAM/vCPUs could theoretically fit on a single NUMA node. To force a virtual machine's vCPUs to spread across two host NUMA nodes, set hw:numa_nodes=2as part of the VM's flavor.
The allocation of a virtual machine's vCPUs and memory from different host NUMA nodes can be configured. This allows for asymmetric allocation of vCPUs and memory, which can be important for some workloads. You can configure the allocation of VM vCPUs and memory across each VM NUMA node using the hw:numa_cpus.{num} and hw:numa_mem.{num} metadata properties as part of the VM flavor. For example, to spread the 6 vCPUs and 6 GB of memory of a VM across two NUMA nodes and create an asymmetric 1:2 vCPU and memory mapping between the two nodes, run the following command using pcdctl CLI (replace with the name of the flavor you wish to update):
$ pcdctl flavor set <flavor-name> --property hw:numa_nodes=2
$ pcdctl flavor set <flavor-name> \
--property hw:numa_cpus.0=0,1 \
--property hw:numa_mem.0=2048
$ pcdctl flavor set <flavor-name> \
--property hw:numa_cpus.1=2,3,4,5 \
--property hw:numa_mem.1=4096NUMA Memory Allocation Policy
When you pin a virtual machine to a host NUMA node, the Compute Service also sets the memory allocation policy that the host applies to that VM's memory. The default policy is strict, which confines the VM's memory to the NUMA node it was placed on. If that node runs out of free memory, the host cannot fall back to another node, so it terminates the VM's process to reclaim memory. The VM shuts down even when other NUMA nodes on the same host still have free RAM.
The hw:numa_mempolicy flavor metadata property lets you relax that constraint. Set it to preferred so that a VM allocates from its assigned NUMA node while it can, and spills over to another node when that node is exhausted, instead of being terminated.
Set hw:numa_mempolicy to one of the following two values:
strict(the default) confines the VM's memory to its assigned NUMA node. Choose this when a VM must never allocate memory from another node, accepting that the VM is shut down if its node is exhausted.preferredallocates from the assigned NUMA node first, then falls back to another node under memory pressure.
If you do not set hw:numa_mempolicy, the policy remains strict and VM behavior is unchanged.
To set the memory allocation policy from the UI, navigate to Virtual Machines in the left-hand navigation menu and open the Flavors page. Select the flavor you want to update, then choose Edit Metadata from the Actions menu. Under Flavor Metadata, use Add Metadata to add the key hw:numa_mempolicy with the value preferred, then click Update Flavor.
To make the same change using the pcdctl CLI, run the following command (replace with the name of the flavor you wish to update):
Apply the Policy to Existing VMs
Adding hw:numa_mempolicy to a flavor affects only the VMs you create from that flavor afterwards. The policy is recorded for a VM when the VM is created, so an existing VM keeps the policy it started with, and rebooting it does not pick up the new value from the flavor.
To move an existing VM onto the new policy, resize it to a flavor that sets hw:numa_mempolicy. The VM's memory allocation policy is regenerated as part of the resize.
Once a VM is running with the preferred policy, that policy persists across hard reboots, resizes, and live migrations.
CPU Pinning
By default, virtual machine vCPU processes are not assigned to any particular host CPU. This allows for features like overcommitting of CPUs. In heavily contended systems, this provides optimal system performance, however that may come at the expense of performance and latency for individual VMs.
Some virtualized workloads require real-time or near real-time behavior, which is not possible with the latency introduced by this default CPU scheduling policy. For such VMs, it is beneficial to control which host CPUs are bound to a VM's vCPUs. This process is known as CPU pinning. No other VMs can use the CPUs of a pinned VM, thus preventing resource contention between VMs.
You can configure a VM to use CPU pinning by specifying the hw:cpu_policy metadata property as part of the VM's flavor. There are three policies: dedicated, mixed and shared (the default). The dedicated CPU policy is used to specify that all CPUs of a VM should use pinned CPUs. To configure a flavor to use the dedicated CPU policy, run:
Related Pages
VM Flavors: how flavors and flavor metadata define a VM's resource allocation
Performance Tuning: image properties that complement flavor-level tuning
Diagnose VM Scheduling Failures: what to check when a NUMA-constrained VM fails to schedule
Last updated
Was this helpful?
