How to Evaluate the Impact of the Least Full Container Placement Policy on Resource Utilization, Load Balancing, and Performance in Containercloudsim?
Share
Condition for Evaluate the Impact of the Least Full Container Placement Policy on Resource Utilization
Description: This research investigates the effectiveness of the Least Full container placement policy in achieving optimal resource utilization and workload balancing within containerized cloud data centers. Using the ContainerCloudSim simulation framework, the study evaluates the dynamic allocation of containers to virtual machines (VMs) based on available computational resources. The proposed framework integrates host and VM selection strategies, including HostSelectionPolicyFirstFit and PowerContainerVmSelectionPolicyMaximumUsage, with the Least Full placement algorithm to distribute workloads evenly across the infrastructure. PlanetLab workload traces are utilized to emulate realistic cloud behavior, enabling detailed analysis of CPU utilization, execution time, and success rate. The simulation captures pre- and post-placement performance statistics, including average utilization, load balance efficiency, execution variance, and success ratio. Experimental results demonstrate how the Least Full policy effectively reduces resource imbalance and improves the efficiency and scalability of containerized cloud operations, offering insights for energy-aware and SLA-compliant scheduling strategies in cloud environments.
/**
* Comprehensive analysis of Least Full Container Placement Policy
*/
public class PlacementPolicyLeastFull {
private static List cloudletList;
private static List vmList;
private static List containerList;
private static List hostList;
// Statistics for Least Full analysis
private static LeastFullStats leastFullStats;
public static void main(String[] args) {
Log.printLine("Starting Least Full Container Placement Policy Analysis...");
leastFullStats = new LeastFullStats();
// Get results and analyze
List completedCloudlets = broker.getCloudletReceivedList();
printCloudletList(completedCloudlets);
analyzeLeastFullResults(completedCloudlets, containerList, vmList);
printLeastFullStatistics();
Log.printLine("Least Full Container Placement Analysis finished!");
/**
* Analyze Least Full placement pattern
*/
private static void analyzeLeastFullPlacement(List containers, List vms) {
Log.printLine("\n=== LEAST FULL PLACEMENT ANALYSIS ===");
// Simulate Least Full placement
ContainerPlacementPolicy leastFullPolicy = new ContainerPlacementPolicyLeastFull();
Map vmContainerCount = new HashMap<>();
Map vmCpuUtilization = new HashMap<>();
Map vmRamUtilization = new HashMap<>();
Map initialAvailableMips = new HashMap<>();
// Initialize maps and record initial available MIPS
for (ContainerVm vm : vms) {
vmContainerCount.put(vm.getId(), 0);
vmCpuUtilization.put(vm.getId(), 0.0);
vmRamUtilization.put(vm.getId(), 0.0);
initialAvailableMips.put(vm.getId(), vm.getContainerScheduler().getAvailableMips());
}
Log.printLine("Initial Available MIPS per VM:");
for (ContainerVm vm : vms) {
Log.printLine(String.format("VM %d: %.2f MIPS available",
vm.getId(), initialAvailableMips.get(vm.getId())));
}
// Simulate placement for each container
List containersCopy = new ArrayList<>(containers);
for (Container container : containersCopy) {
ContainerVm selectedVm = leastFullPolicy.getContainerVm(vmList, container, new HashSet());
if (selectedVm != null) {
// Update statistics
int vmId = selectedVm.getId();
vmContainerCount.put(vmId, vmContainerCount.get(vmId) + 1);
/**
* Analyze Least Full results after simulation
*/
private static void analyzeLeastFullResults(List completedCloudlets,
List containers, List vms) {
Log.printLine("\n=== LEAST FULL PERFORMANCE RESULTS ===");
Map> vmExecutionTimes = new HashMap<>();
Map vmSuccessCount = new HashMap<>();
Map vmTotalMips = new HashMap<>();
// Initialize maps
for (ContainerVm vm : vms) {
vmExecutionTimes.put(vm.getId(), new ArrayList());
vmSuccessCount.put(vm.getId(), 0);
vmTotalMips.put(vm.getId(), vm.getMips());
}
// Analyze completed cloudlets
for (ContainerCloudlet cloudlet : completedCloudlets) {
if (cloudlet.getCloudletStatusString().equals("Success")) {
int vmId = cloudlet.getVmId();
double executionTime = cloudlet.getActualCPUTime();
// Calculate performance metrics per VM
Log.printLine("\nVM ID | Success Count | Avg Time (s) | Std Dev | MIPS | Efficiency");
Log.printLine("------|--------------|--------------|----------|-------|------------");
for (ContainerVm vm : vms) {
int vmId = vm.getId();
List times = vmExecutionTimes.get(vmId);
int successCount = vmSuccessCount.get(vmId);
double totalMips = vmTotalMips.get(vmId);
for (List times : vmExecutionTimes.values()) {
if (!times.isEmpty()) {
totalAvgTime += times.stream().mapToDouble(Double::doubleValue).average().orElse(0);
vmCount++;
}
}
/**
* Print comprehensive Least Full statistics
*/
private static void printLeastFullStatistics() {
Log.printLine("\n=== LEAST FULL STATISTICS SUMMARY ===");
/**
* Analyze placement patterns for Least Full
*/
private static void analyzeLeastFullPlacementPatterns() {
Log.printLine("\n=== LEAST FULL PLACEMENT PATTERN ANALYSIS ===");
// Count containers per VM in placement sequence
Map placementDistribution = new HashMap<>();
for (Placement placement : leastFullStats.placementSequence) {
placementDistribution.put(placement.vmId,
placementDistribution.getOrDefault(placement.vmId, 0) + 1);
}
private static ArrayList createVmList(int brokerId, int containerVmsNumber) {
ArrayList containerVms = new ArrayList();
for (int i = 0; i < containerVmsNumber; ++i) {
ArrayList peList = new ArrayList();
int vmType = i / (int) Math.ceil((double) containerVmsNumber / 4.0D);
for (int j = 0; j < ConstantsExamples.VM_PES[vmType]; ++j) {
peList.add(new ContainerPe(j,
new ContainerPeProvisionerSimple((double) ConstantsExamples.VM_MIPS[vmType])));
}
containerVms.add(new PowerContainerVm(IDs.pollId(ContainerVm.class), brokerId,
(double) ConstantsExamples.VM_MIPS[vmType], (float) ConstantsExamples.VM_RAM[vmType],
ConstantsExamples.VM_BW, ConstantsExamples.VM_SIZE, "Xen",
new ContainerSchedulerTimeSharedOverSubscription(peList),
new ContainerRamProvisionerSimple(ConstantsExamples.VM_RAM[vmType]),
new ContainerBwProvisionerSimple(ConstantsExamples.VM_BW),
peList, ConstantsExamples.SCHEDULING_INTERVAL));
}
return containerVms;
}
public static List createHostList(int hostsNumber) {
ArrayList hostList = new ArrayList();
for (int i = 0; i < hostsNumber; ++i) {
int hostType = i / (int) Math.ceil((double) hostsNumber / 3.0D);
ArrayList peList = new ArrayList();
for (int j = 0; j < ConstantsExamples.HOST_PES[hostType]; ++j) {
peList.add(new ContainerVmPe(j,
new ContainerVmPeProvisionerSimple((double) ConstantsExamples.HOST_MIPS[hostType])));
}
hostList.add(new PowerContainerHostUtilizationHistory(IDs.pollId(ContainerHost.class),
new ContainerVmRamProvisionerSimple(ConstantsExamples.HOST_RAM[hostType]),
new ContainerVmBwProvisionerSimple(1000000L), 1000000L, peList,
new ContainerVmSchedulerTimeSharedOverSubscription(peList),
ConstantsExamples.HOST_POWER[hostType]));
}
return hostList;
}
ContainerDatacenter datacenter = new PowerContainerDatacenterCM(name, characteristics, vmAllocationPolicy,
containerAllocationPolicy, new LinkedList(), schedulingInterval, experimentName, logAddress,
VMStartupDelay, ContainerStartupDelay);
return datacenter;
}
public static List createContainerList(int brokerId, int containersNumber) {
ArrayList containers = new ArrayList();
for (int i = 0; i < containersNumber; ++i) {
int containerType = i / (int) Math.ceil((double) containersNumber / 3.0D);
containers.add(new PowerContainer(IDs.pollId(Container.class), brokerId,
(double) ConstantsExamples.CONTAINER_MIPS[containerType],
ConstantsExamples.CONTAINER_PES[containerType],
ConstantsExamples.CONTAINER_RAM[containerType],
ConstantsExamples.CONTAINER_BW, 0L, "Xen",
new ContainerCloudletSchedulerDynamicWorkload(
ConstantsExamples.CONTAINER_MIPS[containerType],
ConstantsExamples.CONTAINER_PES[containerType]),
ConstantsExamples.SCHEDULING_INTERVAL));
}
return containers;
}
public static List createContainerCloudletList(int brokerId, int numberOfCloudlets)
throws FileNotFoundException {
String inputFolderName = "/home/soft13/soft13/Project 2019/Cloudsim-4.0-examples/src/workload/planetlab";
ArrayList cloudletList = new ArrayList();
long fileSize = 300L;
long outputSize = 300L;
UtilizationModelNull utilizationModelNull = new UtilizationModelNull();
java.io.File inputFolder1 = new java.io.File(inputFolderName);
java.io.File[] files1 = inputFolder1.listFiles();
int createdCloudlets = 0;
for (java.io.File aFiles1 : files1) {
java.io.File inputFolder = new java.io.File(aFiles1.toString());
java.io.File[] files = inputFolder.listFiles();
for (int i = 0; i < files.length; ++i) {
if (createdCloudlets < numberOfCloudlets) {
ContainerCloudlet cloudlet = null;
try {
cloudlet = new ContainerCloudlet(IDs.pollId(ContainerCloudlet.class),
ConstantsExamples.CLOUDLET_LENGTH, 1, fileSize, outputSize,
new UtilizationModelPlanetLabInMemoryExtended(files[i].getAbsolutePath(), 300.0D),
utilizationModelNull, utilizationModelNull);
} catch (Exception var13) {
var13.printStackTrace();
System.exit(0);
}
cloudlet.setUserId(brokerId);
cloudletList.add(cloudlet);
createdCloudlets += 1;
} else {
return cloudletList;
}
}
}
return cloudletList;
}
/**
* Statistics class for Least Full analysis
*/
static class LeastFullStats {
int totalPlacements = 0;
int successfulCloudlets = 0;
double totalExecutionTime = 0;
double minExecutionTime = -1;
double maxExecutionTime = 0;
double overallAvgExecutionTime = 0;
double minVmUtilization = -1;
double maxVmUtilization = 0;
double averageUtilization = 0;
double utilizationStdDev = 0;
double loadBalanceEfficiency = 0;
double successRate = 0;
List vmUtilization = new ArrayList<>();
List availableMipsAtPlacement = new ArrayList<>();
List placementSequence = new ArrayList<>();
Map vmAvgTimes = new HashMap<>();
Map vmEfficiency = new HashMap<>();
Map finalVmUtilization = new HashMap<>();
}
/**
* Placement record class
*/
static class Placement {
int containerId;
int vmId;