# Using gravitational search algorithm enhanced by fuzzy for resource allocation in cloud computing environments

- 119 Downloads

**Part of the following topical collections:**

## Abstract

The aim of this paper is to allocate resources to tasks and scheduling tasks on existing virtual machines (VMs) in cloud environments, so that the time to finish the last work and average of all tasks execution time are minimized, and loads are distributed balanced on virtual machines. Since task scheduling in the cloud environment is a continuous process, so scheduling improvements, although slight, play an important role in cloud efficiency. On the other hand the resource allocation problem in cloud computing and user tasks scheduling on existing virtual machines is a NP-hard problem, and traditional algorithms requires exponential time to examine search space of this problem in sequence and finding the best answer, therefore we used Gravitational Search Algorithm (GSA) that has a high efficiency in solving nonlinear problems, for solving this problem. To do this, we create masses by combining sequences of tasks assigned to all machines. Each mass position is a solution of the problem. Then we find the best possible assignment using the gravitational search algorithm. We used fuzzy logic to determine the number of masses that affect one another during the implementation of the GSA. To calculate the cost, we use a combination of Make_ span (Time to finish the last task) and Mean_ Flow_Time (Average of all tasks execution time) and Load_ imbalance. The results show that the proposed method achieves more optimal response than genetic algorithm and GSA without fuzzy for resource allocation. It means that proposed algorithm allocated resources to tasks with less make span and mean_ flow time and more load balancing than other two algorithms.

## Keywords

Cloud computing Gravitational search algorithm (GSA) Resource allocation Tasks scheduling Fuzzy logic## 1 Introduction

Cloud computing is a computational model based on Internet that provides a fresh model for the supply, consumption and delivery of computing services (including infrastructure, software, platform, and other computing resources) by utilizing the network. In cloud computing, resources such as disk, network, RAM, and processor, or services such as a database, according to customer needs, are provided online.

Clouds are divided into several categories based on the type of service they provide: Infrastructures as a Service (IaaS), Platforms as a Service (PaaS) and Software as a Service (SaaS). Iaas is a combination of the hardware and services needed to run the cloud. Paas is a computing platform and a set of applications to an enterprise by a cloud provider. SaaS is a software distribution that is hosted by the service provider and used by users online [1].

One of the most important issues in cloud computing is how to allocate resources (such as CPU, Memory) to user requests. Virtualization is generally used to allocate resources in the cloud environment. A tasks scheduler is used to map each task to virtual machines (VMs) to minimize a given cost function. Cost can be power/energy consumption [2] or make-span, that is, the time when finishes the latest task, or flow-time, that is, the sum of initialization times of all the tasks [3].

The problem of resource allocation in cloud computing and user tasks scheduling on existing virtual machines is a NP-hard problem [4]. So the search space for this problem is so large that if an algorithm wants to examine this space in sequence and find the best answer, it requires exponential time. Therefore, intelligent and heuristic methods and algorithms are used to solve this problem.

Main issue in cloud computing is resource deficiency. Therefore, maximizing the utilization of resources at same time minimizing the make span is an important object [5]. One way to increase utilization of resource and consequently increase cloud throughput is to avoid overloading on resources and balancing load on them. On the other hand, the service level agreement (SLA) for cloud environment uses the average response time to reflect the Quality of Service (QoS) and cloud users want this time to be minimal. Therefore, in a good scheduling method, minimizing make span (time to finish the last task) and minimizing average of all tasks execution time and maximizing load balancing should be considered.

Task scheduling and resource allocation in the cloud environment are continuous processes, so scheduling improvements, although slight, play an important role in cloud efficiency. Since the task scheduling problem is a nonlinear problem and Rashedi et al. [6] have shown that the Gravitational Search Algorithm (GSA) has a high efficiency in solving nonlinear problems, and results obtained by GSA in most cases provide superior results and in all cases are comparable with other algorithms such as Particle Swarm Optimization (PSO) and Genetic algorithm (GA), so in this study we used GSA for task scheduling to achieve mentioned purposes. To increase the accuracy of the algorithm, we used fuzzy logic in our proposed method to determine the number of masses that affect one another during the implementation of the GSA. The results show that proposed method, in comparison with the Genetic Algorithm (GA) and GSA without fuzzy enhancement, receives roughly more optimal responses for resource allocation and it allocated resources to tasks with less make span and mean_ flowtime and more load balancing than other two algorithms.

