Cloudsim Tutorials

How to do Virtual machine and Task Scheduling in CloudSim

This article will help you understand the class hierarchies available in Cloudsim for Virtual Machine and Cloudlet Scheduling. This blog post is supported with a video lecture provided at the end, to have a better understanding of the implementation. Let’s start with the basic terms.

Basics of Scheduling

In computers, Scheduling is a process of arranging the submitted jobs/task into a very specific sequence of execution. It is an essential characteristic of any software operating environment, which is handled by a very special program known as a scheduler.

Scheduler’s main objective is to keep the underlined hardware resources(primarily processor) to be used effectively as well as efficient. In general, the scheduler may prefer to have any of the following scheduling approaches:

Scheduling in Cloud

As cloud computing is the virtualized operating environment, and the virtual machines are the primary computing component which is responsible for the execution of the workloads(tasks).

The virtual machine(s) are powered by a physical server host machine (i.e.) hardware.

Depending on the requirement of the Virtual Machine(VM) there could be ‘one to one’ or ‘many to one’ mapping between the VM and host machine.

That means in cloud computing the scheduling is done at both the mapping levels that are:

Both of VM to Host as well as Workload(task) to VM mappings may utilize space-share or time-shared or any other specialized scheduling algorithm.

Scheduling in Cloudsim

The Cloudsim simulation toolkit framework has effectively addressed the Scheduling scenario and implemented it as a set of the programmable class hierarchies with parent class as:

  1. VmScheduler
  2. CloudletScheduler

Also, Virtual Machine(VM) and Task( Cloudlet) scheduling are one of the most important and the popular use case to be simulated by researchers using the CloudSim simulation toolkit.

Note: In cloudsim, the task is called as cloudlet, therefore in the following text instead of ‘task’ we will be using the ‘cloudlet’.

Cloudsim Virtual Machine Scheduling

The VmScheduler is an abstract class that defines and implements the policy used to share processing power among virtual machines running on a specified host. The hierarchy of the cloudsim virtual machine scheduler classes is as:

Cloudsim Virtual Machine Scheduler Class Hierarchy

These classes can be located in “org.cloudbus.cloudsim” package of cloudsim.

The definition of this abstract class is extended to the following types of policies implemented as classes:

The application of the VmScheduler classes is while instantiating the host model. Following is the code snippet used in CloudsimExample1.java from line number 160 to 174:

int hostId = 0;
int ram = 2048; // host memory (MB)
long storage = 1000000; // host storage
int bw = 10000;

hostList.add(
	        new Host(
		hostId,
		new RamProvisionerSimple(ram),
		new BwProvisionerSimple(bw),
		storage,
		peList,
		new VmSchedulerTimeShared(peList)
	)
); // This is our machine

This is where the processing element list is passed as a parameter to the VmSchedulerTimeShared() class call and during the simulation, the cloudsim will simulate the timeshare behavior for the virtual machines.

Also, in case you want to test other VmScheduler you may replace it with VmSchedulerTimeShared() call with appropriate parameters, this includes your own designed custom virtual machine scheduler.

Cloudsim Cloudlet Scheduling

The “CloudletScheduleris an abstract class that defines the basic skeleton to implement the policy to be used for cloudlet scheduling to be performed by a virtual machine. The hierarchy of the cloudsim Cloudlet scheduler classes is as:

Cloudlet Scheduler Class Hierarchy

These classes again exist in “org.cloudbus.cloudsim” package of cloudsim.

The definition of this abstract class is extended as the following types of policies implemented as three individual classes in cloudsim:

The application of the CloudletScheduler classes is while instantiating the Vm model. Following is the code snippet used in CloudsimExample1.java from line number 82 to 91:

int vmid = 0;
int mips = 1000;
long size = 10000; // image size (MB)
int ram = 512; // vm memory (MB)
long bw = 1000;
int pesNumber = 1; // number of cpus
String vmm = "Xen"; // VMM name

Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size, vmm, new CloudletSchedulerTimeShared()); // create VM

By instantiating the CloudletSchedulerTimeShared() class, the Virtual machine is decided to follow the timeshare(round-robin) approach while simulation for scheduling & executing the Cloudlets.

Also, in case you want to test other CloudletScheduler you may replace it with CloudletSchedulerTimeShared() call with appropriate parameters, this includes your own designed custom cloudlet scheduler.

Now in case you want to implement your own scheduling policies with respect to Virtual Machine or Cloudlet(s), you may simply extend the VmScheduler or CloudletScheduler class to implement all the abstract methods as specified.

This gives you the flexibility to design and implement your own set of algorithms and then later test & optimize during the repetitive simulation runs.

Learn More

In case you missed reading our popular article on Detailed introduction to Cloudsim you may follow CloudSim Simulation Toolkit: An Introduction.

Also, To quickly get started with Cloudsim Simulation Toolkit, Feel free to join our learners community on online self-paced course named “Essential Cloudsim Tutorials” I would be interested to interact with you. for further discussion.

Exit mobile version