How to Demonstrate the Effect of Host Underutilization on Energy Consumption and Resource Efficiency in ContainerCloudSim?
Share
Condition for Demonstrate the Effect of Host Underutilization on Energy Consumption and Resource Efficiency in ContainerCloudSim
Description: To demonstrate the underloaded scenario using ContainerCloudSim, where the infrastructure consists of 15 physical hosts, but only 8 virtual machines and 10 containers are deployed. This imbalance intentionally creates low workload density, simulating real-world cases such as night-time traffic drops or over-provisioned deployments. During execution, resource monitoring and utilization analysis reveal multiple idle or underutilized hosts, highlighting significant power wastage. To mitigate this inefficiency, we further evaluate consolidation strategies based on host selection and VM migration policies, aiming to determine the optimal number of active hosts required to maintain workload performance while minimizing energy usage. This experiment provides insights into when and how cloud providers should consolidate workloads to achieve eco-efficient containerized data centers.
/**
* Underloaded Scenario: Too few containers for too many hosts
* Demonstrates resource wastage and consolidation strategies
*/
public class ContainerCloudsimUnderloaded {
private static List cloudletList;
private static List vmList;
private static List containerList;
private static List hostList;
private static ContainerDatacenterBroker broker;
// Custom constants for underloaded scenario
private static class UnderloadConstants {
// Creating severe underload: Many hosts, few containers
public static final int NUMBER_HOSTS = 15; // Many hosts
public static final int NUMBER_VMS = 8; // Fewer VMs than hosts
public static final int NUMBER_CONTAINERS = 10; // Very few containers
public static final int NUMBER_CLOUDLETS = 10;
}
hostList = createHostList(UnderloadConstants.NUMBER_HOSTS);
cloudletList = new ArrayList();
vmList = new ArrayList();
ContainerVmAllocationPolicy vmAllocationPolicy =
new PowerContainerVmAllocationPolicyMigrationAbstractHostSelection(
hostList, vmSelectionPolicy, hostSelectionPolicy,
overUtilizationThreshold, underUtilizationThreshold);
int overBookingFactor = 95; // Higher overbooking since we have plenty of resources
broker = createBroker(overBookingFactor);
int brokerId = broker.getId();
if (avgUtilization < 0.30) {
Log.printLine(" LOW UTILIZATION DETECTED - Significant consolidation opportunity!");
} else if (avgUtilization < 0.50) {
Log.printLine(" MEDIUM UTILIZATION - Some consolidation possible");
}
}
/**
* Calculate host utilization (simplified simulation)
*/
private static double calculateHostUtilization(ContainerHost host) {
// Simulate low utilization for underloaded scenario
// In real implementation, this would use actual metrics from the host
return 0.1 + (Math.random() * 0.3); // Between 10% and 40% utilization
}
int recommendedHosts = Math.max(2, UnderloadConstants.NUMBER_VMS / 2);
Log.printLine("1. Reduce host count from " + UnderloadConstants.NUMBER_HOSTS + " to " + recommendedHosts);
Log.printLine("2. Implement VM live migration to consolidate workloads");
Log.printLine("3. Use power-saving modes for idle hosts");
Log.printLine("4. Deploy container density optimization");
Log.printLine("5. Consider dynamic right-sizing based on workload patterns");
Log.printLine("6. Implement auto-scaling to shut down unused hosts during low demand");
if (UnderloadConstants.NUMBER_HOSTS > UnderloadConstants.NUMBER_VMS) {
Log.printLine("7. Match host count to VM count (" + UnderloadConstants.NUMBER_VMS + " hosts)");
}
}
// Modified existing methods for underload scenario
private static String getExperimentName(String... args) {
StringBuilder experimentName = new StringBuilder();
for (int i = 0; i < args.length; ++i) {
if (!args[i].isEmpty()) {
if (i != 0) experimentName.append("_");
experimentName.append(args[i]);
}
}
return experimentName.toString();
}
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 % 2;
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 % 3;
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;
}
return new PowerContainerDatacenterCM(name, characteristics, vmAllocationPolicy,
containerAllocationPolicy, new LinkedList(), schedulingInterval,
experimentName, logAddress, VMStartupDelay, ContainerStartupDelay);
}
public static List createContainerList(int brokerId, int containersNumber) {
ArrayList containers = new ArrayList();
for (int i = 0; i < containersNumber; ++i) {
int containerType = i % 3;
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) {
if (aFiles1.isDirectory()) {
java.io.File inputFolder = new java.io.File(aFiles1.toString());
java.io.File[] files = inputFolder.listFiles();
if (files != null) {
for (int i = 0; i < files.length; ++i) {
if (createdCloudlets < numberOfCloudlets) {
try {
ContainerCloudlet cloudlet = new ContainerCloudlet(
IDs.pollId(ContainerCloudlet.class),
ConstantsExamples.CLOUDLET_LENGTH, 1,
fileSize, outputSize,
new UtilizationModelPlanetLabInMemoryExtended(files[i].getAbsolutePath(), 300.0D),
utilizationModelNull, utilizationModelNull);