CDRAM
5.2 Proposed Algorithm
5. VM Migration for Profit Maximization in Federated Cloud
The above formulation is a variant of dynamic bin packing problem which is NP-hard, where VMs are the items and DCs are the bins, and VMs can be migrated across the DCs [131]. Hence, the formulated problem is NP-hard. We propose a heuristic algorithm to solve the problem in polynomial time.
5.2. Proposed Algorithm
ALGORITHM 7: CAVMA Cost AwareVMMigrationAlgorithm Input: Dp: The list of DCs of CPp
V: The list of virtual machines Output: ResM ap(V Mi,Dql)
1 Initialization:
2 SrcDC←N U LL;
3 SrcV M ←N U LL;
4 DesDC←N U LL;
5 SortDp in desc order based on hSrcDC;
6 SrcDC←Dp.head;
7 while(SrcDC6=N U LL) do
8 SortVSrcDC in desc order based onhSrcV M;
9 SrcV M ←VSrcDC.head;
10 while(SrcV M 6=N U LL)do
11 if (ySrcV M 6= 0)then
12 DesDC=SelectDesDC(SrcV M, SrcDC);
13 if (DesDC6=N U LL)then
14 Migrate(SrcV M, SrcDC, DesDC);
15 UpdateResM ap(SrcV M, DesDC);
16 SrcV M ←SrcV M.next;
17 SrcDC←SrcDC.next;
18 returnResM ap;
impacts the migration cost. We definemigration benefit, M Bipk,ql to indicate the profit that can be obtained by migratingV Mi fromDpk to Dql after subtracting the cost of migration as
M BiDpk,Dql =V Mit(pricepki −priceqli )−M Cipk.ql (5.23) where the life time ofV Mi is taken as a factor since the migration profit increases for VMs with longer life time. We use Eq.5.23 to select the potential destination DC (Dql).
We propose Cost-Aware VM Migration Algorithm (CAVMA) to select the source DC, the source VM, and the destination DC for migration based on the aforementioned heuristics. Algorithm 7 shows the steps in the algorithm. It takes as inputDp, the list of DCs of CPp andV, the list of VMs, to return ResM ap, the updated VM placement after migration (ResM ap maps VMs to DCs). The steps of the algorithm are as follows:
1. First, the algorithm initializes the variablesSrcDc, SrcV M, andDesDcfor migration (lines 1-4). It then sortsDp in decreasing order based on hSrcDC (computed using Eq.5.21). Then, it selects the first DC in sorted Dp as SrcDC, that gives the highest
5. VM Migration for Profit Maximization in Federated Cloud
operating cost (lines 5-6).
2. It sortsVSrcDC, the list of VMs placed inSrcDCin decreasing order based onhSrcV M (using Eq.5.22) and then takes the first VM asSrcV M (lines 8-9).
3. If SrcV M is eligible for migration (yi = 1), then select the destination DC for migrationDesDC, otherwise the algorithm moves to the next VM (line 11).
4. The algorithm selects DesDC by calling SelectDesDC algorithm (explained later) (line 12).
5. If a suitable DesDC is found that makes the migration of SrcV M beneficial with a relatively short migration time, the algorithm migrates SrcV M from SrcDC to DesDC, and then updates the location ofSrcV M inResM ap (lines 13-15).
6. It repeats Steps (3) to (5) for all VMs inSrcDCby checking sortedVSrcDC sequentially, and it migrates only VMs that are eligible for migration and whose migration is beneficial (lines 10-16).
7. The algorithm repeats Steps (2) to (6) for all DCs of CP pin order (∀SrcDC ∈Dp) (lines 7-17).
8. Finally, the execution of the migration algorithm returns ResM ap, the updated location of VMs of CPp (line 18).
Next, we discuss the algorithm,SelectDesDCto select the best destination DC for migrating a VM, that returns the highest profit with a relatively short migration time.
Algorithm 8 shows the steps of the proposed algorithm. It takes as input, SrcV M and SrcDC, the source VM and the source DC for migration, respectively, andF−the list of FCMs of the CPs in the federation. It returnsDesDC, the selected Destination DC in the federation (DesDC∈D) to migrateSrcV M. We describe the steps of the algorithm below:
1. The algorithm defines DClist as the list of DCs in the federation which includes initially only local DCsDp, and it initializesDesDC toN U LL (lines 1-3).
2. Fp contacts FCMs and requests information of their DCs (resource availability and price), based on which it updatesDClist (lines 4-7).
5.2. Proposed Algorithm
ALGORITHM 8: SelectDesDC
Input: SrcV M: The source VM to be migrated SrcDC: The source DC of migration F: List of FCMs
Output: DesDC: The selected destination DC
1 Initialization:
2 DClist←Dp;
3 DesDC←N U LL;
4 foreachFq ∈Fdo
5 Request(resAvailql, f edP riceqli )of allDql∈Dq;
6 Receive(Dql, resAvailql, f edP riceqli )from Fq;
7 UpdateDClist;
8 foreachDql∈DClistdo
9 CalculateM BSrcV MSrcDC,Dql;
10 SortDClistin Desc order based onM BSrcDC,DSrcV M ql;
11 DesDC←DClist.head;
12 if (DesDC==SrcDC)then
13 returnN U LL;
14 while(M BSrcDC,DesDC
SrcV M >0)do
15 if ( (resAvailDesDC >SrcV MresDemand) ∧ (V MSrcV MP DR < BWSrcDC,DesDC))then
16 returnDesDC;
17 else
18 DesDC←DesDC.next;
19 returnN U LL;
3. The algorithm calculates the benefit of migratingSrcV M to each DC inDClistusing Eq.5.23. Then, it sorts DClist in decreasing order of migration benefit and selects the first DC that gives the highest migration benefit as potential DesDC (lines 8-11).
4. IfDesDC is same as SrcDC, it means that the current DC ofSrcV M is the best location for it and there is no benefit in migrating SrcV M to any other DC. The algorithm returns N U LL (line 12-13). In this case, there might be profit due to migrating SrcV M to another DC, but the migration cost is more than the profit; that leads to a negative migration benefit increasing the TCO instead of decreasing it.
5. Otherwise, the algorithm scans the sortedDClist and selectsDesDC as the first DC with (i) positive migration benefit, (ii) it has enough resources forSrcV M, and (iii) the available bandwidth between SrcDC and this DesDC is larger than the PDR of SrcV M, which is to minimize the migration time and the downtime (lines 14-18).
5. VM Migration for Profit Maximization in Federated Cloud
Figure 5.3: Federated cloud system for simulation
6. The algorithm returnsN U LL if there is no DC that meets the previous conditions (line 19).
In summary, the proposed algorithm minimizes the cost of the CPp by migrating only the VMs, whose migration gives a profit by selecting the VMs to give the highest migration benefit. While deciding the destination DC, it considers the network bandwidth and data transfer price to minimize the migration time, downtime, and the migration cost.
Time and Space Complexity: Let L be the number of DCs of the CP p (|Dp|), M be the of number DCs in the federation (|D|), and N be the number of VMs (|V|) where (L < M << N). The algorithm first sortsDpinO(Llog(L)), then it sortsVinO(Nlog(N)).
Next, for everyV Mi∈V,SelectDesDC sorts D, that takesO(N Mlog(M)). Therefore, the time complexity of the algorithm is O(N(logN+MlogM)). The space complexity is O(L+M+N); that isO(N).