Cloudsim

What is Cloudsim?

CloudSim is a simulation toolkit that supports the modeling and simulation of the core functionality of cloud, like job/task queue, processing of events, creation of cloud entities(datacenter, datacenter brokers, etc), communication between different entities, implementation of broker policies, etc. This toolkit allows to:

  • Test application services in a repeatable and controllable environment.
  • Tune the system bottlenecks before deploying apps in an actual cloud.
  • Experiment with different workload mix and resource performance scenarios on simulated infrastructure for developing and testing adaptive application provisioning techniques

Core features of CloudSim are:

  • The Support of modeling and simulation of large scale computing environment as federated cloud data centers, virtualized server hosts, with customizable policies for provisioning host resources to virtual machines and energy-aware computational resources
  • It is a self-contained platform for modeling cloud’s service brokers, provisioning, and allocation policies.
  • It supports the simulation of network connections among simulated system elements.
  • Support for simulation of federated cloud environment, that inter-networks resources from both private and public domains.
  • Availability of a virtualization engine that aids in the creation and management of multiple independent and co-hosted virtual services on a data center node.
  • Flexibility to switch between space shared and time shared allocation of processing cores to virtualized services.

Is Cloudsim suitable for my research work?

This simulation toolkit is an API that allows a developer to run any server hardware model as a software simulation, to analyze its behavior for real-world workloads. Therefore it is clear that it allows as a researcher to simulate the Infrastructure as a Service(IaaS) layer. This includes software models of data centers, hosts, storage, virtual machines, Cloud datacenter brokers, allocation & scheduling policies for the virtual machines as well as tasks, power management policies including migrations and consolidation of the virtual machines over different hosts, defining the workload attributes for its execution simulation over the cloud systems, etc.

It is not applicable/suitable where you are looking to analyze any service related to Platform as a Service(PaaS) or Software as a Service(SaaS) for example real-time applications, security algorithms, platform implementations, etc

Does it require a High computing system?

No, not at all. The cloudsim is a software simulation toolkit and is developed using Java programming language, Therefore, any computer system with a dual-core processor, 2 GB RAM, and 1 GB storage is good enough to simulate the cloud-based systems using the cloudsim as this is required to support the JRE working. Also, the hardware requirements may differ on the basis of which IDE you are using for JAVA development.

How to download Cloudsim?

Cloudsim project source code, as well as compiled jars files, are published through the GitHub project page: https://github.com/Cloudslab/cloudsim. By default, the project page displays the source code(based on maven build tool) of the current release, which is currently released version 5.0(beta) and the page displays the basic information about the project along with the publication details. Now if you are interested in using the previous versions of this project then you have click on releases link option available on project main page or otherwise, you may access it directly from the following links:

Every version except 5.0(still under development) contains 4 asset files example description for each asset file is as follows:

  • cloudsim-4.0.tar.gz: This file contains the compiled JAR file that can be directly used into the custom simulation implementation where there is no need to change in the source code of cloudsim simulation engine. This version is Linux specific.
  • cloudsim-4.0.zip: This is the same as above the only difference is that it is windows specific.
  • Source code(zip): This file contains the complete source code of the cloudsim simulation framework project. As the cloudsim uses the maven build tool for its DevOps. Therefore to set up this project you require to use an IDE that supports maven project imports. How do you identify that its a maven based project? you will find a “pom.xml” file in the project root folder. This zip is windows operating system specific file.
  • Source code(tar.gz): This file contains a similar structure as mentioned above, but it is specific to Linux

How to install?

Cloudsim setup is very easy, for this you may follow the following link: cloudsim-setup-using-eclipse/. This link describes in detail all the steps that are required to successfully configure the Cloudsim 3.0.3 version. The cloudsim 3.0.3 version is best to start with that once you understand the basic working and architecture then you can move to any latest version.

How cloudsim work?

As it is already mentioned that the cloudsim allows to model and simulate the cloud system components, therefore to support its function different set of classes has been developed by its developers like:

  • To simulating the regions and datacenters the class named “Datacenter.java” is available in org.cloudbus.cloudsim package.
  • To simulate the workloads for cloud, the class named as “Cloudlet.java” is available in org.cloudbus.cloudsim package.
  • To simulate the load balancing and policy-related implementation the classes named “DatacenterBroker.java”, “CloudletScheduler.java”, “VmAllocationPolicy.java”, etc are available under org.cloudbus.cloudsim package.
  • Now because all the different simulated hardware models are required to communicate with each other to share the simulation work updates for this cloudsim has implemented a discrete event simulation engine that keeps track of all the task assignments among the different simulated cloud components.

To read understand more on the architecture, you should definitely read the article titled “CloudSim Simulation Toolkit: An Introduction” as well as “Beginners Guide to Cloudsim Project Structure

How to run my first cloudsim simulation scenario?