In next section, a brief summary of tasks scheduling in Cloud environments is presented. In Sect. 3, we explain necessity to improve scheduling methods and describe problem statement. Section 4 gives an overview of GSA. In Sect. 5, how using enhanced GSA by fuzzy for resource allocation is mentioned, and in Sect. 6 achieved results are given.

## 2 Related works

Scheduling is one of the key issues of optimization and has an important role in increasing the reliability of the system. The main purpose of the scheduling is to allocate resources to the tasks and to find the proper sequence of the tasks to execute with appropriate time [7]. Since the application of cloud computing is increasing andas mentioned finding an optimal solution for the tasks scheduling is a NP-hard problem, in recent years, tasks scheduling techniques for cloud environment received great attention from the researchers.

In [8] a scheduler has been proposed using the particle swarm optimization (PSO) algorithm to schedule tasks and allocate resources to tasks, which uses this scheduler less time consuming than the Best Resource Selection (BRS) algorithm.

Lakra and Yadav [9], proposed a multi-purpose tasks scheduling algorithm for tasks mapping to VMS to increase the efficiency of the data center and reduce costs without violating the SLA (Service Level Agreement). This method is simulated using Cloud Sim simulator and results show throughput improvement.

Li et al. [10] presented a method for scheduling tasks in cloud environments based on ant colony optimization (ACO) algorithm. The main goal of this proposed algorithm is to balance the entire system load while minimizing the time it takes to end the last task.

Priya et al [11] proposed a fuzzy multidimensional resource scheduling model to increase the resource scheduling efficiency in the cloud by introduce a resource scheduling and load balancing algorithm.

In [12], Mansouri et al. proposed a hybrid method using fuzzy system and particle swarm optimization (PSO) algorithm to increase load balancing and cloud throughput. In their study, they used fuzzy system for calculating fitness with some input factors such as tasks length, speed of CPU, size of RAM, and execution time. In their paper, the combination of crossover and mutations operators with POS algorithm is used to improve optimization performance. The experimental results show that the proposed algorithm has a better performance comparing to other methods in some terms such as imbalance degree and make span.

Jena and Mohanty [13] using Genetic algorithm to task scheduling in multi-cloud computing. The aim of their paper is to map the tasks to VMs in order to have maximum customer consent and minimum time that needs to finish the last task. They first using Genetic algorithm to map tasks to the virtual machines and then schedule tasks by using shortest job algorithm. The results show that the proposed algorithm efficiency is more than existing algorithms.

Muthulakshmi and Somasundaram [14] integrate the simulated annealing (SA) and artificial bee colony (ABC) algorithm to scheduling the tasks according to their size and priority of the request and distance between client nodes to a server in the cloud environment. They use Cloud Sim tool too simulation the results. The results show that the proposed algorithm is more efficient in terms of reduced make span.

## 3 Problem statement

As mentioned in the introduction section, tasks scheduling is one of the most important issues in cloud computing. For cloud providers, a good scheduling should reduce costs and avoid overloading on resources to increase system efficiency. From the cloud user’s view, make span and the average of all tasks execution time should be minimized. Therefore, to satisfy the interest of both groups, the proposed algorithm should consider minimizing make span and average of all tasks execution time and maximizing utilization of resource by balancing load on them.

Task scheduling and resource allocation in the cloud environment are continuous processes, so scheduling improvements, although slight, play an important role in cloud efficiency. Since task scheduling is a nonlinear problem and GSA has a high efficiency in solving nonlinear problems, therefore in this paper we used GSA for task scheduling to satisfy optimization constraints.

