Skip to content
VirtualLP Virtual Learning Platform

Cloud Simulation with CloudSim: Entities, Scheduling and Metrics

15 min read Topic 4 of 31 4 hands-on labs

A simulation is a computer model used to study how a system behaves. You can change a setting, run it again and compare results.

CloudSim is a Java library for simulating clouds. You describe data centres, servers, VMs (Virtual Machines) and tasks in code. CloudSim reports what happened in the model. It does not create real cloud resources.

CloudSim

CloudSim is an open-source Java library for simulating clouds. You model data centres, hosts, VMs and tasks in code, then read the simulation results. The classic examples in these lessons use CloudSim 3.0.3.

cricket video game

In a cricket game you choose the players, pitch and weather, then the game calculates what happens ball by ball. CloudSim is the same: you choose the servers, VMs and jobs, and it calculates what happens event by event ("VM created", "job started", "job finished"). This is what discrete-event means – time jumps from one event to the next.

Layered architecture

flowchart TB
    U["User code<br/>simulation scenario · broker policies · your experiment"]
    C["CloudSim core<br/>Datacenter · Host · VM · Cloudlet · provisioning & scheduling policies"]
    S["Simulation engine (formerly SimJava / GridSim)<br/>events · entities · future event queue · simulation clock"]
    U --> C --> S
Layer Contains
User code Your main() program: the number of users, hosts, VMs, cloudlets, the broker and the policies
CloudSim The cloud model: data centres, hosts, VMs, cloudlets, VM allocation, VM and cloudlet scheduling, network, cost
Core simulation engine The discrete-event engine (CloudSim.init, startSimulation); entities talk to each other by sending events (originally built on SimJava/GridSim)

Core entities

Class Represents Key attributes
Datacenter A provider's data centre Hosts, VmAllocationPolicy, characteristics (arch, OS (Operating System), VMM (Virtual Machine Monitor), cost)
DatacenterCharacteristics Fixed properties and prices Cost per second, per MB RAM (Random Access Memory), per MB storage, per MB bandwidth
Host A physical server Pe list, RAM, bandwidth, storage, VmScheduler
Pe A processing element (CPU (Central Processing Unit) core) MIPS (Million Instructions Per Second) rating (speed)
Vm A virtual machine MIPS, number of PEs, RAM, BW, size, VMM, CloudletScheduler
Cloudlet A task / job Length (MI (Million Instructions)), PEs, input & output file size, use models
DatacenterBroker Acts for the user Submits VMs and cloudlets, and binds cloudlets to VMs

A cloudlet's execution time on its own core = length (MI) ÷ VM MIPS.

Worked example

A cloudlet of 400 000 MI (million instructions) on a 1000 MIPS VM takes 400 000 ÷ 1000 = 400 seconds. Like reading a 400-page book at 1 page per second.

Provisioning and scheduling policies

Level Decides Common policies
VM allocation (data centre) Which host gets a VM VmAllocationPolicySimple – the host with the most free PEs
VM scheduling (host) How a host's cores are shared by its VMs VmSchedulerTimeShared, VmSchedulerSpaceShared
Cloudlet scheduling (VM) How a VM runs its cloudlets CloudletSchedulerTimeShared, CloudletSchedulerSpaceShared
Space-shared Time-shared
Idea One task per core at a time; others wait in a queue Tasks share the cores at the same time
Effect Later tasks start later, but each runs at full speed All start at once, but each runs slower
Analogy A queue at a single ticket counter Several people sharing one projector

Simulation life cycle

sequenceDiagram
    participant P as Your program
    participant C as CloudSim engine
    participant B as DatacenterBroker
    participant D as Datacenter
    P->>C: CloudSim.init(numUsers, calendar, traceFlag)
    P->>D: create hosts → characteristics → Datacenter
    P->>B: create broker, submit VM list and cloudlet list
    P->>C: startSimulation()
    B->>D: create VMs (allocation policy)
    B->>D: send cloudlets to VMs (scheduling policy)
    D-->>B: cloudlets return (start time, finish time)
    P->>C: stopSimulation() then print results

Steps:

  1. Start CloudSim (init).
  2. Build the data centre with its hosts.
  3. Create the broker and give it the list of VMs and cloudlets.
  4. Run the simulation (startSimulation).
  5. The broker creates the VMs and sends the cloudlets to them.
  6. Finished cloudlets come back with their start and finish times.
  7. Stop and print the results.

Performance metrics you analyse

Metric Meaning
Start time / finish time When each cloudlet began and ended (on the simulation clock)
Execution (actual CPU) time finish − start for that cloudlet
Makespan The time when the last cloudlet finished – the total time for the whole batch
Average turnaround / waiting time How long tasks waited and took, on average
Utilisation How busy the hosts/VMs were
Cost Worked out from the data centre's price per second, per MB and per bandwidth
Key point

Know the four entities in order – Datacenter → Host → VM → Cloudlet – plus the broker, the formula time = length ÷ MIPS, and the difference between space-shared and time-shared scheduling.

Practise it

Virtual lab · CloudSim · 25 min

Create and simulate a cloud data center

Model a data centre in code: hosts, processing elements (PEs), RAM, bandwidth, storage and pricing – then grow it and observe the effect.

Open lab

Virtual lab · CloudSim · 30 min

Virtual machine scheduling: time-shared vs space-shared

Run the same workload with time-shared and space-shared schedulers at the VM and host level and compare start and finish times.

Open lab

Virtual lab · CloudSim · 30 min

Simulate task scheduling with cloudlet-to-VM binding

Compare the broker’s default round-robin assignment with explicit scheduling using bindCloudletToVm, and measure the effect on makespan.

Open lab

Virtual lab · CloudSim · 35 min

Performance analysis of a cloud simulation

Instrument the output with average execution time, makespan and cost, then compare scheduling policies with numbers rather than guesses.

Open lab

Quick revision

  1. CloudSim is a Java discrete-event simulator for clouds.
  2. Layers: user code → CloudSim → simulation engine.
  3. Entities: Datacenter, Host, Pe, Vm, Cloudlet, DatacenterBroker.
  4. Space-shared queues tasks per core; time-shared shares cores among tasks.
  5. Analyse start/finish times, execution time, makespan, use and cost.

Practise this topic

Hands-on virtual labs

Apply what you just read in a realistic, guided simulation. Free with a verified account.

Create a free account to track your progress and unlock virtual labs.