Once you have completed your installation/setup and understand the basic working of the cloudsim, the next step is to implement your own custom scenario. Any simulation will go through the following steps:

  • Initialize the CloudSim with the current clock time and this will also initialize the core CloudInformationService entity.
  • Create Datacenter(s) as Datacenters are the resource providers in CloudSim. We need at list one of them to run a CloudSim simulation.
  • Create Broker to simulate the user workload scheduling as well as virtual machine allocation and placements.
  • Create one/more virtual machine and submit to the broker for further submitting it to the respective DataCenters for its placement and execution management during the simulation run.
  • Create one/more Cloudlet and submit the cloudlet list to the broker for further task scheduling on the active virtual machines for its processing during the simulation run.
  • Starts the simulation, this will initiate all the entities and components created above and put them into execution for supporting various simulation operations.
  • Stop the simulation, concludes simulation and flush all the entities & components before the exit of a simulation run.
  • Print results when the simulation is over, where you will be able to display which cloudlet executed on which virtual machine along with how much time it spent in execution, its start time as well as its finish time.

The step by step detailed description about each step can be read in the article “Guide to CloudsimExample1.java simulation workflow

It is frequently used for?

  • Load Balancing of resources and tasks
  • Task scheduling and its migrations
  • Optimizing the Virtual machine allocation and placement policies
  • Energy-aware Consolidations or Migrations of virtual machines
  • Optimizing schemes for Network latencies for various cloud scenarios
  • and many more.

Other simulators based on cloudsim

The Cloudsim 3.x.x version was a very important release and become the base for many other extensions which in turn supports a very specific type of use cases:

Learning Resources

Sample Source Codes

There are various researchers who have published their cloudsim project code on their GitHub handles, following are the quick links for your reference:

As a beginner, you may refer to these pieces of code to understand, how other fellow researchers have worked upon the cloudsim based simulation to implement their work. And definitely, this will help you to accelerate your by forking these projects and working on your own additions or a complete overhaul of these sets of codes.

References used for this post

Cloudlet in Cloudsim Simulation

Cloudlet in Cloudsim defined the workload, which is to be executed during the simulation run of the cloudsim simulation engine. Cloudlet in Cloudsim is a model class that exists inside the package ‘org.cloudbus.cloudsim‘. Cloudlet is one of the most important models which defined the specifications for a simulation engine corresponding to the real-life candidate application to be considered for moving to a Cloud-based system.

In contrast, we can also define this cloudlet as a single process or task being executed on the cloud-based system which is to be simulated through a Cloudsim simulation engine.

The cloudlet model class defines four different constructors for its initialization, its method signatures are as follows:

/*
First method signature with 8 parameters with simplest cloudlet execution with out maintaining its history or additional files
*/
public Cloudlet(
			final int cloudletId,
			final long cloudletLength,
			final int pesNumber,
			final long cloudletFileSize,
			final long cloudletOutputSize,
			final UtilizationModel utilizationModelCpu,
			final UtilizationModel utilizationModelRam,
			final UtilizationModel utilizationModelBw)

/*
Second method signature with 10 parameters with support for cloudlet execution history maintenance as well as additionl list of file requirements for execution.
*/
public Cloudlet(
			final int cloudletId,
			final long cloudletLength,
			final int pesNumber,
			final long cloudletFileSize,
			final long cloudletOutputSize,
			final UtilizationModel utilizationModelCpu,
			final UtilizationModel utilizationModelRam,
			final UtilizationModel utilizationModelBw,
			final boolean record,
			final List<String> fileList)

/*
Third method signature with 9 parameters with support for cloudlet execution additionl list of file requirements for execution.
*/
public Cloudlet(
			final int cloudletId,
			final long cloudletLength,
			final int pesNumber,
			final long cloudletFileSize,
			final long cloudletOutputSize,
			final UtilizationModel utilizationModelCpu,
			final UtilizationModel utilizationModelRam,
			final UtilizationModel utilizationModelBw,
			final List<String> fileList)

/*
Fourth method signature with 9 parameters with support for cloudlet execution history maintenance.
*/
public Cloudlet(
			final int cloudletId,
			final long cloudletLength,
			final int pesNumber,
			final long cloudletFileSize,
			final long cloudletOutputSize,
			final UtilizationModel utilizationModelCpu,
			final UtilizationModel utilizationModelRam,
			final UtilizationModel utilizationModelBw,
			final boolean record) 