In our proposed method, physical resources are shared among several tasks using virtualization. Virtual resource requests are described by a set of parameters, including CPU, Memory and other resources requirements. The cloud provider satisfies a request by mapping virtual resources to physical ones. The resources are allocated to tasks on demand basis. Each VM can process several tasks at a time, but no two VM process the same task at a time.

Here we apply GSA to allocate virtual machines to tasks and used fuzzy logic to improve GSA Performance. We used combination of Make _span (Time to finish the last task) and Mean _Flow_Time (Average of all tasks execution time) and Load _imbalance as cost function in GSA and attempt to minimize this function value and consequently maximize fitness value of masses.

## 4 Gravitational search algorithm (GSA)

There are four main forces in nature. Gravity, weak force, electromagnetic force and strong force [15]. Among these forces, the gravitational force is weaker than the others, but it has the fate of the universe. The gravitational force is very comprehensive and covers the entire universe while other forces are local.

In the gravitational search algorithm (GSA), optimization is done with the aid of a plan of gravitational laws and motion in a discrete time artificial system [6]. The system environment is the same as the range of the problem definition. Under gravity law, each mass recognizes the location and condition of other masses through gravitational law. Therefore, this force can be used as a means of exchanging information.

In the first step, the system space is determined. The environment consists of a multi-dimensional coordinate system in the problem space. Every point in space is a solution to the problem. The search agents are a collection of masses. Each mass has four characteristics: (a) mass position, (b) active gravity mass, (c) inactive gravity mass, and (d) inertia mass. The amounts of gravitational and inertial masses are determined by the fitness of each mass.

*N*masses. The position of

*d*dimension of the mass

*i*is represented by \(x _{d}^{i}\)(Eq. (1)). In this equation,

*m*is the problem dimension.

*M*

_{aj}and

*M*

_{pi}are the active gravitational mass of the mass

*j*and the passive gravitational mass of the mass

*i*respectively.

*G*(

*t*) is the gravitational constant at time

*t*and

*R*

_{ij}is the distance between

*i*and

*j*masses. We use Euclidean distance to determine the distance between masses in accordance with Eq. (3). ε is a very small number.

*p*is the distance exponent, which is a real number greater than one. This value is often considered to be one.

*i*in the direction

*d*at time

*t*is shown by \(F_{i}^{d} \left( t \right)\) and is equal to the sum of the random coefficients of the forces that

*k*best masses enter on the mass

*i*(Eq. (4)). In this equation, \(rand_{j}\) is a random number with uniform distribution in interval [0–1], which is used to maintain the randomness feature of the search algorithm.

*i*accelerates in the direction of dimension

*d*at time

*t*, and this acceleration is calculated by Eq. (5) in which

*M*

_{ii}is the inertia mass of the mass

*i*.

*d*of the mass

*i*is calculated by Eq. (7).

In the Eq. (6), *rand*_{i} is a random number that distributed uniformly in the interval [0–1], which is used to maintain the randomness feature of the search algorithm.

In Eq. (9), *G*_{0} isthe initial gravitational constant, *α* is a positive constant and *t* is the total of algorithmic repetitions.

In Eq. (11), *fit*_{i}(*t*) represents the amount of fitness of mass *i* at time *t*.

## 5 Using GSA enhanced by fuzzy for resource allocation in cloud computing environments

As mentioned the problem of tasks scheduling on existing virtual machines in cloud environment is a NP-hard problem. If we show the number of tasks with *Tas knum* and the number of virtual machines with *VMnum*, then the number of possible allocations is *VMnum*^{Tasknum}. The duty of scheduler is finding an allocation of virtual machines to input tasks such that the computational and memory requirements of all tasks are satisfied with the lowest cost.

- 1.
Make span: Time to finish the last task

- 2.
Mean (Flow-Time): Average of all tasks execution time

- 3.
Load imbalance

Cost can be a combination of these parameters.

For scheduling, we can use traditional algorithms such as Round Robin algorithm, but because they have a serial structure, offer only possible responses that are not necessarily optimal or relatively optimal. Also do not meet the load balance criterion.

