Simulating Virtualization in Cloudsim

Virtualization technology is not new, If you ever read about mainframes like IBM CP/CMS, these were first of it a kind of computer that implemented the virtualization at the hardware level. Back then in the early 1970s, the cost of computing resources was very high they were supposed to be shared for various operational purposes with application backward compatibility.

Then over the period of time, as the cost of computing decreased it become distributed to personal. This change helped virtualization to diversify its role in storage, network, application execution environment and has become a well-matured technology.

Also, since 1990 when the internet becomes public, within 15-20 years there has been exponential growth in the websites and applications hosted across the internet. This growth has intense stress on the service providers in terms of workload, operational, and maintenance costs. Apart from this increased use of computation required intense cooling measures which leads to indirect contribution of greenhouse gas emissions as most of the electricity is produced through burning the natural resources.

The service providers like Google, Microsoft, AWS worked around this problem and used virtualization technology as a great tool to have a sustained comprehensive computing practice by integrating Virtualization in cloud computing.

This is how virtualization becomes a fundamental component of a cloud computing stack because it allows the creation of a secure, customizable, and isolated abstract execution environment for running the application. This abstract execution environment completely separates the underlined host through the inception of hypervisor which is basically virtual machine managers. There have been various types of Virtualization in cloud computing, based on the type of resource is involved.

Apart from this, virtualization provides a great opportunity to build elastically scalable systems, which are capable of provisioning additional capacity with minimum cost as the underlying host machines are shared among various virtual machines. Ultimately leading to the Infrastructure as a service that can be offered on a pay as you go model.

Even though this technology has brought a huge difference to the real computing paradigm but as a cloud computing researcher it is really difficult to leverage such a commercial system, as its usage for testing the research hypothesis will cost you based on what resources require for how long. So without funding, it is not possible to test on a real cloud.

To address this problem Dr, Raj Kumar Buyya and his team worked presented the cloudsim which basically supports the modeling and simulation of large-scale Cloud computing data centers. This tool is basically an API developed using a java programming language.

The interesting point of this tool is that the various components of this real-world virtualization were modeled in the form of java classes and during the simulation, these classes produce similar behavior using the logical and mathematical models.

Let’s take an example of AWS EC2 instance “t4g.micro” the configuration that it defines is vCPU 2 with consistent baseline compute availability of 10%, 1 GB RAM, up to 10 GB of EBS, and up to 5 Gbps of network bandwidth.

Just like above the virtual machine configuration can be defined using a few lines of java code. The Virtual machine model behavior is implemented in Vm.java class. This class defines all the attributes like processing elements, RAM, Storage Size, Bandwidth, computation capacity, etc. The following snippet demonstrates how these attributes are initialized before the simulation process.

// VM description
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

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

Here, it is important to mention that just like a real cloud, cloudsim supports the allocation of more than one CPU to Vm through the attribute pesNumber. But the allocation is only possible if the underlined simulating host has enough resources to support the requested resources.

Now in the real-world cloud-based system, every virtual machine contains an execution environment to accommodate the application processing, where the number of processes run on this abstract virtual machine and based on the execution of these process the output/ response is either displayed to the user or sent back to the requesting entity. These process executions are intern managed through schedulers like Round-robin/ shortest job first etc.

On a similar note to support the simulation of virtualization in the cloudsim simulation toolkit, there exist four classes CloudletScheduler.java, CloudletSchedulerTimeshared.java, CloudletSchedulerSpaceShared.java, CloudletSchedulerDynamicWorkload.java.

These class models facilitate the cloudsim simulation engine to imitate the real-life scheduling process and are by far the state of the art.

The real cloud-based virtual machine allocation engine takes care of allocating the create a virtual machine to a suitable host, similarly, the cloudsim virtualization simulation engine has a model implementation in VmAllocationPolicy.java and VmAllocationPolicySimple.java. These classes are used by the datacenter class to find the right mapping of VM to Host. This task of mapping is performed through the processVmCreate() method of Datacenter.java class the logic is as follows:

protected void processVmCreate(SimEvent ev, boolean ack) {
		Vm vm = (Vm) ev.getData();

boolean result = getVmAllocationPolicy().allocateHostForVm(vm);

if (ack) {
	int[] data = new int[3];
	data[0] = getId();
	data[1] = vm.getId();

	if (result) {
		data[2] = CloudSimTags.TRUE;
	} else {
		data[2] = CloudSimTags.FALSE;
		}
	send(vm.getUserId(), CloudSim.getMinTimeBetweenEvents(), CloudSimTags.VM_CREATE_ACK, data);

	}

	if (result) {
		getVmList().add(vm);
		if (vm.isBeingInstantiated()) {
			vm.setBeingInstantiated(false);
			}

		vm.updateVmProcessing(CloudSim.clock(), getVmAllocationPolicy().getHost(vm).getVmScheduler()
					.getAllocatedMipsForVm(vm));
	}

}

Also, we know the real cloud-based virtual machines are just an abstract machine it requires a host to fulfill its resource request. Also, a single host may manage more than one virtual machine. So to support the scheduling of Virtual machine there exist a VM Scheduler policy.

To support the same in simulation, the cloudsim simulation toolkit implements a VmScheduler.java, VmSchedulerTimeshare.java, VmSchedulerspaceShared.java, and VmSchedulerTimesharedoversubscription.java. These VmScheduler classes are called every time the VM processing is updated means that whenever the cloudsim simulation engine is progressing the cloudlet/task processing intern updates the VM processing using the updateVmsProcessing() method available in Host.java class.

