Dynamic Resource Allocation for Load Balancing in Fog Environment

1School of Computer and Software, Nanjing University of Information Science and Technology, Nanjing, China 2Jiangsu Engineering Centre of Network Monitoring, Nanjing University of Information Science and Technology, Nanjing, China 3State Key Laboratory for Novel Software Technology, Nanjing University, Nanjing, China 4Department of Computer Science and Engineering, Michigan State University, East Lansing, MI, USA


Introduction
In recent years, the Internet of Things (IoT) has attracted attention from both industry and academia, which is beneficial to humans' daily lives.The data extracted from the smart sensors are often transmitted to the cloud data centers and the applications are generally executed by the processors in the data centers [1].The cloud computing paradigm is efficient in provisioning computation and storage resources for the IoT applications, but the ever-increasing amount of resource requirements of the IoT applications leads to the explosively increased energy consumption and the performance degradation of the computing nodes due to data transmission and computing node migration; thus, how to perform IoT applications becomes an urgent issue [2][3][4][5][6].Fog computing extends the computing process to the edge of the network rather than performing the IoT applications in the cloud platforms.
In the fog environment, the routers are the potential physical servers which could provision resources for the fog services at the edge of the network [7,8].The routers could enhance the performance of computation and storage, which could be fully utilized as the computing nodes.In the big data era, there are different performance requirements for the IoT applications, especially for the real-time applications; thus, such applications choose the edge computing nodes as a priority to host [9,10].In the fog environment, the users could access and utilize the computation, storage, and network resources, like the way the customers use the cloud resources, and the virtualized technology is also applicative to provision the on-demand resources dynamically [11].The IoT applications could be performed by the fog computing nodes and the physical resources deployed in the remote cloud data center.The resource allocation for the IoT applications should take into account both the centralized and the geodistributed computing nodes, and the resource schedulers and managers 2 Wireless Communications and Mobile Computing should choose the appropriate computing nodes to host the fog services combined in the IoT applications through the design of resource allocation strategies.
Resource allocation and resource scheduling are the key technologies to manage the data centers, which contribute a great deal to lowering the carbon emission, improving the resource utilization, and obtaining load balancing for the data centers [12][13][14].In the cloud environment, the main goal of resource allocation is to optimize the number of active physical machines (PMs) and make the workloads of the running PMs distributed in a balanced manner, to avoid bottlenecks and overloaded or low-loaded resource usage [14][15][16][17].In the fog environment, resource allocation becomes more complicated since the applications could be responded to by the computing nodes both in fog and in clouds.The computing nodes in the fog are distributed dispersedly in the network of edge, while the computing nodes in the cloud are distributed in a centralized data center.The resource requirements of the IoT applications for the computing nodes are various as the applications have different demands of computing power, storage capacity, and bandwidth.Therefore, it is necessary to undergo resource allocation for the dynamic resource requirements of the IoT applications, to achieve the goal of load balancing.
With the above observations, it is still a challenge to realize the load balance for the computing nodes in the fog environment during the execution of IoT applications.In view of this challenge, a dynamic resource allocation method, named DRAM, for load balancing in fog environment is proposed in this paper.Specifically, our main contributions are threefold.Firstly, we present a system framework for IoT applications in fog environment and conduct the loadbalance analysis for various types of computing nodes.Then, a corresponding resource allocation method in the fog environment is designed through static resource allocation and dynamic service migration to achieve the load balance for the fog computing systems.Finally, adequate experimental analysis is conducted to verify the performance of our proposed method.
The rest of this paper is organized as follows.In Section 2, formalized concepts and definitions are presented for loadbalance analysis in the fog environment.Section 3 elaborates the proposed resource allocation method DRAM.Section 4 illustrates the comparison analysis and performance evaluation.Section 5 summarizes the related work, and Section 6 concludes the paper and presents the prospect for the future work.

