3.5. Schedule Hosts and Cells

The Compute scheduling service determines on which cell or host (or host aggregate), an instance will be placed. As an administrator, you can influence where the scheduler will place an instance. For example, you might want to limit scheduling to hosts in a certain group or with the right RAM.
You can configure the following components:
  • Filters - Determine the initial set of hosts on which an instance might be placed (see Section 3.5.1, “Configure Scheduling Filters”).
  • Weights - When filtering is complete, the resulting set of hosts are prioritized using the weighting system. The highest weight has the highest priority (see Section 3.5.2, “Configure Scheduling Weights”).
  • Scheduler service - There are a number of configuration options in the /etc/nova/nova.conf file (on the scheduler host), which determine how the scheduler executes its tasks, and handles weights and filters. There is both a host and a cell scheduler. For a list of these options, refer to the "Configuration Reference" (RHEL OpenStack Platform Documentation).
In the following diagram, both host 1 and 3 are eligible after filtering. Host 1 has the highest weight and therefore has the highest priority for scheduling.

Figure 3.3. Scheduling Hosts

Scheduling Hosts

3.5.1. Configure Scheduling Filters

You define which filters you would like the scheduler to use in the scheduler_default_filters option (/etc/nova/nova.conf file; you must have either root or nova user permissions). Filters can be added or removed.
By default, the following filters are configured to run in the scheduler:
scheduler_default_filters=RetryFilter,AvailabilityZoneFilter,RamFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter
Some filters use information in parameters passed to the instance in:
All available filters are listed in the following table.

Table 3.4. Scheduling Filters

Filter Description
AggregateCoreFilter
Uses the host-aggregate metadata key cpu_allocation_ratio to filter out hosts exceeding the over-commit ratio (virtual CPU to physical CPU allocation ratio); only valid if a host aggregate is specified for the instance.
If this ratio is not set, the filter uses the cpu_allocation_ratio value in the /etc/nova/nova.conf file. The default value is '16.0' (16 virtual CPU can be allocated per physical CPU).
AggregateDiskFilter
Uses the host-aggregate metadata key disk_allocation_ratio to filter out hosts exceeding the over-commit ratio (virtual disk to physical disk allocation ratio); only valid if a host aggregate is specified for the instance.
If this ratio is not set, the filter uses the disk_allocation_ratio value in the /etc/nova/nova.conf file. The default value is '1.0' (one virtual disk can be allocated for each physical disk).
AggregateImagePropertiesIsolation Only passes hosts in host aggregates whose metadata matches the instance's image metadata; only valid if a host aggregate is specified for the instance. For more information, see Section 4.1.1, “Create an Image”.
AggregateInstanceExtraSpecsFilter Metadata in the host aggregate must match the host's flavor metadata. For more information, see Section 3.3.4, “Update Flavor Metadata”.
AggregateMultiTenancyIsolation A host with the specified filter_tenant_id can only contain instances from that tenant (project). Note: The tenant can still place instances on other hosts.
AggregateRamFilter
Uses the host-aggregate metadata key ram_allocation_ratio to filter out hosts exceeding the over commit ratio (virtual RAM to physical RAM allocation ratio); only valid if a host aggregate is specified for the instance.
If this ratio is not set, the filter uses the ram_allocation_ratio value in the /etc/nova/nova.conf file. The default value is '1.5' (1.5 RAM can be allocated for each physical RAM).
AllHostsFilter Passes all available hosts (however, does not disable other filters).
AvailabilityZoneFilter Filters using the instance's specified availability zone.
ComputeCapabilitiesFilter Ensures Compute metadata is read correctly. Anything before the ':' is read as a namespace. For example, 'quota:cpu_period' uses 'quota' as the namespace and 'cpu_period' as the key.
ComputeFilter Passes only hosts that are operational and enabled.
CoreFilter Uses the cpu_allocation_ratio in the /etc/nova/nova.conf file to filter out hosts exceeding the over commit ratio(virtual CPU to physical CPU allocation ratio). The default value is '16.0' (16 virtual CPU can be allocated per physical CPU).
DifferentHostFilter Enables an instance to build on a host that is different from one or more specified hosts. Specify 'different' hosts using the nova boot option --different_host option.
DiskFilter Uses disk_allocation_ratio in the /etc/nova/nova.conf file to filter out hosts exceeding the over commit ratio(virtual disk to physical disk allocation ratio). The default value is '1.0' (one virtual disk can be allocated for each physical disk).
ImagePropertiesFilter Only passes hosts that match the instance's image properties. For more information, see Section 4.1.1, “Create an Image”.
IsolatedHostsFilter Passes only isolated hosts running isolated images that are specified in the /etc/nova/nova.conf file using isolated_hosts and isolated_images (comma-separated values).
JsonFilter
Recognises and uses an instance's custom JSON filters:
  • Valid operators are: =, <, >, in, <=, >=, not, or, and
  • Recognised variables are: $free_ram_mb, $free_disk_mb, $total_usable_ram_mb, $vcpus_total, $vcpus_used
