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.”

Create a user-defined event and CloudsimTags

Did you ever wonder what drives the Cloudsim core simulation engine? The answer is the CloudsimTags.java class, which exists in org.cloudbus.cloudsim.core package.

CloudsimTags.java is the basic building block class, which contains the constant values defined against the actions that are to be performed during the simulation run.

The actions are defined as Register Resources, Cloudlet Submit, Vm creates, Vm Destroy, Vm Migrate, etc. CloudsimTags class contains a total of 57 variables where 55 are defined with a public modifier, and the other 2 are defined with private modifiers.

These variables defined as static final integers; therefore, these tag variables can be used without any class object initialization, and their values cannot be changed due to its final state.

In case during the simulation flow run, you want to put or call your action, then this is the class from where you should start planning the design of your implementation. The key markers that you should remember while adding a new tag are:

  1. The guideline comments defined by the author suggest that the range of values should be from 0 to 299, and an exclusive no 9600 reserved for describing the baud rate for the communication channel. Therefore the sequence of number series should be maintained. Till now, the sequence up to 49 is in use.
  2. There are two private variables defined named BASE and NETBASE, where the BASE set to 0(zero) and NETBASE set to 100(hundred). Both are used as a seed to determine two different sets of tags; therefore, the new tag values should be chosen carefully as per these categories to avoid any confusion at a later stage.
  3. The value assigned to a new tag should not overlap with the existing variable; otherwise, this will lead to a logical error due to ambiguity.
  4. This class cannot be instantiated i.e. the object cannot be created/initialized as cloudsimtags explicitly throws the exception for the same.

Now, Once the definition of the custom action tag completed, the new action tag can be utilized in any entity as per the requirement.

for example: In datacenter class within processevent() method Cloudlet_submit tag is used to start the call for processCloudletSubmit() method. You may initiate the call for your custom-defined respective method.

Is it still getting challenging to digest this article, then you have missed reading some essential articles related to cloudsim: CloudSim Simulation Toolkit: An Introduction and Beginners Guide to Cloudsim Project Structure.

In case you are looking for a comprehensive cloudsim tutorial, you should subscribe to “Essential Cloudsim Tutorials.”