Preliminary Knowledge
In this section, a fog computing framework for IoT applications is designed and the load-balance analysis is conducted as well.
To facilitate dynamic resource allocation for load balancing in fog environment, formal concepts and load-balance analysis are presented in this section.Key notations and descriptions used in this section are listed in the section named "Key Terms and Descriptions Involved in Resource Scheduling in Fog Environment."

System Framework for Fog
Computing.Fog computing is a new computing paradigm, which sufficiently leverages the decentralized resources through the fog and cloud environments, to provision the computation and storage services for the IoT applications.Fog computing extends the data process and data storage between the smart sensors and the cloud data centers.Some of the tasks from the IoT applications could be processed in the fog rather than performing all the tasks in the cloud environment.The virtualized technology could be employed to improve the resource usage in the fog environment.
Figure 1 shows a hierarchical framework for computing tasks from IoT applications in the fog environment.There are four layers in this framework, that is, the IoT application layer, the service layer, the fog layer, and the cloud layer.The IoT application contains a large amount of service requirements that need to be responded to by selecting appropriate computing nodes according to the time urgency and the resource amount from fog and cloud.The fog layer consists of the edge computing nodes and the intermediate computing nodes.The services with the highest time urgency and less computation density can be calculated by the edge computing nodes in the fog layer, and the less urgent tasks could choose intermediate computing nodes for execution.The cloud layer is appropriate to hosting the loose-fitting tasks with high-density computation and huge-volume storage which often demand a large amount of physical resources.The intermediate computing nodes could be the routers for data transmission, the edge computing nodes could be the mobile devices or sensors, and the computing nodes in the cloud are the PMs.
Fog computing is useful for IoT applications which combine many fog services.The fog services cover all the procedures of the data extraction, data transmission, data storage, and service execution from the IoT applications.
Definition 1 (fog service).The services requested by the IoT applications are available to be performed in the fog and remote cloud data centers, denoted as  = { 1 ,  2 , . . .,   }, where  is the number of fog services generated by the IoT applications.
The PMs in the remote cloud data centers, the intermediate computing nodes, and the edge computing nodes in the fog environment are all available to be leveraged to provision physical resources for the fog services.Suppose there are  computing nodes in the fog and cloud environment, denoted as  = { 1 ,  2 , . . .,   }.The virtualized technology has been widely applied in the cloud environment, which is also adaptive in the fog environment to measure the resource capacity of all the computing nodes and the resource requirement of the fog services.
Definition 2 (resource capacity of computing nodes).For all the computing nodes in the fog and cloud, their resource capacities are quantified as the number of resource units, and each resource unit contains various physical resources, including CPU, memory, and bandwidth.Definition 3 (resource requirement of   ).The corresponding resource requirement of the th fog service   could be quantified as the time requirements, the resource type, and the resource amount to perform   , denoted as   = {  ,   ,   ,   }, where   ,   ,   , and   represent the request start time, the duration time, the resource type, and the requested amount of   , respectively.
Note that the resource requirements in this paper are measured by the amount of resource units.For example, in the cloud data centers, the resource units are the VM instances, and the customers often rent several VM instances to host one application.

Load Balancing Model in Fog
Environment.Fog computing paradigm releases the load distribution in the cloud environment.Due to the diversity of execution duration and specifications for the computing nodes in the fog, the resources could not be fully utilized.In the fog environment, we try to achieve load balancing for the computing nodes to avoid low utilization or overload of the computing nodes.
Let    () be the binary variable to judge whether   (1 ≤  ≤ ) is assigned to the computing node   (1 ≤  ≤ ) at time instant , which is calculated by With the judgement of fog service distribution, the resource utilization for the th computing node   at time  is calculated by where   is the capacity of the computing node   .
According to the service distribution, the number of services deployed on   at time instant  is calculated by The load-balance variance should be specified for each type of computing node.Suppose there are  types of computing nodes in cloud and fog environment for performing the fog services.
The load-balance variance is closely relevant to the resource utilization.To calculate the resource utilization, the employed amount of computing nodes with type  at the time instant  is calculated by where    is a flag to judge whether   is a type  of computing nodes, which is described in (5), and   () is used to judge whether   is empty at , presented in (6).

