Site icon Cloudsim Tutorials

Cloudsim Task Scheduling

Cloudsim Task Scheduling

Cloudsim Task Scheduling

Cloudsim task scheduling refers to the process of assigning tasks (called cloudlets) to virtual machines (VMs) in a cloud environment.

Efficient CloudSim Task Scheduling is crucial for maximizing resource utilization, reducing execution time, and optimizing overall real cloud performance based on the analysis of simulation results.

In CloudSim, task scheduling involves deciding which cloudlets should be executed on which VMs, taking into account the resources available in each VM and the characteristics of each task.

The goal is to ensure that tasks are completed efficiently while balancing the load across available resources. And the learnings from the simulation are used to improve the real-world cloud systems.

Key Concepts of CloudSim Task Scheduling

Cloudlets:

Cloudlets represent the individual tasks or jobs that are submitted to the cloud infrastructure.

Each cloudlet has attributes such as length, file size, number of CPUs needed, and priority. These attributes helps us to put our estimations of real world tasks workload requirements for the sake of testing during simulation.

During simulation, cloudlets are executed on VMs, which are hosted on physical machines (hosts).

This simulation really helps us to understand that what will be the behaviour of the cloud lights while it is being executed on the real cloud infrastructure, ultimately helping us to optimise the overall performance

This cloudsim task scheduling simulation really helps us to understand that what will be the behaviour of the cloudlets(tasks) while it is being executed on the real cloud infrastructure, ultimately helping us to optimise the overall performance

Virtual Machines (VMs):

VMs are the compute units in which cloudlets are executed. Similar to cloudlet virtual machines, also have the attribute requirement of MIPS, RAM, Bandwidth etc. and mimics the working just like real world virtual machine deployments.

Each VM is provisioned with resources like CPU (MIPS), RAM, bandwidth, and storage, which is being made from the simulation of cluster of hosts defined within the cloudsim simulation.

CloudSim supports multiple VMs, and the scheduling algorithm determines how cloudlets are assigned to these VMs for execution.

DatacenterBroker:

The DatacenterBroker is responsible for mapping and cloudsim task scheduling.

It is one of the most important entity in Cloudsim simulation toolkit without which we cannot make the provisioning and scheduling operations performed on the behalf of users who are interacting in a real world cloud computing scenario.

Once the cloudlet and VM are being configured in the sample, example, it is further being submitted to the datacentrebroker. Then It manages the mapping of cloudlets to VMs based on the scheduling policy in place.

Further, It selects which cloudlets to send to which VMs and monitors the completion of tasks.

Schedulers:

Schedulers influence how tasks are executed within VMs during the CloudSim Task Scheduling process.

CloudSim offers two main types of scheduling algorithms:

  1. Time-Shared Scheduler: Cloudlets share the VM’s resources, and tasks are executed in time slices. Mimicking the round robin scheduler. it is implemented in cloudsim using CloudletSchedulerTimeshared class model.
  2. Space-Shared Scheduler: Each cloudlet gets exclusive access to the VM’s resources for a certain period, and other cloudlets must wait until the current task is completed. This is a typical First come first serve scheduler. It is implemented in cloudsim through CloudletSchedulerSpaceshared class model.

but it is not limited to these two scheduling policies, because the cloudsim has an extensible API we can simply extend the Cloudletschedulers abstract model.and implement our own policies based on various constraints.

How Cloudsim Task Scheduling Works

Step 1. Cloudlet Submission:

From any example file users submit a list of cloudlets to the DatacenterBroker, which is done through submitCloudletList() method.

Each cloudlet has specific resource requirements like CPU cycles, RAM, and bandwidth which are defined in the cloudlet class instance. This requirement is further considered while executing the cloudlet on the simulated infrastructure.

broker.submitCloudletList(cloudletList);

Step 2. VM Provisioning:

This is an important step because the broker first provisions VMs by selecting hosts with enough resources to support the VMs. Only after this the cloudlets will be mapped to the VMs for its execution.

The broker may provision multiple VMs based on the total number of cloudlets and their resource requirements.

Also if the host capacity configurations are not enough, the VM provisioning will fail and subsequently the task allocation may also fail if it is in a space-shared allocation mode.

broker.submitVmList(vmList);

Step 3. Task Scheduling:

The DatacenterBroker decides on the go which cloudlets to assign to which VMs. OR you may hardcode it at the time of its declaration in any example file

It uses scheduling policies (e.g., time-shared, space-shared) to distribute the workload.

In time-shared scheduling, multiple cloudlets share the resources of the VM, and tasks are executed concurrently in small time slots.

In space-shared scheduling, each cloudlet occupies the entire VM’s resources until it finishes.

cloudlet.setVmId(vm.getId());

This setting cloudlet with VMs is performed through submitCloudlets() method of datacenterbroker class. Any modifications required to be done for initial provisioning of tasks should be made to this method either by extending the datacenterbroker class or withing the main code file.

Step 4. Task Execution:

Once the cloudlet is assigned to a VM, it begins execution through processCloudlet() method available in Datacenter class model.

While executing the task(s), CloudSim tracks the start time, completion time, and resource utilization for each task.

The VM uses its CPU cores, RAM, and bandwidth to process the assigned cloudlet through VMProcessing() method i.e. based on the capacity of virtual machine the cloudlet(task) execution progress will be proceeded.

Step 5. Task Completion:

After completing a task, the VM sends the result back to the DatacenterBroker, which records the output of the cloudlet and frees up the VM for the next task.

List<Cloudlet> result = broker.getCloudletReceivedList();

Step 6. Load Balancing:

