List of Topics:
Research Breakthrough Possible @S-Logix pro@slogix.in

Office Address

Social List

How to Perform Energy Efficient Task Execution using CloudSim?

Perform Energy Efficient Task Execution using CloudSim

Condition for Perform Energy Efficient Task Execution using CloudSim

  • Description:
    Energy-efficient task execution in CloudSim focuses on optimizing resource use to reduce energy consumption while ensuring performance. This can be done through methods like dynamic voltage and frequency scaling (DVFS), virtual machine consolidation, and workload balancing. DVFS lowers power consumption by adjusting host frequencies based on load. VM consolidation minimizes energy use by moving tasks to fewer hosts, allowing idle ones to power down. Workload balancing ensures even task distribution to avoid overloading some hosts. Implementing these strategies in CloudSim requires customizing classes like VmAllocationPolicy and VmScheduler for energy-aware decisions. Monitoring CPU utilization, energy use, and execution times helps assess efficiency, ensuring a balance between performance and energy savings in cloud environments.
Sample Code
  • import org.cloudbus.cloudsim.*;
    import org.cloudbus.cloudsim.core.CloudSim;
    import org.cloudbus.cloudsim.provisioners.*;
    import java.util.*;
    public class EnergyEfficientTaskExecution {
    public static void main(String[] args) {
    try {
    // Initialize CloudSim
    int numUsers = 1; // Number of cloud users
    Calendar calendar = Calendar.getInstance();
    boolean traceFlag = false; // No event tracing
    CloudSim.init(numUsers, calendar, traceFlag);
    // Step 1: Create Datacenter
    Datacenter datacenter = createDatacenter("Datacenter_0");
    // Step 2: Create Broker
    DatacenterBroker broker = new DatacenterBroker("Broker_0");
    int brokerId = broker.getId();
    // Step 3: Create VMs
    List vmlist = createVM(brokerId, 5); // Create 5 VMs
    broker.submitVmList(vmlist);
    // Step 4: Create Cloudlets
    List cloudletList = createCloudlet(brokerId, 10); // Create 10 cloudlets
    broker.submitCloudletList(cloudletList);
    // Step 5: Start Simulation
    CloudSim.startSimulation();
    // Step 6: Monitor Resource Utilization
    monitorUtilization(datacenter);
    // Step 7: Stop Simulation
    List newList = broker.getCloudletReceivedList();
    CloudSim.stopSimulation();
    // Print Results
    for (Cloudlet cloudlet : newList) {
    System.out.println("Cloudlet " + cloudlet.getCloudletId() +
    " executed on VM " + cloudlet.getVmId() +
    " with status " + cloudlet.getStatus());
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    private static Datacenter createDatacenter(String name) throws Exception {
    List hostList = new ArrayList<>();
    // Host Configuration
    int hostId = 0;
    int ram = 20480; // 20 GB RAM
    long storage = 1000000; // 1 TB Storage
    int bw = 10000; // 10 GB Bandwidth
    int cores = 8; // Number of cores
    int mips = 10000; // MIPS
    // Create a list of processing elements (PEs)
    List peList = new ArrayList<>();
    for (int i = 0; i < cores; i++) {
    peList.add(new Pe(i, new PeProvisionerSimple(mips))); // Create cores
    }
    // Create a Host
    hostList.add(new Host(
    hostId,
    new RamProvisionerSimple(ram),
    new BwProvisionerSimple(bw),
    storage,
    peList,
    new VmSchedulerTimeShared(peList)
    ));
    // Create a Datacenter with the host list
    String arch = "x86";
    String os = "Linux";
    String vmm = "Xen";
    DatacenterCharacteristics characteristics = new DatacenterCharacteristics(
    arch, os, vmm, hostList, 10.0, 3.0, 0.05, 0.001, 0.0
    );
    return new Datacenter(name, characteristics, new VmAllocationPolicySimple(hostList), new
    LinkedList<>(), 0);
    }
    private static List createVM(int brokerId, int vmCount) {
    List vmList = new ArrayList<>();
    int mips = 1000;
    int size = 10000; // 10 GB Storage
    int ram = 2048; // 2 GB RAM
    long bw = 1000; // 1 GB Bandwidth
    int pesNumber = 1; // Number of cores
    String vmm = "Xen";
    for (int i = 0; i < vmCount; i++) {
    Vm vm = new Vm(i, brokerId, mips, pesNumber, ram, bw, size, vmm, new
    CloudletSchedulerTimeShared());
    vmList.add(vm);
    }
    return vmList;
    }
    private static List createCloudlet(int brokerId, int cloudletCount) {
    List cloudletList = new ArrayList<>();
    long length = 40000; // Cloudlet length
    long fileSize = 300; // File size
    long outputSize = 300; // Output size
    int pesNumber = 1; // Number of cores
    UtilizationModel utilizationModel = new UtilizationModelFull();
    for (int i = 0; i < cloudletCount; i++) {
    Cloudlet cloudlet = new Cloudlet(i, length, pesNumber, fileSize, outputSize,
    utilizationModel, utilizationModel, utilizationModel);
    cloudlet.setUserId(brokerId);
    cloudletList.add(cloudlet);
    }
    return cloudletList;
    }
    private static void monitorUtilization(Datacenter datacenter) {
    for (Host host : datacenter.getHostList()) {
    double mip = host.getAvailableMips();
    double bandwidth = host.getBw();
    long storage = host.getStorage();
    double cpuUtilization = ((host.getTotalMips() - mip) / host.getTotalMips()) * 100;
    System.out.println("Host ID: " + host.getId());
    System.out.println("CPU Utilization: " + cpuUtilization + "%");
    System.out.println("Bandwidth Utilization: " + bandwidth + "%");
    System.out.println("Available Storage: " + storage);
    }
    }
    }
ScreenShots
  • Energy Efficient Task Execution
  • Energy Efficient Task Execution