Wireless Communications and Mobile Computing
The resource utilization for the computing nodes with th type at time  is calculated by Definition 4 (variance of load balance of   at time instant ).The load-balance value is measured by the variance of the resource utilization.The variance value for   is calculated by Then, the average variance value for all the type  computing nodes is calculated by For the execution period [ 0 , ] in the fog and cloud environment, the load-balance variance could be calculated by With these observations, the problem of minimizing the variance of load balance can be formulated as follows: min   , ∀ = 1, . . ., where ∑  =1   in formula (13) represents the resource requirements for all services, ∑  =1   in formula (14) represents the capacity of all computing nodes, and ∑  =1      in formula (14) represents the resource requirements for all services allocated to the type  computing node.
From (11) to (14), we can find that the final objective solved in this paper is an optimization problem with multiple constraints [18][19][20].

A Dynamic Resource Allocation Method for Load Balancing in Fog Environment
In this section, we propose a dynamic resource allocation method, named DRAM, for load balancing in fog environment.Our method aims to achieve high load balancing for all the types of computing nodes in the fog and the cloud platforms.
3.1.Method Overview.Our method consists of four main steps, that is, fog service partition, spare space detection for computing nodes, static resource allocation for fog service subset, and the load-balance driven global resource allocation, as shown in the section named "Specification of our Proposed Resource Allocation Method for Load Balancing in Fog Environment."In this method, Step 1 is the preprocess procedure, Step 2 is employed to detect the resource usage for Steps 3 and 4, and Step 3 is designed for static resource allocation for the fog services in the same subset and it provides the primary resource provision strategies for Step 4. Finally, Step 4 is a global resource allocation method to realize dynamic load balance.

Specification of Our Proposed Resource Allocation Method for Load Balancing in Fog Environment
Step 1 (fog service partition).There are different types of computing nodes for the performance of fog services.To efficiently provision resources, the fog services are classified as several sets based on the resource requirements of node type.Furthermore, these sets are divided into multiple subsets according to the request start time.
Step 2 (spare space detection for computing nodes).To judge whether a computing node is portable to host the fog service, it is necessary to detect the spare space of all the computing nodes.We analyze the employed resource units through the analysis of occupation records, and then the spare space of the computing nodes could be obtained.
Step 3 (static resource allocation for fog service subset).
For the fog services in the same service subset, the proper computing nodes are identified to host these services.When allocating resource units for a fog service, the computing node with the least and enough spare space is selected.Besides, some workloads from the computing nodes with higher resource usage are migrated to the computing nodes with low resource usage.
Step 4 (load-balance driven global resource allocation).For all the fog service subsets, we could find the initialized resource allocation strategies in Step 4, and then the dynamic resource allocation adjustment is conducted at the competition moments of the fog services to achieve the global load balance during the execution period of the fog services.

Fog Service Partition. The fog services from different
IoT applications have different requirements of computing resources; that is, the fog services need to choose different  types of computing nodes for resource response.Suppose there are  types of processing nodes, including the PMs in cloud platforms, the intermediate nodes, and the edge nodes near the sensors.
In this paper, we try to achieve the goal of load balancing for each type of computing node; we assume that the fog services need to be performed with the same type of computing nodes.As a result, the fog services could be partitioned as  different service sets, denoted as The resource requirements of the fog services in the same set have different resource response time.To efficiently realize resource allocation for the services, the fog services in the same set should be partitioned to several subsets according to the start time for occupying the resource units of the computing nodes.Then, we can allocate resource units for the fog services in the same set to achieve high load balancing.
The subset f w ( = 1, 2, . . ., ) in F is divided into multiple subsets according to the requested start time of the fog services.Let f w,i be the th (1 ≤  ≤ |f w |) subset contained in f w .After the partition process, the fog services in  , have the same request start time.
Algorithm 1 specifies the process of fog services subset acquisition.In Algorithm 1, the input is the resource requirements of IoT applications, that is, , and the output is the partitioned fog service set F. We traverse all the fog services (Line (1)), and the services are put in different sets according to the requested resource type (Lines (1) to (6)), and then the fog services are put in  different service sets.Then, the set f w is divided to multiple subsets, according to the required start time (Lines (8) to (17)).

