OpenStack Stacking vs Spreading
Set ram_weight_multiplier to -1.0 for stacking or 1.0 for spreading in /etc/nova/nova.conf.
Configuration
Edit /etc/nova/nova.conf on the controller node.
Stacking (High Density)
Pack instances onto fewer hosts.
[DEFAULT]
scheduler_weight_classes = nova.scheduler.weights.ram.RAMWeigher
[filter_scheduler]
enabled_filters = AvailabilityZoneFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,NUMATopologyFilter
ram_weight_multiplier = -1.0
Spreading (High Isolation)
Distribute instances evenly across hosts.
[DEFAULT]
scheduler_weight_classes = nova.scheduler.weights.ram.RAMWeigher
[filter_scheduler]
enabled_filters = AvailabilityZoneFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,NUMATopologyFilter
ram_weight_multiplier = 1.0
Multi-Resource Weighing
Combine RAM, CPU, and Disk weighers.
[DEFAULT]
scheduler_weight_classes = nova.scheduler.weights.ram.RAMWeigher,nova.scheduler.weights.cpu.CPUWeigher,nova.scheduler.weights.disk.DiskWeigher
[filter_scheduler]
ram_weight_multiplier = 1.0
cpu_weight_multiplier = 1.0
disk_weight_multiplier = 1.0
Overcommit Ratios
Adjust virtual-to-physical ratios in /etc/nova/nova.conf.
[DEFAULT]
cpu_allocation_ratio = 4.0
ram_allocation_ratio = 1.5
disk_allocation_ratio = 1.0
Deployment Scenarios
Dev/Test (Stacking + High Overcommit)
Maximize density for non-critical workloads.
[filter_scheduler]
ram_weight_multiplier = -1.0
[DEFAULT]
cpu_allocation_ratio = 16.0
ram_allocation_ratio = 2.0
Production (Spreading + Low Overcommit)
Prioritize performance isolation.
[filter_scheduler]
ram_weight_multiplier = 1.0
[DEFAULT]
cpu_allocation_ratio = 2.0
ram_allocation_ratio = 1.0
Mixed Strategy via Host Aggregates
Apply different overcommit policies to specific host groups.
openstack aggregate create --availability-zone dev-zone dev-aggregate
openstack aggregate create --availability-zone prod-zone prod-aggregate
openstack aggregate add host dev-aggregate compute-dev-01
openstack aggregate add host prod-aggregate compute-prod-01
openstack aggregate add host prod-aggregate compute-prod-02
openstack aggregate set --property cpu_allocation_ratio=16.0 dev-aggregate
openstack aggregate set --property cpu_allocation_ratio=2.0 prod-aggregate
Verification
Check instance placement:
openstack server list --long -c Name -c Host -c Status
Review hypervisor resource usage:
openstack hypervisor list --long
openstack hypervisor show compute-01 -c vcpus_used -c memory_mb_used -c running_vms
Troubleshooting
- All VMs on one host: Set
ram_weight_multiplier = 1.0. - No valid host found: Check
enabled_filters, resource availability, and overcommit limits. - Uneven distribution: Verify
scheduler_weight_classesand multiplier signs. - OOM kills: Reduce
ram_allocation_ratioor increase physical RAM.