Cloudlet in Cloudsim defines following are the attributes that are being by the cloudsim simulation engine:

  • userId: defines the broker id to through which this cloudlet will be executed and the result of execution will be returned & displayed on the console through the same broker.
  • cloudletLength: defines the length of the cloudlet in terms of the expected number of instructions required to be executed in the lifetime of the workload under execution.
  • cloudletFileSize: As the cloudlet is supposed to be executed over the cloud that means the input data transfer over the network should be happening during the execution. This attribute defines the total size of the input data in bytes.
  • cloudletOutputSize: Similar to cloudletFileSize the output data size is also defined in bytes.
  • numberOfPes: Defines the number of processors required to execute this cloudlet, if parallel processing is required to be performed.
  • cloudletId: used as a unique identification number for cloudlets, required for referencing throughout the simulation flow.
  • status: defines the current state of the cloudlet. A cloudlet could be in any one of the state as follows: CREATED, READY, QUEUED, INEXEC, SUCCESS, FAILED, CANCELED, PAUSED, RESUMED, FAILED_RESOURCE_UNAVAILABLE. These states are defined explicitly in cloudlet model class and are assigned a numerical value.
  • num: defined the time at various stages of cloudlet execution
  • execStartTime: Defines the latest execution time and is updated every time the status of cloudlet shuffle among CANCEL, PAUSED and RESUMED
  • finishTime: Stores the time, when the execution of the cloudlet is finished and status is not a success.
  • reservationId: defines the ID of the resource reserved for which this cloudlet.
  • record: defines in boolean(True/False) if the history of the cloudlet execution across different resources is maintained or not.
  • newline: Defined newline characteristics and used during the string concatenations while logging the history of cloudlet execution.
  • history: maintains the history of the cloudlet execution across simulation flow.
  • resList: Maintains the log of the resources where the cloudlet is being executed.
  • index: defines the ID of the resource on which the cloudlet is being currently assigned and helps in getting the status
  • classType: Defines the resource scheduling information(never used in cloudsim 3.0.3)
  • netToS: Defines the type of service for the network transactions. This is a field for IPv6 for ensuring the quality of service.
  • vmId: stores the Id of the virtual machine to which this cloudlet is to be allocated for allocation. This is done in the case where you are planning to move a real-life application to a cloud-based system with a specific Virtual machine configuration. Such mapping of cloudlet helps in determining the behavior of the application in various scenarios as simulated over the cloudsim simulation engine.
  • costPerBw: defines the cost associated with the usage of the network for cloudlet network usage. this is overridden if the cost on bandwidth is defined by the datacenter instance which is always done.
  • accumulatedBwCost: Stores the overall cost of bandwidth consumed by the cloudlet while processing during the simulation. This can be used to check what is the cost involved in network bandwidth for a particular candidate application which is under consideration to be moved to the cloud-based system.
  • utilizationModelCpu/utilizationModelRam/utilizationModelBw: these attributes defines the type of model to be used for executing the defined cloudlet. It may individually defined for each attribute from following: UtilizationModelFull, UtilizationModelNull, UtilizationModelStochastic and UtilizationModelPlanetLabInMemory(used in power-aware workloads only).
  • requiredFiles: defines the path for the list of files to be required by the cloudlet during execution. These are the input files and are directly associated with the network bandwidth cost.

Following are the states that each cloudlet can sustain during the simulation flow:

  • CREATED: Defined when the cloudlet is created and added to the CloudletList(used by the datacenter broker during the simulation flow)
  • READY: Defined when the cloudlet is assigned with a resource for execution
  • QUEUED: Defined when the cloudlet is moved to the cloud resource on which it will wait for its execution
  • INEXEC: Defined when the cloudlet is put into execution on the assigned cloud resource;
  • SUCCESS: Defined when the cloudlet execution is successfully completed and is ready to be sent back to the broker with its final status
  • FAILED: Defined in case the cloudlet is failed to be executed to the planned cloud node e.g. when the VM for which the cloudlet is to be assigned is failed to start due to any reason the cloudlet execution will be failed.
  • CANCELED: Defined, when the execution of the cloudlet is canceled due to any situation and can be further denoted in the failed state is required
  • PAUSED: Defined, when the cloudlet execution is put on hold. This could be due to some high priority cloudlet arrival or due to VM migration etc.
  • RESUMED: Defined to resume the cloudlet execution after it is being paused.
  • FAILED_RESOURCE_UNAVAILABLE: Defined when the cloudlet execution failed due to the failure of the resource on which it was supposed to be executed.

The cloudlets would shuffle between these states any number of times depending upon the simulation scenario under consideration.

One of the most important behaviors of the Cloudlet model class is that it may be moved from one resource to another resource due to any implicit/explicit reasons, therefore, the track is to be maintained for its movement during the simulation flow. To support this a nested class named ‘Resource’ is defined which contains the following attributes:

  • submissionTime: defines when the cloudlet was submitted to the provided cloud resource instance.
  • wallClockTime: defines the total time that a cloudlet spent of the currently provided cloud resource.
  • actualCPUTime: defines the actual time spent under the execution and may or may not differ from wallClockTime.
  • costPerSec: defines the cost spent on execution of cloudlet on currently provided cloud resources based on usage per second.
  • finishedSoFar: defines the currently completed execution under the currently provided cloud resource.
  • resourceId: stores the unique ID of the cloud resource which is currently provided to the cloudlet for the execution.
  • resourceName: defines the name of the current cloud resource.

The instance of this ‘Resource’ model class is defined and utilized through the setResourceParameter() method of cloudlet class. Which is further utilized in the processCloudletSubmit() method(line no 715) of DataCenter class available under the same package i.e. ‘org.cloudbus.cloudsim’. This class plays a very important role in simulated distributed network applications.

Learn More

You may subscribe to an online self-paced course named Learn Basics of Cloudsim, The content for this course will be updated weekly till August 2021.