Spare Space Detection for Computing
Nodes.The fog services need to be put on the computing nodes; thus, those computing nodes with spare space should be identified.For all the computing nodes, the allocation records are employed to monitor the resource usage of all the computing nodes in the fog and cloud.
Definition 5 (occupation record  , ).The th (1 ≤  ≤ |  |) occupation record in   contains the response fog service, the occupation start time, the duration time, and the resource units, which is a 4-tuple, denoted as  , = ( , ,  , ,  , ,  , ), where  , ,  , ,  , , and  , are the fog service, the start time, the duration time, and the resource unit sets of  , , respectively.
A computing node has a set of occupation records, since it could host several fog services.The record set for the computing node   (1 ≤  ≤ ) is recorded as   .Then, for all the computing nodes in the fog and cloud, there are  occupation record sets, denoted as  = { 1 ,  2 , . . .,   }.In   , there are many occupation records, which reflect the resource usage of the computing node   .
The occupation records are dynamically updated according to the real-time resource provisioning for the fog services.Once the fog services are moved to the other computing nodes during their lifetime, the occupation time parameter should be updated accordingly for the relevant records.The occupation records are generated from the users when they apply for resources in the fog and cloud data center for implementing the services generated from the IoT applications.
Benefiting from the resource monitoring, the occupied resource units of all the computing nodes and the spare units could be detected for resource allocation at any time.
Definition 6 (spare space of   ).The spare space of the computing node   is defined as the idle amount of resource units, which is measured by the difference value of the capacity and the occupied amount of resource units on   .The spare space of the computing node   could be detected from the analysis of occupation records.In these records, if occupation start time is less than the statistic time instant for checking the PM status and the occupation finish time is over the statistic time, the relevant resource units combined in the occupation records could be obtained.With these acquired resource units and the resource capacity of   , the spare space could be finally detected.
Algorithm 2 specifies the key idea of spare space detection for computing nodes.In Algorithm 2, the input and the output are the occupation records of the computing node   and the spare space for   .According to Definition 7, we need to calculate the occupation amount of resource units on   first (Lines (1) to (8)), and then the spare space could be detected (Line (8)).

