Configuring Resource Overcommitment
OpenStack supports overcommitting of CPU and memory resources on compute nodes. Overcommitting is a technique of allocating more virtualized CPUs and memory than physical resources available. This will increase the number of instances we are able to run on our cloud, but at the cost of reducing the performance of instances.
Allocation Ratios
OpenStack Compute uses the following ratios by default:
- CPU Allocation Ratio: 16:1
- RAM Allocation Ratio: 1.5:1
The default CPU allocation ratio of 16:1 means that the scheduler allocates up to16 virtual cores per physical core.
For example, if a physical node has 8 cores, the scheduler sees 128 available virtual cores. With typical flavor definitions of 4 virtual cores per instance, this ratio would provide 32 instances on a physical node.
Thus, we can conclude that the number of virtual instances on a compute node is:
Number of instances = (OR*PC)/VC
where:
PC: Number of physical cores
VC: Number of virtual cores per instance
OR: CPU overcommit Ratio
Similarly, the default RAM allocation ratio of 1.5:1 means that the scheduler
allocates instances to a physical node as long as the total amount of RAM
associated with the instances is less than 1.5 times the amount of RAM available
on the physical node. For example, if a physical node has 32 GB of RAM, the scheduler allocates instances to that node untill the sum of the RAM associated with the instances reaches 48 GB in total.
Choosing Overcommit Ratio
In this part, all contributing factors when selecting overcommit ratios, in the sense of available physical resources, are considered and discussed.
1. Factors in the choice of CPU allocation ratio
In general, the choice of CPU overcommitment ratio depends on:
- number of physical cores
- whether the CPU supports Hyper-Threading or Multithread Considerations
Note that Hyper-Threading is Intel's proprietary simultaneous multithreading implementation used to improve parallelization on their CPUs. Enabling this will improve the performance of multithreaded applications.
In our systems, for example, we would use CPUs with 4 physical and 4 hyper-thread cores. Thus we would have a total of 8 logical cores per CPU.
2. Factors in the choice of RAM allocation ratio
The choice of ram allocation ratio will influence the amount of swap space needed and hence, the amount of disk required. When calculating the required swap space, one should consider that the host physical machine's itself needs a maximum of 4 GB storage as well as an additional 4 GB as a swap space minimum.
Allocation ratios we would probably use?
System Specification:
- We are going to start with 10 systems, each having 32 GB of RAM and 4+4(hyper-thread) logical cores.
Our Goal:
- Satisfy both CPU intensive and IO intensive tasks with maximum possible efficiency.
Possible Solution CPU Ratio:
- 1 Compute Node: 1:1
- 1 Compute Node: 2:1
- 1 Compute Node: 3:1
- 3 Compute Node: 4:1
- 3 Compute Node: 16:1
Then:
- At best, we would have 16*8 = 128 cores in an instance/virtual machine
- A maximum of 128 instances per hypervisor if and only if one core assigned to each instance.
Possible Solution RAM Ratio:
- All compute Nodes: 1.2:1
Calculating Swap Space:
- 4 GB (for OS) + 4 GB (for system swap space) + 128 GB (maximum number of instances when each need 1 GB RAM only) = 136 GB
- Largest swap space required = 136 GB - 36 GB (RAM per node) = 104 GB
Then:
104 GB swap space per compute node is required.