As noted above, the problem of scheduling and allocating resources in the cloud is a NP-Hard problem and due to the size of the search space, the time needed to check the entire space sequentially and find the best answer is required exponential time. Because of the good performance of GSA in nonlinear problems, we used this algorithm for tasks scheduling in Cloud environment.

*Allocated*. The length of this array is equal to the number of tasks (

*Task num*), and in each section, allocated task numbers in each machine are stored. Also, in an array named

*Tasks ln VM*with the length of the number of virtual machines (

*V Mnum*), the number of tasks assigned to each machine is kept. Figure 2 shows an example of coding for the 10 tasks scheduling on 6 machines. In this figure as mentioned in problem state section, each VM can process several tasks at a time, for example task#1 and task#3 are executed on VM#1 and task#6, task#8 and task#10 are executed on VM#5. Since we have 10 tasks here, so the length of

*Allocated*array is 10. The

*Allocated*array, along with the

*Tasks lnV M*array, determines each task executes on which virtual machine. For example,

*Tasks lnVM*[1] = 2 means that two tasks are running on VM#1, and since

*Allocated*[1] = 1

*and Allocated*[2] = 3, so tasks 1 and 3 are running on VM#1. Likewise

*TaskslnVM*[2] = 1 means that one task is running on VM#2, and since two tasks are running on VM#1, therefore the first two cells of the

*Allocated*array store the tasks numbers that runs on the VM#1, and the third cell shows the executed task number on the VM#2. Here

*Allocated*[3]= 2 and it means that task#2is running on VM#2.

*Resnum*, then the capacities of the virtual machines in an array called

*VMsCapacity*with

*Resnum*×

*VMnum*dimensions are stored. The column

*i*of this array shows the amount of

*i*-

*th*virtual machine resources. Also resource requirements for tasks are stored in an array named

*Tasks Requirements*with dimensions

*Resnum*×

*Tasknum*. The j column of this array shows the amount of resources requested by

*j*-

*th*task. The structure of the

*VMs Capacity*and

*Tasks Requirements*arrays is shown in Fig. 3.

*Allocated*array that stores the number of executed tasks on the

*y*machine is as in Fig. 4, then the Eq. (17) at the time

*t*is established.

*Make span*parameter is important and if α = 1 and β = 0, then only second parameter is important. The fitness of appropriateness of the allocation at any time is obtained from Eq. (19):

Any allocation that has more fitness will be a better allocation.

After formulating allocations, we use the gravitational search algorithm to find an optimal allocation.

*fitness*function is defined in such a way that a better allocation is more competent, so at the time

*t*, the best and the worst allocation is obtained from Eqs. (20) and (21), respectively, where

*N*is the number of problem responses in time

*t*.

*N*masses, then the position of each mass is a point of space, which is the answer to the problem. In our problem, the answer is coded in

*Allocated*array therefore, the position of the dimension

*d*of the mass

*i*is represented by \(Allocated_{i}^{d}\)(Eq. (24)). In this equation the number of tasks (

*Task num*) is the dimension of the problem.

*t*, to mass

*i*by mass

*j*, a force of \(F_{ij}^{d}\) is entered in the direction

*d*dimension. The value of this force is calculated from Eq. (26).

*i*is obtained from Eq. (27). To improve the power of the algorithm, only the

*k best*set containing the

*k*best members is allowed to affect other members. Because in the initial repetition of the algorithm, there is a need for pervasive search, so the start time affects all the masses on one another, and over time, the number of members affecting the population is reduced by a linear ratio, until the end, only 2% of the best of the population affect to other members.

In this equation *rand* _{j} is a random number with a uniform distribution in the interval [0, 1] and used to maintain the randomness of the search.

