Introduction to CloudSim

CloudSim Installation on Windows 11

Introduction to CloudSim Framework

CloudSim is an open-source framework used for the modeling and simulation of Cloud Computing infrastructures and services. It provides a virtualized environment to test resource provisioning, energy consumption, and scheduling algorithms without the high costs of real-world cloud deployment.

Key Use Cases

  • Energy Efficiency: Analyzing data center power consumption under varying workloads.
  • Resource Scheduling: Evaluating algorithms for mapping Cloudlets (tasks) to Virtual Machines.
  • Cost Analysis: Estimating operational expenses on commercial cloud platforms.
  • Federated Clouds: Simulating inter-cloud resource sharing and cooperation.

Core Classes of CloudSim

1. Datacenter

The core infrastructure provider that models internal hardware (Hosts) and manages storage and bandwidth.

Example: A physical AWS availability zone or a large-scale server farm.

2. Host

A physical server residing within a Datacenter. It possesses defined RAM, storage, and multiple Processing Elements (PEs).

Example: A rack-mounted blade server with 128GB RAM and 32 CPU cores.

3. PE (Processing Element)

Represents a single CPU core. Its performance is quantified in MIPS (Millions of Instructions Per Second).

Example: A single 3.0GHz core in a multi-core processor.

4. VM (Virtual Machine)

A software-based emulation of a computer that runs on a Host and competes for its hardware resources.

Example: An EC2 t2.micro instance configured with 1 vCPU and 1GB RAM.

5. Cloudlet

Models the application task to be executed. It defines the specific workload (Instruction Length) required for completion.

Example: A specific database query or a file compression task.

6. DatacenterBroker

Acts as the mediator between users and providers, handling VM placement and task scheduling logic.

Example: A management portal that selects the best server based on current load.

Simulation Flow Example

Consider a scenario where a Cloudlet with an instruction length of 5000 is assigned to a VM with 500 MIPS capacity:

Execution Time = (Cloudlet Length) / (VM MIPS) = 5000 / 500 = 10 Seconds

Mapping: Physical vs. Simulation

Physical Entity CloudSim Class Primary Attribute
Server Room Datacenter OS, VMM (Hypervisor)
Physical Server Host RAM, Bandwidth, PEs
CPU Core PE MIPS Rating
Virtual Server VM Image Size, MIPS
Application Task Cloudlet Instruction Length

CloudSim Plus Simulation Examples

These examples demonstrate the progression from simple single-task simulations to more complex multi-core, multi-task cloud scenarios using the CloudSim Plus framework.

Scenario 1: Basic Single VM & Single Cloudlet

Usecase Establishing a baseline simulation to measure the execution time of a single task on a dedicated virtual resource.
Logic A Cloudlet of 5000 Million Instructions runs on a VM with 1000 MIPS. The simulation calculates a 5-second completion time.
public class BasicCloudSimExample {
    public static void main(String[] args) {
        CloudSimPlus simulation = new CloudSimPlus();
        List<Pe> peList = new ArrayList<>();
        peList.add(new PeSimple(1000)); 
        Host host = new HostSimple(2048, 10000, 100000, peList);
        Datacenter datacenter = new DatacenterSimple(simulation, List.of(host));
        DatacenterBroker broker = new DatacenterBrokerSimple(simulation);
        
        Vm vm = new VmSimple(1000, 1);
        vm.setRam(512).setBw(1000).setSize(10000);
        
        Cloudlet cloudlet = new CloudletSimple(5000, 1);
        
        broker.submitVmList(List.of(vm));
        broker.submitCloudletList(List.of(cloudlet));
        
        simulation.start();
        new CloudletsTableBuilder(broker.getCloudletFinishedList()).build();
    }
}

Scenario 2: Resource Contention (Single Core)

Usecase Modeling task queuing and time-sharing when multiple applications compete for the same physical CPU core.
Logic Two Cloudlets are submitted to a single-core VM. This tests how the broker and scheduler handle sequential task execution.
public class BasicCloudSimExample {
    public static void main(String[] args) {
        CloudSimPlus simulation = new CloudSimPlus();
        List<Pe> peList = new ArrayList<>();
        peList.add(new PeSimple(1000)); 
        Host host = new HostSimple(2048, 10000, 100000, peList);
        Datacenter datacenter = new DatacenterSimple(simulation, List.of(host));
        DatacenterBroker broker = new DatacenterBrokerSimple(simulation);
        
        Vm vm = new VmSimple(1000, 1);
        
        Cloudlet cloudlet1 = new CloudletSimple(5000, 1);
        Cloudlet cloudlet2 = new CloudletSimple(2000, 1);
        
        broker.submitVmList(List.of(vm));
        broker.submitCloudletList(List.of(cloudlet1, cloudlet2));
        
        simulation.start();
        new CloudletsTableBuilder(broker.getCloudletFinishedList()).build();
    }
}

Scenario 3: Parallel Processing (Multi-Core)

Usecase Simulating multi-core virtualization where multiple tasks execute simultaneously on different cores of the same VM.
Logic The Host is configured with 2 PEs and the VM is given 2 cores. This allows Cloudlet 1 and Cloudlet 2 to run in parallel.
public class BasicCloudSimExample {
    public static void main(String[] args) {
        CloudSimPlus simulation = new CloudSimPlus();
        List<Pe> peList = new ArrayList<>();
        peList.add(new PeSimple(1000)); 
        peList.add(new PeSimple(1000)); // Second Core
        
        Host host = new HostSimple(16384, 1000000, 1000000, peList);
        Datacenter datacenter = new DatacenterSimple(simulation, List.of(host));
        DatacenterBroker broker = new DatacenterBrokerSimple(simulation);
        
        Vm vm = new VmSimple(1000, 2); // 2-Core VM
        
        Cloudlet cloudlet1 = new CloudletSimple(5000, 1);
        Cloudlet cloudlet2 = new CloudletSimple(2000, 1);
        
        broker.submitVmList(List.of(vm));
        broker.submitCloudletList(List.of(cloudlet1, cloudlet2));
        
        simulation.start();
        new CloudletsTableBuilder(broker.getCloudletFinishedList()).build();
    }
}