By default, the broker ensures that cloudlets are evenly distributed across VMs to prevent overloading any single VM. Proper scheduling helps in maintaining a balance between task execution times and resource utilization. This can be further customized based on the policy requirement for the simulation. This has its own big scope and will be discussed in separate blog article

Common Cloudsim Task Scheduling Policies

First-Come, First-Served (FCFS):

In the FCFS policy, cloudlets are assigned to VMs in the order they are submitted. There is no prioritization, and the cloudlet that arrives first is executed first.

While simple, this approach does not always result in optimal resource utilization or minimized execution time.

Round-Robin Scheduling:

Here, in this Cloudlets are distributed among VMs in a cyclic order, ensuring that all provisioned VMs get an equal share of tasks.

This helps in balancing the load but might not consider the resource requirements of individual cloudlets. Again the default time-slice for this algorithm is one simulation clock tick and can be customized if required.

Priority-Based Scheduling:

This is a custom policy where Cloudlets are assigned to VMs based on their priority based on a attribute added to cloudlet while extending its model.

Here, High-priority tasks are executed before lower-priority tasks. This is useful when certain tasks need to be completed urgently, but it can lead to resource starvation for low-priority tasks.

Dynamic Scheduling:

This is again a custom policy where in dynamic scheduling, the broker monitors resource usage in real time and adjusts the scheduling of cloudlets based on the current load and resource availability.

This can involve migrating cloudlets between VMs to optimize performance.

Energy-Aware Scheduling:

This scheduling policy aims to reduce energy consumption in the cloud infrastructure and is available through PowerDatacenterBroker and PowerDatacenter class models.

Here, the broker schedules tasks to VMs based on their energy efficiency and may consolidate VMs to minimize power consumption in data centers. This is an interesting usecase and many researchers prefer to work on improving this type of scheduling as this is closely related to real world cloud infrastructure requirements.

Now lets understand the implementation with a sample code example.

Examples of Cloudsim Task Scheduling

Time-Shared Scheduling:

In this policy of cloudsim task scheduling, the VM’s resources are shared among multiple cloudlets, based on CloudletSchedlerTimeshared model, which memics round robin approach

Each cloudlet gets a slice of the VM’s resources, and the tasks are executed in parallel.

Vm vm = new Vm(vmId, brokerId, mips, pesNumber, ram, bw, size, "Xen", new CloudletSchedulerTimeShared());

Space-Shared Scheduling:

In this policy, only one cloudlet is assigned to the VM at a time, which is based on CloudletSchedulerSpaceShared class model.

The VM dedicates all its resources to a single task until it completes. This is the simplest Cloudsim Task Scheduling policy and it memics the batch processing approach.

Vm vm = new Vm(vmId, brokerId, mips, pesNumber, ram, bw, size, "Xen", new CloudletSchedulerSpaceShared());

Priority-Based Scheduling:

In if you are having a priority attribute associates with your cloudet model, in that case, we can implement a priority-based scheduler by extending the DatacenterBroker and adding logic to prioritize cloudlets based on custom criteria (e.g., task urgency or required execution time).

public class PriorityBasedDatacenterBroker extends DatacenterBroker {
    @Override
    protected void processCloudletSubmit(SimEvent ev, boolean ack) {
        Cloudlet cloudlet = (Cloudlet) ev.getData();
        if (cloudlet.getPriority() == Cloudlet.HIGH_PRIORITY) {
            // Schedule high-priority cloudlet first
            assignToVm(cloudlet, highPerformanceVm);
        } else {
            // Schedule normal-priority cloudlet
            assignToVm(cloudlet, normalVm);
        }
    }
}

Ifn’t it that simple, and the custom cloudsim task scheduling process required minimal code changes to actual code. Only thing is that you should have the understanding of the workflow of the cloudsim simulation API.

Now, lets talk about why this cloudsim task scheduling is important and how it impacts the real world cloud computing infrastructure performance optimizations

Importance of Cloudsim Task Scheduling simulations

  1. Maximizes Resource Utilization: Efficient task scheduling ensures that VMs are fully utilized, reducing idle time and maximizing the use of resources such as CPU, RAM, and bandwidth.
  2. Minimizes Task Execution Time: Properly scheduling tasks helps reduce overall execution time, ensuring that cloudlets are processed as quickly as possible.
  3. Balances Load: Task scheduling helps distribute workloads evenly across VMs, preventing overloading of individual VMs and ensuring a balanced cloud infrastructure.
  4. Improves Energy Efficiency: Energy-aware scheduling can reduce power consumption by consolidating workloads on fewer VMs during periods of low demand, allowing idle hosts to be powered down.
  5. Enhances Performance: By dynamically adjusting task assignments and using policies like load balancing and priority scheduling, task scheduling in CloudSim improves the overall performance and efficiency of the simulated cloud infrastructure.

Conclusion

In this blogpost we tried to discuss the concept of cloudsim task scheduling policies in very detail and I hope we are able to make it simple to help you understand.

And I hope you are able to appreciate that CloudSim task scheduling is critical to the efficient operation of cloud simulation environments. As this is the core feature which helps you to analyze the performance without spending a single pennie of real cloud infrastructure.

By simulating different scheduling policies and strategies, researchers can explore how to optimize resource usage, reduce task completion times, and improve the overall performance of real cloud infrastructures.

Whether you use time-shared, space-shared, priority-based, dynamic scheduling or your own custom scheduling policy, CloudSim provides a flexible platform for studying the impact of various task scheduling policies in a cloud computing environment.

To further learn more on cloudsim task scheduling, I would recommend you to join our learners community through this on-demand online self-paced course named “Essential Cloudsim Tutorials”.

I look forward to hear your feedback in comments and connecting with you over there!

Exit mobile version