Cloud Simulation with CloudSim: Entities, Scheduling and Metrics
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 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.
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.
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:
- Start CloudSim (
init). - Build the data centre with its hosts.
- Create the broker and give it the list of VMs and cloudlets.
- Run the simulation (
startSimulation). - The broker creates the VMs and sends the cloudlets to them.
- Finished cloudlets come back with their start and finish times.
- 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 |
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.
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.
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.
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.
Quick revision
- CloudSim is a Java discrete-event simulator for clouds.
- Layers: user code → CloudSim → simulation engine.
- Entities: Datacenter, Host, Pe, Vm, Cloudlet, DatacenterBroker.
- Space-shared queues tasks per core; time-shared shares cores among tasks.
- 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.