Static Resource Allocation for Fog Service Subset.
Based on the fog service partition in Section 3.1 and spare space detection for computing nodes in Section 3.2, the fog services that need to be processed and the available computing resources for fog service execution are identified, which are all beneficial for resource allocation.
In the fog environment, the fog services need to be responded to by the computing nodes, and the time requirements also should be presented when allocating the resources to the fog services.In this section, we define the resource allocation records to reserve the allocation history about resource provisioning for the fog services.
Definition 7 (resource allocation record for   ).The resource allocation record for   consists of the node type, the number of resource units, the start time, and the desired duration time, which is denoted as   = (  ,   ,   ,   ), where   ,   ,   , and   are the node type, the amount of resource units, the service start time, and the resource occupation time for   , respectively.
The fog services in the same fog service subset have the same required node type and start time.When allocating resource units for the fog service subset, each fog service should find a portable computing node to host it.Thus, we need to find the available nodes first.The computing nodes with the requested type, which have spare space, which could be detected by Algorithm 2, are chosen as the candidate resources to be provided for the fog services in the subset.
To achieve the load balancing of the computing nodes, we try to achieve high resource usage of the employed computing nodes.The problem of static resource allocation is like bin packing problem, which is NP-hard.Here, we leverage the idea of Best Fit Decreasing to realize the process of computing node matching for the fog services.Before resource allocation, the fog services are sorted in the decreasing order of requested resource amount.The service with more required resource units will be processed first.And it chooses the computing node with the least and enough spare space for hosting the service.
For example, there are 3 computing nodes  1 ,  2 , and  3 , and the spare spaces of these 3 computing nodes are 4, 6, and 9, respectively, as shown in Figure 4.There are two fog services in the same subset, that is,  1 and  2 , and the requested resource amounts of these two services are 2 and 6.When conducting resource allocation for  1 and  2 ,  2 has more resource requirements, and thus  2 is processed first.After resource allocation,  2 chose  3 for hosting and  1 chose  1 for hosting.
The above allocation may lead to the unbalanced distribution of the workloads of some computing nodes.In this section, a threshold  is employed to judge whether the computing node is in low resource utilization.If a computing node is in low resource utilization and there are no other computing nodes that could host the workloads in this computing node, we choose to move some workloads to this computing node to improve the load balance.After resource allocation, there are several allocation records generated, to record the allocation history for the fog services in the service subset.Meanwhile, there are some computing nodes, providing resource units for executing the fog services, which also generate some occupation records.
Algorithm 3 illustrates the key idea of static resource allocation for fog service subset f w,i .The input of Algorithm 3 is the fog service subset f w,i , and the output of this algorithm is the resource allocation records for the fog services in f w,i .The required computing nodes of fog services in the same subset have the same node type, which should be obtained first (Line (1)).The services with fewer requested resource units will be processed first, so f w,i should be sorted in the increasing order of the amount of values of required resources.Then, each service could be responded to with computing nodes sequentially (Line (3)).When selecting a computing node to provision resources for a fog service, the available computing nodes with enough spare space to host the service, calculated by Algorithm 2, should be achieved first (Lines (4) to (11)).The computing nodes also should be sorted in the increasing order of spare space (Line (12)).Then, the computing node with the least spare space will be selected to accommodate the service (Line (13)).Some workloads from the computing nodes with higher resource usage will be migrated to the computing nodes with low resource utilization to improve load balance (Lines (15) to (24)).Finally, the relevant occupation records and the resource allocation record for the fog service should be updated (Lines (25) and (26)).

Load-Balance Driven Global Resource Allocation.
From the analysis in Sections 3.2 and 3.4, the initialized resource allocation is conducted, and the different types of computing nodes could achieve high resource utilization and load balancing at the allocation moment.However, the static resource allocation only could achieve the temporary load balancing at the service arrival moments.During the service running, the resource usage of the computing nodes is dynamically changed due to the various lifetimes of the fog services.In this section, a global resource allocation strategy is designed to make load balancing come true during the execution of the fog services.
Input: The fog service subset f w,i Output: The relevant resource allocation records (1) Get the node type nt in the service subset f w,i (2) Sort f w,i in decreasing order of required resource amount (3) for each fog service in f w,i do (4) for  = 1 to  do (5) if   has the same type with  then (6) Get the spare space byAlgorithm 2 (7) if   has enough space to host the service then (8) Add The fog service subsets demand the same type of computing nodes for hosting sequentially according to the requested start time of the resources.Let  , be the requested start time for resource occupation of the th subset  , in f w .For dynamic adjustment of resource allocation at the finish time of the fog services in  , (1 ≤  < |f w |), the scheduling time should be with the time period ( , ,  ,+1 ).When  = |f w |, the scheduling time should be the competition time for the rest of the fog service loads during the period for the execution of the fog services in f w,i .
At the scheduling time, the running workloads occupy some computing nodes, and these computing nodes may be with low resource usage due to the service competition.The computing nodes with the same type in fog or cloud could be sorted in the decreasing order of the resource usage.The workloads in the computing nodes with the lower resource usage could be migrated to the computing nodes with higher resource usage, to achieve higher resource utilization.Besides, the migration of workloads could also help to realize the goal of load balancing as the computing nodes with more spare space could be moved vacant and shut down further.
For the workloads from different fog services, it is necessary to find the destination computing nodes to host them.The selection of destination computing nodes decides on the resource requirements of the workloads and the spare space of the computing nodes.If all the workloads from the same computing node could find the destination computing nodes, these workloads could be migrated to the destination computing nodes.Finally, the resource allocation records and the occupation records are generated or updated according to the real occupation computing nodes and the usage time of the corresponding resource units.
Algorithm 4 illustrates the key process of load-balance driven global resource allocation.The key idea of Algorithm 4 is to conduct static resource allocation for the fog services at the start execution time and dynamically adjust the service placement according to the resource usage of all the employed computing nodes.The input of this algorithm is the fog service set , and the final output of this algorithm is the resource allocation records and the occupation records.In this algorithm, the fog service subset is achieved first by Algorithm 1 (Line (1)), and then we traverse each subset for resource allocation (Line (2)) and conduct static resource allocation for the subsets by Algorithm 3 (Line (3)).Then, for each subset, the competition time list  is extracted for loadbalance driven dynamic resource allocation (Line (5)).Then, at each competition instant, we adjust the resource allocation records for the running services (Line (6)).The fog services on the computing node with less spare space would be moved to the computing node with higher resource usage, which has enough spare space to host the services (Lines (8) to (20)).
When all the fog services on a computing node could find the destination node, the relevant allocation records and the occupation records for the resource units will be generated and updated (Lines (15) to ( 27)).

