(1) Identify the number of executing/pending tasks in each VM and arrange it in increasing order on a Queue. |
(a) Set numTaskInQueue = Number of Executing/Waiting Tasks in each VM and arrange it in increasing order |
(2) If the number of tasks in the first item of the queue is greater than or equal to “1”, then terminate the Load Balancing logic |
execution else proceed to the 3rd step. |
(a) If (numTaskInQueue.first() ≥1) then |
Return; |
(3) If the number of tasks in the last item of the queue is less than or equal to “1”, then terminate the Load Balancing logic |
execution else proceed to the 4th step. |
(a) If (numTaskInQueue.last() ≤1) then |
Return; |
(4) Identify the Pending Execution Time in each of the VMs by adding the Pending Execution length from executing, |
waiting & paused list and then divided the value by the processing capacity of the VM. |
(a) Set pendingJobsTotLength = JobsRemainingLengthInExecList + JobsRemainingLengthInWaitList + |
JobsRemainingLengthInPauseList |
(b) Set pendingExecutionTime = pendingJobsTotLength/ |
(5) Arrange the VMs based on the least pending time to the highest pending time and group it, in case two VMs fall |
in the same pending time. |
(a) Sort the VMMap by the Pending Execution time of each VM |
(6) Remove a task from the higher pending time VM, which contains more than one task and assign this task to the lower |
pending time VM, which has no task to process. |
(a) While (true) |
Set OverLoadedVM = VMMap.get(VMMap.size()) |
Set LowLoadedVM = VMMap.get(0) |
Varlowerposition = 1; |
Varupperposition = 1; |
(b) While(true) |
If (OverLoadedVM.taskSize() > 1 &&LowLoadedVM.taskSize() < 1) |
Break; |
Else if (OverLoadedVM.taskSize() > 1) |
LowLoadedVM = VMMap.get(lowerposition) |
Lowerposition++ |
Else if (LowLoadedVM.taskSize() < 1) |
OverLoadedVM = VMMap.get(VMMap.size() - upperposition) |
Upperposition++ |
Else |
Break The Outer While Loop |
(c) End While |
Set migratableTask = OverLoadedVM.getMigratableTask() |
LowLoadedVM.assign(migratableTask) |
Break |
(d) End While |
(7) Re execute from the step 1 |
(8) Then the steps 2 and 3 will decide the load balancing further. |
(9) This load balancing will be called after every task completion irrespective of any VMs. |