The filter is specfied as a query hint in the nova boot command. For example:
--hint query='['>=', '$free_disk_mb', 200 * 1024]'
MetricFilter Filters out hosts with unavailable metrics.
NUMATopologyFilter Filters out hosts based on its NUMA topology; if the instance has no topology defined, any host can be used. The filter tries to match the exact NUMA topology of the instance to those of the host (it does not attempt to pack the instance onto the host). The filter also looks at the standard over-subscription limits for each NUMA node, and provides limits to the compute host accordingly.
RamFilter Uses ram_allocation_ratio in the /etc/nova/nova.conf file to filter out hosts exceeding the over commit ratio (virtual RAM to physical RAM allocation ratio). The default value is '1.5' (1.5 RAM can be allocated for each physical RAM).
RetryFilter Filters out hosts that have failed a scheduling attempt; valid if scheduler_max_attempts is greater than zero (by default,scheduler_max_attempts=3).
SameHostFilter
Passes one or more specified hosts; specify hosts for the instance using the --hint same_host option for nova boot.
ServerGroupAffinityFilter
Only passes hosts for a specific server group:
  • Give the server group the affinity policy (nova server-group-create --policy affinity groupName).
  • Build the instance with that group (nova boot option --hint group=UUID).
ServerGroupAntiAffinityFilter
Only passes hosts in a server group that do not already host an instance:
  • Give the server group the anti-affinity policy (nova server-group-create --policy anti-affinity groupName).
  • Build the instance with that group (nova boot option --hint group=UUID).
SimpleCIDRAffinityFilter
Only passes hosts on the specified IP subnet range specified by the instance's cidr and build_new_host_ip hints. Example:
--hint build_near_host_ip=192.0.2.0 --hint cidr=/24

3.5.2. Configure Scheduling Weights

Both cells and hosts can be weighted for scheduling; the host or cell with the largest weight (after filtering) is selected. All weighers are given a multiplier that is applied after normalising the node's weight. A node's weight is calculated as:
w1_multiplier * norm(w1) + w2_multiplier * norm(w2) + ...
You can configure weight options in the scheduler host's /etc/nova/nova.conf file (must have either root or nova user permissions).

3.5.2.1. Configure Weight Options for Hosts

You can define the host weighers you would like the scheduler to use in the [DEFAULT] scheduler_weight_classes option. Valid weighers are:
  • nova.scheduler.weights.ram - Weighs the host's available RAM.
  • nova.scheduler.weights.metrics - Weighs the host's metrics.
  • nova.scheduler.weights.all_weighers - Uses all host weighers (default).

Table 3.5. Host Weight Options

Weigher Option Description
All [DEFAULT] scheduler_host_subset_size Defines the subset size from which a host is selected (integer); must be at least 1. A value of 1 selects the first host returned by the weighing functions. Any value less than 1 is ignored and 1 is used instead (integer value).
metrics [metrics] required
Specifies how to handle metrics in [metrics] weight_setting that are unavailable:
  • True - Metrics are required; if unavailable, an exception is raised. To avoid the exception, use the MetricFilter filter in the [DEFAULT]scheduler_default_filters option.
  • False - The unavailable metric is treated as a negative factor in the weighing process; the returned value is set by weight_of_unavailable.
metrics [metrics] weight_of_unavailable Used as the weight if any metric in [metrics] weight_setting is unavailable; valid if [metrics]required=False.
metrics [metrics] weight_multiplier Mulitplier used for weighing metrics. By default, weight_multiplier=1.0 and spreads instances across possible hosts. If this value is negative, the host with lower metrics is prioritized, and instances are stacked in hosts.
metrics [metrics] weight_setting
Specifies metrics and the ratio with which they are weighed; use a comma-separated list of 'metric=ratio' pairs. Valid metric names are:
  • cpu.frequency - Current CPU frequency
  • cpu.user.time - CPU user mode time
  • cpu.kernel.time - CPU kernel time
  • cpu.idle.time - CPU idle time
  • cpu.iowait.time - CPU I/O wait time
  • cpu.user.percent - CPU user mode percentage
  • cpu.kernel.percent - CPU kernel percentage
  • cpu.idle.percent - CPU idle percentage
  • cpu.iowait.percent - CPU I/O wait percentage
  • cpu.percent - Generic CPU utilization
Example: weight_setting=cpu.user.time=1.0
ram [DEFAULT] ram_weight_multiplier Multiplier for RAM (floating point). By default, ram_weight_multiplier=1.0 and spreads instances across possible hosts. If this value is negative, the host with less RAM is prioritized, and instances are stacked in hosts.

3.5.2.2. Configure Weight Options for Cells

You define which cell weighers you would like the scheduler to use in the [cells] scheduler_weight_classes option (/etc/nova/nova.conf file; you must have either root or nova user permissions)
Valid weighers are:
  • nova.cells.weights.all_weighers - Uses all cell weighers(default).
  • nova.cells.weights.mute_child - Weighs whether a child cell has not sent capacity or capability updates for some time.
  • nova.cells.weights.ram_by_instance_type - Weighs the cell's available RAM.
  • nova.cells.weights.weight_offset - Evaluates a cell's weight offset. Note: A cell's weight offset is specified using --woffset in the nova-manage cell create command.

Table 3.6. Cell Weight Options

Weighers Option Description
mute_child [cells] mute_weight_multiplier Multiplier for hosts which have been silent for some time (negative floating point). By default, this value is '-10.0'.
mute_child [cells] mute_weight_value Weight value given to silent hosts (positive floating point). By default, this value is '1000.0'.
ram_by_instance_type [cells] ram_weight_multiplier Multiplier for weighing RAM (floating point). By default, this value is '1.0', and spreads instances across possible cells. If this value is negative, the cell with fewer RAM is prioritized, and instances are stacked in cells.
weight_offset [cells] offset_weight_multiplier
Multiplier for weighing cells (floating point). Enables the instance to specify a preferred cell (floating point) by setting its weight offset to 999999999999999 (highest weight is prioritized). By default, this value is '1.0'.