Experimental Analysis
In this section, the cloud simulator Cloudsim is applied to evaluate our proposed method DRAM.The intermediate computing nodes and the edge computing nodes are simulated as two computing data centers.The resource allocation method for fog environment is NP-hard, like the bin packing problem; thus, the typical and efficient resource allocation methods FF, BF, FFD, and BFD are employed for comparison analysis.

Experimental Context.
To discuss the effectiveness of DRAM, 4 datasets with different scale of fog services are utilized, which are shared at https://drive.google.com/drive/folders/0B0T819XffFKrZTV4MFdzSjg0dDA?usp=sharing.The parameters for experimental evaluation are presented in Table 1.The fog services employ three types of computing nodes, that is, the edge computing node, the intermediate node, and the PMs in cloud for resource response.The number of services for each type of computing node contained in the 4 different datasets is shown in Figure 5.For example, when the number of fog services is 1000, there are 324 fog services that need edge computing nodes, 353 fog services that need intermediate computing nodes, and 323 fog services that need PMs in the remote cloud for resource response.

Performance Evaluation.
Our proposed method tends to minimize the load-balance variance, which is relevant to the resource utilization of each computing node and the average resource utilization.Therefore, we conduct performance evaluation for this fog computing system on the employed number of computing nodes, resource utilization, and loadbalance variance.
(1) Performance Evaluation on the Employed Number of Computing Nodes.The number of the computing nodes could reflect the efficiency of resource usage.Figure 6 shows the comparison of the number of employed computing nodes  by FF, BF, FFD, BFD, and DRAM by using the 4 different scales of datasets.From Figure 6, we can find that our proposed method DRAM as well as BFD could employ fewer computing nodes, compared with FF, BF, and FFD, when the number of fog services is 500, 1000, and 2000.When the number of fog services is 1500, our proposed DRAM could even get higher efficiency on the employed number of computing nodes than BFD.In the process of static resource allocation, DRAM leverages the basic idea of BFD; thus, in most cases, DRAM and BFD have similar performance on the amount of employed computing nodes.But when some of the computing nodes are spared through the process of DRAM, thus in some cases, DRAM is superior to BFD.
As there are 3 types of computing nodes in our experimental evaluations, we should evaluate DRAM for the different types of computing nodes, compared to the other four methods.The 4 subfigures in Figure 7 show the comparison of the number of the employed computing nodes with different types by FF, BF, FFD, BFD, and DRAM using different datasets.It is intuitive from Figure 7 that our proposed method DRAM is fit for all kinds of computing nodes, which employs fewer computing nodes than FF, BF, and FFD, and gets similar performance to BFD in most cases.
(2) Performance Evaluation on Resource Utilization.The resource utilization is a key factor to decide the load-balance variance; thus we evaluate this value to discuss the resource usage achieved by FF, BF, FFD, BFD, and DRAM with different datasets.The resource utilization is referenced to the resource usage of the resource units on the computing nodes.Figure 8 shows the comparison of average resource utilization by FF, BF, FFD, BFD, and DRAM with different datasets.It is intuitive from Figure 8 that DRAM could obtain better resource utilization than FF, BF, FFD, and BFD, since DRAM is a dynamic and adaptive method which could adjust the load distribution during the fog service execution.
Similar to the evaluation on the employed amount of computing nodes, the performance evaluation on resource utilization is conducted from the perspective of the different types of the computing nodes.Figure 9 shows the comparison of resource utilization for different types of computing nodes by FF, BF, FFD, BFD, and DRAM with different datasets.From Figure 9, we can find that DRAM could achieve higher resource utilization than FF, BF, FFD, and BFD.For example, in Figure 9(c), when the number of fog services is 1500, DRAM obtains the resource utilization over 80%, whereas FF, BF, FFD, and BFD obtain near or below 70% resource utilization for each type of computing node.
(3) Performance Evaluation on Load-Balance Variance.The evaluation of the load-balance variance is also conducted by FF, BF, FFD, BFD, and DRAM using 4 different scales of datasets.Figure 10 shows the comparison of average loadbalance variance, where we can find that our proposed method DRAM is superior to the other methods, that is, FF, BF, FFD, and BFD.For example, when the number of fog services is 500, the load-balance variance obtained by DRAM is near 2.5 × 10 −2 , whereas FF, BF, FFD, and BFD obtain the load-balance value over 3 × 10 −2 .
The evaluation on the load-balance variance also should take into consideration the computing node type.Figure 11 shows the comparison of load-balance variance values for different types of computing nodes by FF, BF, FFD, BFD, and DRAM with different datasets.From Figure 11, we can find that when changing the scale of datasets, our method can keep the priority on the load-balance variance for each type of computing node.

