Skip to content
VirtualLP Virtual Learning Platform

Practical 11: Performance Analysis of Cloud Simulation

15 min read Topic 20 of 31 1 hands-on lab

Aim

Run the cloud simulations and calculate their performance values. Compare execution time, finish time, CPU (Central Processing Unit) time, waiting time, makespan, throughput, resource use and cost.

Theory

Performance analysis means using measured results to understand how a system worked. A result table helps you compare scheduling policies.

First, check what each column measures and its unit. Then use the formulas below. Compare runs with the same tasks and VM (Virtual Machine) settings so that the policy comparison is fair.

Performance metrics

Metric Formula (CloudSim) Meaning
Actual CPU time getActualCPUTime() = finish − start Time a task actually run
Waiting time start − submission (getWaitingTime()) Time a task waited in a queue
Finish (completion) time getFinishTime() Clock time when a task completed
Turnaround time finish − submission Total time in the system
Makespan max(finish times) Time to complete the whole workload
Average execution time Σ CPU time / n Typical task duration
Throughput n / makespan Tasks completed per second
Resource utilisation Σ(length) / (makespan × total MIPS (Million Instructions Per Second)) How busy the capacity was
Processing cost getProcessingCost() CPU-seconds × price + bandwidth charges

Lower makespan and waiting time and higher throughput and use indicate better performance; cost must also be considered.

hospital report card

Waiting time = time a patient sits in the waiting room. Execution time = time with the doctor. Turnaround = from entering to leaving. Makespan = when the last patient of the day leaves. Throughput = patients treated per hour. Utilisation = how much of the day the doctors were actually busy.

Worked example – use

Total work = 700 000 MI (Million Instructions), total speed = 2 VMs × 1000 MIPS = 2000 MIPS, makespan = 470.1 s. Use = 700 000 ÷ (470.1 × 2000) = 74.45 %.

Requirements

Use the CloudSim 3.0.3 project prepared in Practical 4, with its CloudSim and Commons Math library files on the classpath. Confirm that the first example runs before continuing.

Procedure

  1. In the project from Practical 4, create PerformanceAnalysis.java and copy the program below.
  2. Run it with Run As > Java Application. Read the Console output.
  3. Compare the IDs, task status and timing columns with the example output. Change one model setting, run again and explain the difference.

Program – PerformanceAnalysis.java

package vlp.cloudsim;

import java.text.DecimalFormat;
import java.util.*;
import org.cloudbus.cloudsim.*;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.provisioners.*;

public class PerformanceAnalysis {

    private static final long[] LENGTHS = {120000, 80000, 200000, 60000, 150000, 90000};
    private static final int VMS = 2, MIPS = 1000;

    public static void main(String[] args) {
        analyse(false);   // CloudletSchedulerTimeShared
        analyse(true);    // CloudletSchedulerSpaceShared
    }