Because in the initial repetition of the algorithm, there is a need for pervasive search, so in most papers often the start time affects all the masses on one another, and over time, the number of members affecting the population is reduced by a linear ratio, until the end, few of the best of the population affect to other members. Here we used fuzzy logic to control and adjust the *k* parameter. Our general policy for determining *k* is that if the optimal answer of the algorithm does not change significantly in much iteration, then we increase the value of *k* so that more masses can affect each mass. This makes it possible for a mutation to occur and the algorithm does not get stuck in the local optimal. Also, when the problem response variations are high, we reduce the *k* value to avoid wasting time and increasing the convergence speed of the algorithm.

*variation*. The output of our fuzzy system shows the

*k*parameter that determines number of members that allowed affecting other members. Figure 5 shows structure of proposed fuzzy system.

*k best*increased because the algorithm does not get stuck in the local optimal, and when the problem response variations are high, the

*k*value reduced to avoid wasting time and increasing the convergence speed of the algorithm.

*fixed number*and

*variation*inputs and

*k best*output is shown in Fig. 8.

*i*in the direction of dimension

*d*at time

*t*is obtained by using Eq. (28).

*d*of the mass

*i*is calculated according to Eq. (30).

In Eq. (29), *rand*_{i} is a random number with a uniform distribution in the interval [0, 1] and used to maintain the randomness of the search.

As mentioned, in the *Allocated* array, the tasks numbers are stored, and since each task only runs on one machine, we scaled the values obtained in Eq. (30) in such a way that they are placed in the interval [1, *Tasknum*] and there are no duplicate values in the *Allocated*_{i} array members.

In this Equation, *G*_{0} is the initial gravitational constant, *α* is a positive constant and *T* is the total of algorithm repetitions, that is, the system lifetime.

The proposed method is summarized in the pseudo-code as follows:

**Resource allocation with GSA**

## 6 Results

In this section, we compare the responses from the implementation of the proposed method to the responses obtained using the GSA without fuzzy enhancement and using genetic algorithm. To run the algorithm we used a system with CPU = core i7 4800MQ, RAM = 8 GB, VGA = AMD Radeon HD 8790 M with 2 GB Dedicated Memory. To test the proposed method, we first create virtual machines with random numbers of each of the available resources using a function called *create vms*. Also, by creating a function called *create tasks*, we create number of arbitrary tasks with random numbers of each of the available resources.

Each time we compare the proposed algorithm with the mentioned algorithms, we use the same virtual machines and the same tasks. In this way, before each comparison, we call the mentioned functions for creating virtual machines and tasks.

For the first comparison, we put G_{0} = 100 and α = 2. First, we create 100 masses randomly. For the genetic algorithm, we also consider the Crossover’s probability to be 0.3 and the mutation’s probability to be 0.2. We also consider the initial population to be 100.

*k best*tuning by fuzzy and makes the GSA algorithm not get stuck in the local optimum. Figure 11 shows number of iterations of these algorithms from twenty times execution.

## 7 Conclusion

Since resource allocation and tasks scheduling problem in cloud environment is a NP-hard problem and previous studies showed that GSA has a high efficiency in solving nonlinear problems, so in this study we used GSA for resource allocation in cloud environment. For this, first we coded problem responses in some arrays that each code showed a sequence of tasks assigned to each machine. Here we used combination of Make_ span and Mean _Flow_ Time and Load_ imbalance as cost function in GSA and attempt to minimize this function value and consequently maximize fitness value of masses. To increase the accuracy of the algorithm, we used fuzzy logic to determine the number of masses that affect one another during the implementation of the GSA and then continue the other steps of the GSA. The results show that proposed method, in comparison with the Genetic Algorithm (GA) and GSA without fuzzy enhancement, receives roughly more optimal responses for resource allocation and it allocated resources to tasks with less make span and mean_ flow time and more load balancing than other two algorithms. Although the proposed method often converges to the optimal response in less number of iterations than the GA and makes the GSA algorithm not get stuck in the local optimum. Future works can include other parameters such as the number of tasks to be completed per unit of time in terms of cost. Also to increase the speed of the algorithm and reduce the number of iterations, for *k best* determining, time is also considered as the input of the fuzzy system so that time has verse effect on *k best*.

## Notes

### Compliance with ethical standards

### Conflict of interest