Related Work
The IoT technology has been widely applied in many fields, including weather forecasting and traffic monitoring.The  data storage and processing usually benefit from the cloud computing which provides scalable and elastic resources for executing the IoT applications [21][22][23][24][25][26].In the ever-expanding data volume, cloud computing is difficult to provide efficient, low-latency computing services, and fog computing is proposed to complement the above shortage of cloud computing [1,2].Compared to the remote cloud computing center, fog computing is closer to the Internet of Things devices and sensors.Fog computing can quickly solve lightweight tasks with fast response.In the era of big data, with cloud computing expansion, fog computing is widely used in the medical, transportation, and communication fields, to name a few [21,[27][28][29][30].
Hu et al. [21] designed a fog calculation framework in detail and compared it with the traditional cloud computing, and a practical application case in the fog computing environment was put forward.Similarly, Kitanov and Janevski [27] compared the cloud computing on computing performance with fog computing in the 5G network, reflecting the superiority of fog computing.Akrivopoulos et al. [28] presented a technology to respond to the combination of IoT applications and the fog computing and introduced the use of fog computing in an automated medical monitoring platform to improve the medical work for the patients.Arfat et al. [29] not only unprecedentedly proposed the integration of mobile applications, big data analysis, and fog computing, but also introduced Google Maps as an example, showing the system of information feedback diversification.Taneja and Davy [30] studied the computational efficiency in the fog environment and constructed a resource-aware placement.
Generally, resource allocation refers to the allocation of specific, limited resources and effective management to achieve the optimal use of resources.The original intention of cloud computing is to allocate network resources on demand, so that it is the same as the use of water and electricity billing [31,32].In the cloud computing, resource allocation method can effectively help to achieve the goal of high resource usage and energy saving for centralized resource management for different types of applications [4,[33][34][35].Fog computing, as an extension of cloud computing paradigm, also needs to conduct resource allocation to achieve high-efficiency resource usage.
Mashayekhy et al. [36] proposed an auction-based online mechanism; it can access in real time the actual needs of users and the allocation of appropriate resources to the user price.Kwak et al. [37] developed a DREAM algorithm for complex tasks in mobile devices, saving 35% of total energy and managing network resources.To address the challenges of high latency and resource shortage in clouds, Alsaffar et al. [38] proposed the resource management framework, collaborating the cloud computing and the fog computing, and then they optimized the resource allocation in fog computing.Xiang et al. [39] designed a RAN (F-RAN) architecture based on atomization calculation, which effectively achieved the high resource usage and could coordinate the global resource scheduling.
Load balancing is an effective factor to determine the resource allocation strategy.For multiple computing tasks, load balancing could promote the resource managers to assign these tasks to multiple computing nodes for execution.The realization of load balancing not only can save the cost of hardware facilities but also can improve resource efficiency.
Banerjee and Hecker [40] proposed a distributed resource allocation protocol algorithm to realize load balancing in a large-scale distributed network; as a result, compared to the FIFO, the response time and resource utilization could be greatly improved.Govindaraju and Duran-Limon [41] designed a method based on the lifecycle-related Service Level Agreement (SLA) parameters of the virtual machines in cloud environment to address resource utilization and cost issues.Evolution algorithms are proved to be powerful to solve the multiobjective problem, which could be leveraged in the resource scheduling in the fog computing [42].Jeyakrishnan and Sengottuvelan [43] developed a new algorithm, while saving operating costs, while maximizing the use of resources, in the balanced scheduling compared to SA, PSO, and ADS being more outstanding.
For the load balancing maximization problem solved in this paper, the traditional operations research is proved to be efficient in optimization problem with constraints [44,45].The game theory is also efficient for the resource allocation with resource competition, and the Nash Equilibria are often needed to be verified first [46,47].
To the best of our knowledge, there are few studies focusing on the resource allocation of fog services in the fog environment which aims to realize the load balancing for the computing nodes in both fog and cloud.

Conclusion and Future Work
In recent years, IoT has been one of the most popular technologies for daily lives.With rapid development of IoT, fog computing is emerging as one of the most powerful paradigms for processing the IoT applications.In the fog environment, the IoT applications are performed by the edge computing nodes and the intermediate computing nodes in the fog, as well as the physical machines in the cloud platforms.To achieve the dynamic load balancing for each type of computing node in the fog and cloud, a dynamic resource allocation method, named DRAM, for load balancing has been developed in this paper.Firstly, a system framework in fog computing was presented and load balancing for the computing nodes is analyzed accordingly.Then, the DRAM method has been implemented based on the static resource allocation and dynamic resource scheduling for fog services.As a result, the experimental evaluations and comparison analysis were carried out to verify the validity of our proposed method.
For future work, we try to analyze the negative impact of the service migration, including the traffic for different types of computing nodes, the cost for service migration, the performance degradation for the service migration, and the data transmission cost.Furthermore, we will design a corresponding method to balance the negative effects and the positive impacts for service migration.

Figure 5 :
Figure 5: Number of fog services for the 3 types of computing nodes with different datasets.

Figure 6 :
Figure 6: Comparison of the number of employed computing nodes by FF, BF, FFD, BFD, and DRAM with different datasets.

Figure 7 :Figure 8 :
Figure 7: Comparison of the number of the employed computing nodes with different types by FF, BF, FFD, BFD, and DRAM using different datasets.

Figure 9 :Figure 10 :Figure 11 :
Figure 9: Comparison of resource utilization for different types of computing nodes by FF, BF, FFD, BFD, and DRAM with different datasets.
The resource requirements of IoT applications  Output: The partitioned fog service set F (1) for  = 1 to  do (2) for  = 1 to  do //There are  types of computing nodes in fog and cloud Input: Figure 4: An example of static resource allocation for fog services  1 and  2 , with computing nodes  1 ,  2 , and  3 .
Identify the occupied computing nodes from  to   (17) Sort   in the decreasing order of spare space