So every individual action that is required to be performed by the virtual machine manager is modeled within the cloudsim simulation toolkit and this allows the cloud computing researcher to test all the possible hypothesis and benchmark it on a state of the art tool.

Virtual machine migration in Cloudsim

Efficient Virtual Machine migration is the primary task that a researcher considers while framing her research problem. And one of the most haunting tasks is to simulate the proposed algorithm using a cloudsim simulation toolkit.

This article will broadly discuss the basics of virtual machine migration, initial virtual machine allocation to hosts, and then how this initial virtual machine allocation is optimized using specific migration strategies. Throughout the article, I have referred to a couple of important methods(functions) that you should check side by side for better understanding. Now if you have not installed/setup the cloudsim on your computer then you should first follow this step by step guide.

Sequence to allocate a Virtual machine to the simulated host in cloudsim

At the start of the cloudsim simulation scenario, first, the configuration details of the Virtual Machine(VM) and cloudlets are defined and submitted to the DatacenterBroker instance. Now, once the Datacentre instance is up and running in the simulation, the DatacenterBroker instance requests the Datacentre instance to create a virtual machine and allocate it to the desired host. For this, the DatacenterBroker initiates the event using 

CloudSimTags.VM_CREATE_ACK

from the method “createVMInDatacentre()” , where DatacentreID passed as a parameter.

Now, once the Datacentre is processing, its assigned events and reaches the event call assigned by the DatacentreBroker. Then, it allocates the virtual machines through the “processVMCreate()” method, which intern recognizes the attached Virtual Machine allocation policy and utilizes the “allocateHostForVM()” method and sends an acknowledgment to the DatacentreBroker.

Now, let us consider two different scenarios

  1. If there is a need to map a particular virtual machine to a specific Datacenter, then the method createVMInDatacentre() (defined inside DatacentreBroker) logic is required to be changed as per the need of the scenario. For example, the situation related to the federated Datacentre or failsafe region-based replication. OR
  2. If there is a requirement for managing the adequate host resource utilization corresponding to the virtual machine to host mapping, then “allocateHostForVM()” method from Datacenter class is required to implement the necessary logic. For this already, a scenario is included in “org.cloudbus.cloudsim.power” packages like “PowerVMAllocationPolicyAbstract” and “VMAllocationPolicysimple“.

Sequence to initiate the VM Migration in cloudsim simulation

Datacentres are responsible for the execution of the workloads, and in cloudsim simulation, the cloudlet is considered as workload; therefore, primarily cloudlet processing performed at every cycle of entity(Datacenter, DatacenterBroker, etc.)event processing which in turn update the VM processing metrics through the host. 

The Datacentre instance utilizes the “updateCloudedProcessing()” method for the progress of the simulation run cycle.

Now, because this cloudlet processing cycle is the primary driving force for simulation; therefore, the power-aware package implements the VM utilization checks between these events only.

 There is a method named as “optimizeAllocation()” whose implementation is in PowerVMAllocationPolicyMigrationAbstract.Java. This method accepts the list of active VMs and performs the following steps in sequence:

  1.  Get the list of all the over-utilized hosts as per the threshold (w.r.t.) The VM allocation policy used.
  2. The list of all over-utilized hosts, along with its utilization metrics, are printed on the console.
  3. Identify the list of virtual machines to be migrated from the over-utilized host, but before doing this, the system takes a backup of the current VM to host mappings.
  4. A VM placement/allocation mapping to a new suitable host identified and kept in a temporary migration map. During this phase, the search space for a suitable host excludes already identified, overloaded hosts.
  5. Now the hosts, which are underutilized(utilization below 1%), are also identified to move their virtual machines. It is done to reduce power consumption by idle server machines. Now to reduce the search space overutilized, switched off(previously underutilized) and hosts identified in step 4 are excluded, and the list of VMs from these hosts also marked for migration
  6. And, finally, the final migration map is prepared, and the current allocation is restored to continue the simulation.

Now Once the migration map is final and is available to Datacentre, then the “updateCloudletProcessing()” method call gets to utilize the migration map. And, for each new VM to host mapping from migration map is scheduled as a new event for the current Datacentre instance with event tag as

CloudSimTags.VM_MIGRATE.

This event will also consider an added network delay calculated based on the available network bandwidth, and further cloudlet processing event gets rescheduled. 

This event is then further processed in the next simulation cycle of the cloudsim simulation engine through the “processVMMigrate()” method available in Datacentre.Java class.

In this following steps are followed:

  1.  Location of VM from the current host.
  2. Allocation of VM to the identified suitable host performed, and if acknowledgment is requested, then an acknowledgment is scheduled. Otherwise, confirmation of migration gets printed on the console.

 So, overall in every cycle of the simulation run, the Cloudsim simulator performs intense calculations to determine the right migration map to optimize the overall allocation of virtual machines to hosts. 

Now, to implement your appropriate Virtual Machine allocation and selection policy, you may consider the study of the proper VM allocation and selection policies available in “org.cloudbus.cloudsim.power” package. 

Now, In case you are looking for a comprehensive cloudsim tutorial, you should subscribe to “Learn Basics of Cloudsim.”