The authors declare that they have no conflict of interest.

## References

- 1.Manvi SS, Shyam GK (2014) Resource management for infrastructure as a service (IaaS) in cloud computing: a survey. J Netw Comput Appl 41:424–440. https://doi.org/10.1016/j.jnca.2013.10.004 CrossRefGoogle Scholar
- 2.Nguyen T, Quang-Hung N, Tuong NH, Tran VH, Thoai N (2013) Virtual machine allocation in cloud computing for minimizing total execution time on each machine. In: International conference on computing, management and telecommunications (ComManTel), Ho Chi Minh City, pp 241–245. https://doi.org/10.1109/ComManTel.2013.6482398
- 3.Carretero J, Xhafa F, Abraham A (2006) Genetic algorithm based schedulers for grid computing systems. Int J Innov Comput Inf Control 3:1053–1071Google Scholar
- 4.Maqableh M, Karajeh H, Masa’deh R (2014) Job scheduling for cloud computing using neural networks. Commun Netw 6:191–200. https://doi.org/10.4236/cn.2014.63021 CrossRefGoogle Scholar
- 5.Sasikaladevi N (2016) Minimum makespan task scheduling algorithm in cloud computing. Int J Grid Distrib Comput 9(11):61–70. https://doi.org/10.14257/ijgdc.2016.9.11.05 CrossRefGoogle Scholar
- 6.Rashedi E, Nezamabadi-Pour H, Saryazdi S (2009) GSA: a gravitational search algorithm. Inf Sci 179(13):2232–2248. https://doi.org/10.1016/j.ins.2009.03.004 CrossRefzbMATHGoogle Scholar
- 7.Zhao C, Zhang S, Liu Q, Xie J, Hu J (2009) Independent tasks scheduling based on genetic algorithm in cloud computing. In: 5th International conference on wireless communications, networking and mobile computing, Beijing, pp 1–4. https://doi.org/10.1109/WICOM.2009.5301850
- 8.Pandey S, Wu L, Guru SM, Buyya R (2010) A particle swarmoptimization-based heuristic for scheduling workflow applications in cloud computing environments. In: 24th IEEE international conference on advanced information networking and applications, Perth, WA, pp 400–407. https://doi.org/10.1109/AINA.2010.31
- 9.Lakra AV, Yadav DK (2015) Multi-objective tasks scheduling algorithm for cloud computing throughput optimization. Procedia Comput Sci 48:107–113. https://doi.org/10.1016/j.procs.2015.04.158 CrossRefGoogle Scholar
- 10.Li K, Xu G, Zhao G, Dong Y, Wang D (2011) Cloud task scheduling based on load balancing ant colony optimization. In: Sixth annual chinagrid conference, Liaoning, pp 3–9. https://doi.org/10.1109/chinagrid.2011.17
- 11.Priya V, Kumar CS, Kannan R (2019) Resource scheduling algorithm with load balancing for cloud service provisioning. Appl Soft Comput 76:416–424. https://doi.org/10.1016/j.asoc.2018.12.021 CrossRefGoogle Scholar
- 12.Mansouri N, Zade BMH, Javidi MM (2019) Hybrid task scheduling strategy for cloud computing by modified particle swarm optimization and fuzzy theory. Comput Ind Eng 130:597–633. https://doi.org/10.1016/j.cie.2019.03.006 CrossRefGoogle Scholar
- 13.Jena T, Mohanty JR (2018) GA-based customer-conscious resource allocation and task scheduling in multi-cloud computing. Arab J Sci Eng 43:4115. https://doi.org/10.1007/s13369-017-2766-x CrossRefGoogle Scholar
- 14.Muthulakshmi B, Somasundaram K (2017) A hybrid ABC-SA based optimized scheduling and resource allocation for cloud environment. Clust Comput. https://doi.org/10.1007/s10586-017-1174-z CrossRefGoogle Scholar
- 15.Holliday D, Resnick R, Walker J (1993) Fundamentals of physics. Wiley, HobokenGoogle Scholar