How to Analyze the Impact of Different Scheduling Intervals on Resource Utilization,Execution Time,and Task Efficiency in Containercloudsim?
Share
Condition for Analyze the Impact of Different Scheduling Intervals on Resource Utilization,Execution Time,and Task Efficiency in Containercloudsim
Description: It implements a comparative simulation framework using ContainerCloudSim, extending CloudSim to analyze the impact of different scheduling intervals on containerized workloads in a cloud data center. The code dynamically configures multiple simulations by varying the scheduling interval values (1.0, 5.0, 10.0, and 30.0 seconds) and measures their performance across multiple metrics such as average execution time, waiting time, success rate of cloudlets, and overall simulation runtime. For each interval, the infrastructure—including hosts, VMs, containers, and PlanetLab-based real workload cloudlets—is instantiated with consistent configurations to ensure a fair comparison. After executing the simulations, the system aggregates results and identifies the optimal scheduling interval based on execution efficiency and workload responsiveness. This experiment provides valuable insights into how fine-grained or coarse-grained scheduling intervals influence performance in containerized cloud environments, aiding in optimization of energy-aware and SLA-driven scheduling policies.
/**
* A simple example showing how to create a data center with one host, one VM,
* one container and run one cloudlet on it.
* Testing different scheduling intervals
*/
public class SchedulingInterval {
/**
* The cloudlet list.
*/
private static List cloudletList;
/**
* The vmlist.
*/
private static List vmList;
/**
* The vmlist.
*/
private static List containerList;
/**
* The hostList.
*/
private static List hostList;
/**
* Creates main() to run this example.
*
* @param args the args
*/
public static void main(String[] args) {
Log.printLine("Starting Scheduling Intervals Comparison...");
try {
// Define different scheduling intervals to test
double[] schedulingIntervals = {1.0, 5.0, 10.0, 30.0};
// Store results for each interval
List results = new ArrayList<>();
for (double interval : schedulingIntervals) {
Log.printLine("\n" + "=".repeat(60));
Log.printLine("Running simulation with scheduling interval: " + interval);
Log.printLine("=".repeat(60));
SimulationResult result = runSimulationWithInterval(interval);
results.add(result);
// Small delay between simulations
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
/**
* Runs a complete simulation with the specified scheduling interval
*/
private static SimulationResult runSimulationWithInterval(double schedulingInterval) {
SimulationResult result = new SimulationResult(schedulingInterval);
try {
// Initialize CloudSim for this simulation run
int num_user = 1;
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false;
CloudSim.init(num_user, calendar, trace_flag);
// Define policies
ContainerAllocationPolicy containerAllocationPolicy = new PowerContainerAllocationPolicySimple();
PowerContainerVmSelectionPolicy vmSelectionPolicy = new PowerContainerVmSelectionPolicyMaximumUsage();
HostSelectionPolicy hostSelectionPolicy = new HostSelectionPolicyFirstFit();
// Print results for this interval
printIntervalResults(result, completedCloudlets);
} catch (Exception e) {
e.printStackTrace();
Log.printLine("Error in simulation with interval " + schedulingInterval);
} finally {
// Shutdown CloudSim for this run
CloudSim.stopSimulation();
}
return result;
}
/**
* Prints results for a single scheduling interval
*/
private static void printIntervalResults(SimulationResult result, List completedCloudlets) {
Log.printLine("\n--- RESULTS for Scheduling Interval: " + result.getSchedulingInterval() + " ---");
/**
* Data class to store simulation results
*/
private static class SimulationResult {
private double schedulingInterval;
private int successfulCloudlets;
private int totalCloudlets;
private double avgExecutionTime;
private double avgWaitTime;
private double maxExecutionTime;
private double minExecutionTime;
private long simulationTime;
private List completedCloudlets;
private PowerContainerDatacenter datacenter;
public SimulationResult(double schedulingInterval) {
this.schedulingInterval = schedulingInterval;
}
// Getters and setters
public double getSchedulingInterval() { return schedulingInterval; }
public int getSuccessfulCloudlets() { return successfulCloudlets; }
public void setSuccessfulCloudlets(int successfulCloudlets) { this.successfulCloudlets = successfulCloudlets; }
public int getTotalCloudlets() { return totalCloudlets; }
public void setTotalCloudlets(int totalCloudlets) { this.totalCloudlets = totalCloudlets; }
public double getAvgExecutionTime() { return avgExecutionTime; }
public void setAvgExecutionTime(double avgExecutionTime) { this.avgExecutionTime = avgExecutionTime; }
public double getAvgWaitTime() { return avgWaitTime; }
public void setAvgWaitTime(double avgWaitTime) { this.avgWaitTime = avgWaitTime; }
public double getMaxExecutionTime() { return maxExecutionTime; }
public void setMaxExecutionTime(double maxExecutionTime) { this.maxExecutionTime = maxExecutionTime; }
public double getMinExecutionTime() { return minExecutionTime; }
public void setMinExecutionTime(double minExecutionTime) { this.minExecutionTime = minExecutionTime; }
public long getSimulationTime() { return simulationTime; }
public void setSimulationTime(long simulationTime) { this.simulationTime = simulationTime; }
public List getCompletedCloudlets() { return completedCloudlets; }
public void setCompletedCloudlets(List completedCloudlets) { this.completedCloudlets = completedCloudlets; }
public PowerContainerDatacenter getDatacenter() { return datacenter; }
public void setDatacenter(PowerContainerDatacenter datacenter) { this.datacenter = datacenter; }
}
/**
* It creates a specific name for the experiment which is used for creating
* the Log address folder.
*/
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();
}
/**
* Create the Virtual machines and add them to the list
*/
private static ArrayList createVmList(int brokerId, int containerVmsNumber, double schedulingInterval) {
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, schedulingInterval)); // Use the specified scheduling interval
}
return containerVms;
}
/**
* Create the host list considering the specs listed in the
* {@link ConstantsExamples}.
*/
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;
}
/**
* create the containers for hosting the cloudlets and binding them
* together.
*/
public static List createContainerList(int brokerId, int containersNumber, double schedulingInterval) {
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]),
schedulingInterval)); // Use the specified scheduling interval
}
return containers;
}
/**
* Creating the cloudlet list that are going to run on 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;
if (files1 != null) {
for (java.io.File aFiles1 : files1) {
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) {
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;
}
}