# A Novel Self-Adaptive VM Consolidation Strategy Using Dynamic Multi-Thresholds in IaaS Clouds
## 3 Novel Self-Adaptive VM Consolidation Strategy
### The Improved MW-MVM Algorithm for VM Selection  
To efficiently choose proper target VMs on each selected \(Source_{PM}\) with fewer VM migrations, [11] first proposed MVM (Minimization of VM Migration) algorithm. The main idea of this method is to sort the CPU utilization of each VM in descending order, and then select the targeted VM to migrated out in two criterions. One of the criterion is that the VM's CPU utilization should be higher than the difference between the upper threshold and each PM's present overall CPU utilization. Another criterion is that, compared to values on all VMs, the difference between the new utilization and the upper threshold on each selected VM is the minimum. If there is no suitable VM that satisfied these two criteria, the VM in \(Source_{PM}\) that has the highest resource utilization will be selected. Unless the new utilization of this source PM is under the upper threshold, all of the above processes will not be repeated any more. The inadequacy of this method is that it only takes one parameter (CPU utilization) into consideration, while different overload PMs usually have different requests on other resources. Based on that, we try to improve this method within our multi-thresholds by using different weights to efficiently allocate VMs. Below is an example showing the detail of our improved method. Assume that the current multi-thresholds are \(T=~{}\langle T_{l},~{}~{}T_{u},~{}T_{SLA},~{}T_{m}\rangle\), and the load thresholds are \(T_{l}=\langle t_{c},~{}t_{r},t_{b}\rangle,~{}T_{u}=\langle T_{c},~{}T_{r},T_{b}\rangle\). The utilization ratio of resource * on \(PM(j)\) can be calculated as  
\[P_{j}^{*}=\frac{U_{pmj}^{*}}{C_{pmj}^{*}}=\frac{\sum_{i=1}^{m}U_{p_{j}v_{i}}^{*} }{C_{pmj}^{*}} \tag{6}\]  
where * represents CPU in \(c\), RAM in \(r\), Bandwidth in \(b\), respectively. Thus, resource utilization ratio on \(PM(j)\) can be expressed as \(P_{j}=\left[~{}P_{j}^{c},~{}P_{j}^{r},~{}P_{j}^{b}~{}\right]\). We define the formula for the relative difference \(Q_{j}^{*}\) between upper threshold and actual utilization of resource * on \(PM(j)\) as  
\[Q_{j}^{*}=\left\{ \begin{array}{cc}P_{j}^{*}-T_{*},&if~{}(P_{j}^{*}>T_{*})\\ 0,&else\end{array} \right. \tag{7}\]  
Thus, the relative different of \(PM(j)\) is \(Q_{j}=\left[~{}Q_{j}^{c},~{}Q_{j}^{r},~{}Q_{j}^{b}~{}\right]\), which can then be used as the weights for choosing minimum number VMs since the weights showing the maximize corresponding overload of each resource on \(PM(j)\). The weights of all VMs on \(PM(j)\) can then be calculated as  
\[ \begin{array}{rl}W_{VM}&=U_{p_{j}v_{i}}^{*}\cdot{Q_{j}}^{T}\\ &=\left[~{}U_{p_{j}v_{i}}^{c}~{}~{}~{}U_{p_{j}v_{i}}^{r}~{}~{}~{}U_{p_{j}v_{i}} ^{b}~{}\right]\cdot\left[\begin{array}{c}Q_{j}^{c}\\ Q_{j}^{r}\\ Q_{j}^{b}\end{array}\right]\\ &=\left[\begin{array}{c}W_{p_{j}v_{1}}\\ W_{p_{j}v_{2}}\\ \vdots\\ W_{p_{j}v_{m}}\end{array}\right]\end{array}  \tag{8}\]  
Here \(U_{p_{j}v_{i}}^{*}\) represents the allocated resource in each VM, which indicates the number of various resources that the virtual machine has occupied and \({Q_{j}}^{T}\) calculated by (7) shows the difference of each threshold, as the higher value of each resource means the more corresponding of migration requests. Thus, by multiplying \(U_{p_{j}v_{i}}^{*}\) and \({Q_{j}}^{T}\), the weight of all VMs in \(PM(j)\) can be calculated. For \(VM(i)\) in \(PM(j)\), its weight is represented as \(W_{p_{j}v_{1}}\), which is used to decide the selection of target VM, as well as the number of VMs that need to be migrated out. To minimize VM migration times, all weights are sorted in descending order. As the higher the weight is, the higher the corresponding request is, the lower the migration times will be. The host (\(PM(j)\)) first select the VM with the highest weights and add it to the waiting list, then it will be checked again for being overload (Algorithm 3). If it is still considered as being overloaded, the VM selection policy is applied again to select another VM to migrate from the host.