## 5 Evaluated Algorithms
### Carbon- and Power-Efficient Optimal Frequency VM Placement (C-PEF)  
The C-PEF algorithmic approach is detailed in Algorithm 2. The proposed strategy allocates the new VMs to feasible servers, ensuring:(i)carbon-efficient clusters based on the PUE and carbon footprint rate (CFR);(ii) the power-efficient optimal operating frequency of servers; and(iii) a minimum increase in overall power after allocation. ```
Input:Clusterlist,Hostlist,reqQ Output:TargetVMQ
1 whileFM inReqQdo
2 TotClusterlist\(\leftarrow\)Get the clusters from theClusterlist of all datacenters;
3 sort the clusters inTotClusterlist in ascending order of (PUE*CFR) using Equation (7);
4 Forcluster inTotClusterlist do
5\(Mhostlist\leftarrow\)Get theHostlist fromcluster;
6 Forflow infruysep do
7 Forflow inMhostlistdo
8\(maxu\leftarrow\)Get utilizationequivalenttusingEquation (4);
9\(cur\_utt\leftarrow\)Get current utilizationusingEquation (4);
10\(remul\leftarrow\)maxu-cur\(\_utt\);
11 iffausible-flowedforVM then
12\(P1\leftarrow\)Get dynamicpowerofthestusingEquation (4);
13\(P2\leftarrow\)Get dynamicpowerofthestwithVM placementusingEquation (4);
14\(AP\leftarrow\)\(P2\_P1\);
15\(R1\leftarrow\)Get minimumremainingtaskexecutiontime;
16\(\Delta R\leftarrow\)Executiontimeoft\(\mathit{FM}\)-\(R1\);
17\(Selected\_Host\)-add(host);
18
19 SortedHost\(\leftarrow\)NULLthen
20 SorttheSelected\(\_Host\) in non decreasing order of \(\Delta P\);
21\(choose\_host\)\(\leftarrow\)Get thehostfromSelected\(\_Host\)withpositive\(\Delta R\);
22\(Select\_Host\)-GetthedifferencebetweenSelected\(\_Host\)andchoose-host;
23\(\mathit{SP}\_pop\)-\(



The aim of the C-PEF algorithm is to distribute the load within the cluster. Each server is set to its minimum utilization level. The utilization level is increased gradually when the VM allocation is not feasible at the current utilization level. The greedy selection of the destination hosts for the VMs among the feasible hosts is based on a minimum increase in overall power consumption at the current utilization level. The utilization of each node is reduced to an extent by distributing the load without performance compromise to avoid hotspots due to CPU turbulence. Each node is utilized at the required minimum utilization level as much as possible. Algorithm 2 receives the _Clusterlist_ of all data centers, the _Hostlist_ of each cluster, and the VM resource request through _ReqQ_. Lines 2 and 3 consolidate the entire cluster list into the _Totclusterlist_. The algorithm considers the carbon footprint rate (CFR) and power usage effectiveness (PUE) for cluster selection and sorts the _Totclusterlist_ in ascending order based on PUE \(\times\) CFR. The greedy search, considering power limited to the current utilization level, is performed in line 6 of Algorithm 2. The feasible host system with nominal operating frequency for _VM_ placement is identified as the _SelectedHost_. The difference in dynamic power before and after _VM_ placement, \(\Delta P\), is calculated in line 14 of Algorithm 2. The power consumption _P2_ is not constant throughout the execution of the _VM_, as it depends on the next incoming and outgoing tasks of the machine to which it is allocated. As the incoming task is not known in advance, the known details of outgoing tasks based on the remaining execution time and utilization level are used effectively to predict the dynamic power. This approach has an impact if there is a time gap between the first request submission and the next. The destination host (_Desthost_) is identified based on the new _VM(NVM)_ execution time and the next outgoing task's remaining execution time in lines 21-33 in algorithm 2. Figure 2 diagrammatically elucidates lines 21-23 with an example. Assume \(M_{1}\), \(M_{2}\), \(M_{3}\), \(M_{4}\), and \(M_{5}\) are machines in the _SelectedHost_. The execution time of the NVM is assumed to be 8 units.