    private static void analyse(boolean spaceShared) {
        String policy = spaceShared ? "Space-shared" : "Time-shared";
        try {
            CloudSim.init(1, Calendar.getInstance(), false);
            Datacenter dc = createDatacenter("Datacenter_0");
            DatacenterBroker broker = new DatacenterBroker("Broker");
            int brokerId = broker.getId();

            List<Vm> vms = new ArrayList<Vm>();
            for (int i = 0; i < VMS; i++) {
                CloudletScheduler cs = spaceShared ? new CloudletSchedulerSpaceShared() : new CloudletSchedulerTimeShared();
                vms.add(new Vm(i, brokerId, MIPS, 1, 512, 1000, 10000, "Xen", cs));
            }
            broker.submitVmList(vms);

            List<Cloudlet> cloudlets = new ArrayList<Cloudlet>();
            UtilizationModel full = new UtilizationModelFull();
            for (int i = 0; i < LENGTHS.length; i++) {
                Cloudlet c = new Cloudlet(i, LENGTHS[i], 1, 300, 300, full, full, full);
                c.setUserId(brokerId);
                cloudlets.add(c);
            }
            broker.submitCloudletList(cloudlets);

            CloudSim.startSimulation();
            List<Cloudlet> list = broker.getCloudletReceivedList();
            CloudSim.stopSimulation();

            // ---- metrics ----
            DecimalFormat dft = new DecimalFormat("###.##");
            double totalCpu = 0, totalWait = 0, totalCost = 0, makespan = 0, totalMi = 0;
            for (Cloudlet c : list) {
                totalCpu += c.getActualCPUTime();
                totalWait += c.getWaitingTime();
                totalCost += c.getProcessingCost();
                totalMi += c.getCloudletLength();
                makespan = Math.max(makespan, c.getFinishTime());
            }
            int n = list.size();
            double utilisation = totalMi / (makespan * VMS * MIPS) * 100;

            Log.printLine("================ " + policy + " ================");
            Log.printLine("Tasks completed          : " + n);
            Log.printLine("Makespan                 : " + dft.format(makespan) + " s");
            Log.printLine("Average execution time   : " + dft.format(totalCpu / n) + " s");
            Log.printLine("Average waiting time     : " + dft.format(totalWait / n) + " s");
            Log.printLine("Throughput               : " + dft.format(n / makespan * 1000) + " tasks per 1000 s");
            Log.printLine("Resource utilisation     : " + dft.format(utilisation) + " %");
            Log.printLine("Total processing cost    : " + dft.format(totalCost));
            Log.printLine();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static Datacenter createDatacenter(String name) throws Exception {
        List<Pe> peList = new ArrayList<Pe>();
        peList.add(new Pe(0, new PeProvisionerSimple(MIPS)));
        peList.add(new Pe(1, new PeProvisionerSimple(MIPS)));
        List<Host> hostList = new ArrayList<Host>();
        hostList.add(new Host(0, new RamProvisionerSimple(4096), new BwProvisionerSimple(10000), 1000000, peList, new VmSchedulerSpaceShared(peList)));
        DatacenterCharacteristics ch = new DatacenterCharacteristics("x86", "Linux", "Xen", hostList, 10.0, 3.0, 0.05, 0.001, 0.0);
        return new Datacenter(name, ch, new VmAllocationPolicySimple(hostList), new LinkedList<Storage>(), 0);
    }
}

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

What the program does: it runs the same 6 tasks on 2 VMs twice – once time-shared, once space-shared – then loops over the finished cloudlets to calculate every metric in the table above (makespan, averages, throughput, use, cost) and prints a report for each policy.

Output

Example output for the settings in this lesson:

================ Time-shared ================
Tasks completed          : 6
Makespan                 : 470.1 s
Average execution time   : 313.33 s
Average waiting time     : 0 s
Throughput               : 12.76 tasks per 1000 s
Resource utilisation     : 74.45 %
Total processing cost    : 5640

================ Space-shared ================
Tasks completed          : 6
Makespan                 : 470.1 s
Average execution time   : 116.67 s
Average waiting time     : 110 s
Throughput               : 12.76 tasks per 1000 s
Resource utilisation     : 74.45 %
Total processing cost    : 2100

Observations

  • Round robin gives VM 0 tasks 0, 2, 4 (470,000 MI) and VM 1 tasks 1, 3, 5 (230,000 MI); VM 0 so determines the makespan of 470.1 s under both policies, and VM 1 sits idle for half the time – so only 74.45 % utilisation. A better task-to-VM assignment (Practical 9) would raise use.
  • Space-shared gives a lower average execution time (each task runs at full speed) but introduces waiting time.
  • Time-shared has zero waiting time but stretches every task’s execution, so average execution time and so CPU-time-based cost rise.
  • The “best” policy depends on the objective: responsiveness (time-shared) vs per-task speed and cost (space-shared).

Conclusion

Use the output to calculate the values in the table. Compare the two policies using the same workload. Explain a result with numbers, such as a shorter waiting time or a lower total cost.

Viva questions

  1. Define makespan, throughput and resource use. Makespan = latest finish time; throughput = tasks ÷ makespan; use = work done ÷ (makespan × total MIPS).
  2. How do you calculate the actual CPU time and waiting time of a cloudlet in CloudSim? getActualCPUTime() (finish − start) and getWaitingTime() (start − submission).
  3. Why is the waiting time zero under time-shared scheduling? All tasks start immediately and share the CPU, so no task waits in a queue.
  4. Why can the processing cost differ between policies for the same workload? Cost is charged per CPU-second; time-sharing stretches each task's CPU time, so the bill rises.
  5. Which metrics would you use to compare two VM placement algorithms? Makespan, use, number of failed VMs, cost and (for power models) energy.

Practise this topic

Hands-on virtual lab

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.