1. Introduction
IoT devices generate a large amount of data as they are interconnected [
1]. Most current proposals focus on centralized or cloud architecture [
2]. The goal of a centralized architecture is to process data in one place of decision. Consequently, a significant amount of data must be uploaded to the cloud. Heavy data transmission over the network is one of the challenges introduced by this architecture [
3]. This suggests that an alternative design is necessary to address this challenge. Since the IoT architecture connects several devices with varied levels of computing, storage capacity, battery life, and Internet access, device constraint awareness is a crucial part of its design.
Also, a variety of services will be available, each with different set of expectations, such as those for capability, quality of data, and latency. These services operate on fog computing devices, which are limited in terms of power when compared to cloud resources [
4], and they require bandwidth. This implies that fog devices and services are closely connected. The main challenge is to allocate the services primarily to the fog whenever possible, and then to the cloud when the fog is not capable of handling services while considering the overall efficiency within a specific IoT architecture.
Furthermore, resource management at the fog layer [
5] is critical for evaluating the advantages of fog computing. Developing an effective fog infrastructure presents several issues. One instance where resolving the following issues becomes essential is with RAM. The execution of services within a distributed architecture becomes more challenging as the size and complexity of the IoT system increase, necessitating a method to allocate services to the node(s), which results in discovering the ideal allocation strategy.
Processing all incoming raw data in the cloud has a detrimental impact on various elements, including higher network congestion, latency, the time it takes to return actions to a user, energy usage, and privacy [
6]. As the Internet of Things expands, there is a need to address these challenges. Fog devices are restricted devices because of their limited computing power when compared to the cloud. As a result, huge workloads cannot be processed on fog devices. In addition, determining the amount of computing load that may be allocated to a fog device is challenging. Furthermore, distributing services among fog devices is difficult since the large number of services in the IoT might demand a lot of computing power [
7]. Effectively allocating services to fog devices with limited resources in an IoMT system presents a challenge. This necessitates the allocation of services based on priority to both fog and cloud devices while considering resource constraints and optimizing for efficient processing. As a result, we must understand the devices’ capabilities and services’ demands. Next, we must optimize the process of service allocation to the devices while maintaining optimal resource utilization.
This paper’s overarching goal is to provide an effective allocation technique for processing data with reduced bandwidth utilization, faster response time, optimized resource usage, and identifying an optimal approach for processing data on a large scale. One of the objectives is to evaluate and test the proposed technique using a simulation. We propose an efficient allocation strategy that brings processing closer to the fog side of the network. Moreover, we investigate which devices and services may be best allocated while preserving resource use in the IoT architecture. In addition, we offer a service allocation technique for allocating services to devices depending on their capabilities. Our main contributions include the following:
Service allocation techniques are significant because providing services to devices in the IoT is a difficult process due to the many types of devices and their capabilities. As a result, we propose priority-based service allocation (PSA) and sort-based service allocation (SSA) techniques, which utilize a list of every fog device connected to the network. This method makes it possible to use fog devices in the best possible sequence to conduct a wide range of services. As a starting point, we use packing problems as a baseline to help solve allocation issues in the IoT environment.
We examine the importance of allocating services to devices and optimizing resource use in fog computing to enhance service quality while meeting the optimal resource usage demands of IoMT. As there will be a large variety of services and devices in the IoT settings, it is vital to allocate the services to the devices and effectively optimize resource consumption.
We evaluate the PSA and SSA techniques using a synthetic dataset that mimics the IoT services and devices. We perform a tradeoff analysis to illustrate the effectiveness of the service allocation approach. The results reveal that the data communication over the network decreased by 96%, as most services are allocated in the fog. Additionally, latency is reduced by approximately 88%.
The remainder of this paper is organized as follows:
Section 2 presents related works in the field of service allocation;
Section 3 describes the research problem and provides a motivational scenario;
Section 4 provides the methodology, including the algorithm and the architecture;
Section 5 presents the experimental setup and reveals the details of the experiments;
Section 6 shows the results that were obtained from experiments and provides a description of the results; followed by discussion and evaluation; finally,
Section 8 presents our conclusions and recommendations for future research.
2. Related Works
Fog computing has become an increasingly popular topic of research in recent years, as it offers a number of benefits for various industries [
8]. One of the main challenges in fog computing is data distribution and allocation. This literature review aims to explore the current state of research on service allocation in fog computing and highlight key references in the field.
Analyzing data closer to the fog leads to reduced latency, and increased efficiency, as well as improved security and privacy [
9]. Fog computing also enables the deployment of computing resources closer to the data source, reducing the need for data transmission over long distances. This can lead to improved performance and lower energy consumption.
Regarding service allocation, research has focused on the use of optimization techniques to allocate resources efficiently in fog computing environments. Optimization techniques such as game theory, packing, linear programming, and scheduling can also be used to model and solve service allocation problems in fog computing environments.
In the context of resource allocation in edge and fog computing, we reviewed research publications that focus on fog systems. The underlying infrastructure is assumed in these studies to be cloud–fog [
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26]. These options fall under the system elements aspect and have a significant impact on the researchers’ optimization goals. When considering cloud and fog computing, many academics believe that the workload is initially stored in the cloud, and the edge system must decide where to duplicate and how to distribute the user load among them [
11]. As a result, they offer a framework for pushing applications that require lots of resources to the fog and reducing average data communication in the edge network across access points by duplicating cloud services on some of the edge servers. Workload distribution over systems that are heterogeneous has to consider the availability of various resources [
27]. When spreading the workload between fog and cloud, the objective is to reduce energy consumption in order to meet service latency needs [
28]. When a specific research project does not assume the use of a central cloud but instead addresses multi-fog situations, the issue may arise from the combined optimization of job distribution, virtual machine placement, and resource allocation [
12]. The authors in [
14] attempt to reduce the load on users by determining user association, joint service placement, and joint allocation.
However, most of the publications have the same optimization objective(s), namely, service completion latency [
12,
15,
16,
20,
21,
22,
23]. Numerous research endeavors have been undertaken to address the trade-off between energy consumption and delay in data transmission [
27,
28]. In addition to providing prompt service completion to users, researchers aim to accommodate numerous users with the edge fog [
19,
22]. Cost minimization includes several aspects, such as resource usage, quality of service, and its associated revenue. The authors of [
29] calculated the total cost of deployment by considering the wireless communication cost and the function placement computation cost, and the authors of [
13,
24], to maximize user allocation numbers in their cost, considered the usage of edge servers to have quality of service. In addition, the data communication over the network is also considered one of the aspects of the cost.
Optimization techniques play a crucial role in the efficient management of resources in fog computing and IoT environments [
30]. One popular optimization technique used in these environments is bin packing. Bin packing is a combinatorial optimization problem [
31,
32] that involves packing a set of items into a fixed number of bins, with the goal of minimizing the number of bins used or the overall cost of the solution. In fog computing and IoT environments, bin packing can be used to optimize the placement of services and devices, taking into account factors such as network conditions, service requirements, and device characteristics to minimize the overall cost of the solution by reducing the number of fog nodes used.
There are many variations of the bin packing problem, including the multi-dimensional bin packing problem [
33] and the multi-constraint bin packing problem [
34]. These variations can be used to add extra constraints and requirements in fog computing and IoT environments. For example, the multi-dimensional bin packing problem can be used to take into account the different resource requirements of services and devices, and the multi-constraint bin packing problem can be used to take into account additional constraints such as security and privacy.
In the literature, there are several works that have proposed the use of bin packing for the optimization of service allocation and task scheduling. The authors of [
35] attempted to enhance task scheduling by transforming it into a bin packing problem. Three modified versions of bin packing algorithms based on the minimization of makespan were presented for use in task scheduling (MBPTS). They used the Cloudsim [
36] open-source simulator. When compared to scheduling algorithms such as first come first serve (FCFS) and particle swarm optimization (PSO), the results of the proposed MBPTS were adequate to optimize balancing results, reducing the waiting time and improving resource utilization. The authors of [
13] presented the edge user allocation (EUA) problem as a bin packing problem and presented a unique optimum solution based on the lexicographic goal programming technique. They ran three sets of tests to compare the suggested strategy to two sample baseline approaches. The experimental findings reveal that their strategy performs substantially better than the other two alternatives. In [
37], the authors presented a methodology for minimizing resource waste through resource consolidation, which is accomplished by allocating many requests to the same machine. Bin packing is offered to perform semi-online workload consolidation. The suggested approach is built on bins, with each job allocated a bin that is subsequently allocated to a machine. The suggested approach addresses the issue of request reduction in real-time resource assignment. The suggested technique obtains information in a brief time frame, allowing for more accurate decisions. Their findings reveal that during periods of high demand, their optimal policy can result in saving up to 40% more resources than the other policies and is resistant to unpredictability in task lengths. Finally, they demonstrate that even slight increases in the permitted time window result in considerable improvements, but that bigger time windows do not always improve resource use for real-world datasets. In summary, bin packing is a powerful optimization technique that can be used to efficiently manage resources in fog computing and IoT environments. By taking into account factors such as network conditions, device capabilities, and additional constraints, bin packing can be used to minimize the number of resources used and reduce the overall cost of the solution.
The summary of existing works on resource allocation in fog computing is presented in
Table 1. The authors of [
38] tackle the problems of allocating resources in cloud computing by using two methods: the tasks to virtual machines distribution challenge as a linear programming model and the task allocation algorithmic solution, additionally referred to as the Hungarian algorithm-based binding policy (HABBP), to address the task distribution issue in the context of cloud computing. A genetic algorithm-based virtual machine placement (GABVMP) can also be used to address and optimize the VM deployment problem in a cloud computing setting. The authors in [
39] offer the novel concept of fog-cloud clustering, aiming to address the challenge of determining the optimal number of required clusters. Their research focuses on effectively scaling the network node count within the fog environment. They present a new technique that uses mixed-integer linear programming (MILP) to derive both lower and upper constraints on the required number of clusters. The work given in [
40] presents an efficient resource allocation technique known as the effective prediction-based resource allocation method (EPRAM). This technique employs both deep reinforcement learning (DRL) and probabilistic neural network (PNN) methodologies. While the DRL component handles resource allocation decisions, the PNN prediction algorithm is used to select target destinations. The proposed approach not only efficiently minimizes the time span but also improves resource consumption. In addition, another strategy used for resource allocation was adopted to enhance the RL. The study in [
41] provides two significant contributions: utilizing PSO for optimization of RL hyperparameters and employing the improved RL for resource allocation in the fog environment. In terms of optimization, the hyperparameters on the improved RL present an efficient approach. In [
42], the authors describe a resource allocation technique known as energy-aware multiple linear regression. The strategy focuses on balancing energy consumption and execution time, with the goal of significantly reducing both delay and response time. By considering multiple linear regressions, the proposed method successfully handles energy efficiency optimization while ensuring fast and responsive system performance. The authors in [
43] conducted a thorough analysis of fog-related resource allocation using the cross-layer design concept. Their new approach takes into account the cloud center device, fog nodes, and user devices as essential aspects of the cloud–fog user ecosystem. Their main objective is to maximize efficiency and outcome by allocating resources in the most efficient way possible using a gradient-based method. The authors in [
44] present an approach for displaying resources in fog computing using MEC (multi-access edge computing) APIs. These APIs make real-time information on the CPU, memory, storage, and networking capabilities of fog devices available. This useful information is used by the fog’s supervising entity to make informed decisions about distributing tasks among the network’s nodes. Furthermore, the researchers developed a Lyapunov-based optimization technique for resource allocation in fog nodes and defined the challenge of latency minimization. The authors demonstrate through simulation that their combined method, which involves both resource representation and optimization of resource allocation, efficiently minimizes latency, and hence improves system performance. Authors in [
45], introduced a mathematical artifact called the Markov blanket. This artifact likely plays a significant role in the management of distributed computing continuum systems. The authors in [
46] focused on addressing energy and delay constraints within a computational context. The authors proposed a strategy called transmission scheduling and computation offloading (TSCO), which aims to optimize energy consumption and reduce delays by intelligently scheduling transmission and offloading computations.
Most of the literature has focused on allocation strategies in the cloud without paying sufficient attention to service allocation in fog and IoT environments. These environments consist of various capability devices, including both constrained and high-capability devices. However, they are not as powerful as the devices in the cloud. This makes the process of allocating services to devices more challenging. It requires a sound allocation strategy while optimizing all aspects such as data communication, energy usage, resource wastage, and response time. Moreover, the proposals in the literature have focused on network conditions and device characteristics, but they have not paid attention to the technical requirements of services and tasks during the allocation process. This is important, since services and tasks have technical requirements similar to those of the devices’ capabilities. In our proposal, we considered both device capabilities and the technical requirements of services to achieve a comprehensive understanding of the allocation process and efficiently allocate services to devices.
3. Research Problem and Motivational Scenario
As the number of IoT devices linked to the Internet has grown, so has the number of services, and businesses have begun to install additional services for various objectives. Most IoT devices have limited resources such as RAM, CPU, and storage, along with limited battery capacity. Furthermore, each deployed service has comparable constraints related to similar resources. Additionally, it is crucial to take into account the data-processing capacities of IoT devices while implementing and distributing services. As a result, before providing information about services to IoT devices, we must understand their limitations.
Considering a hospital environment where the distribution of IoT devices and services is crucial for bothIoT and healthcare. The hospital setting is composed of many IoT devices, such as sensors, wearables, and medical devices, all of which are linked together by an IoMT system. These devices continuously monitor and collect information about patient health factors in real time. In this scenario, our focus is on service distribution within the IoMT system to ensure efficient resource utilization and provide excellent patient care. Each patient who visits the hospital is given a unique identification, and their health information is collected and securely preserved. In addition, the physician allocates each individual a priority rating according to the seriousness and necessity of their health condition.
Whenever a patient comes to the hospital, they are subjected to a range of tests and examinations to determine the severity of their illness. These examinations can range from simple blood tests and an electrocardiogram (ECG) to more complicated diagnostic scans like magnetic resonance imaging (MRI) or X-rays. Each test generates various types of data with varying levels of complexity and resource requirements. For example, MRI and X-rays produce videos and images data in healthcare. Additionally, the physician determines whether the patient is of high or low priority. The system then treats this process as a single service, considering its priority. These services with priority levels will be allocated to the fog devices (, …, ) for processing. The fog devices will start by processing the high-priority services, followed by the processing of lower-priority services. Finally, when the fog devices are unable to process the services (either due to low or high priority), the cloud devices (, …, ) will receive the services for further analysis. For example, if a patient is listed as a high priority, then the system will send the patient’s service to the fog device for processing and obtaining a fast response. However, if the patient is in low-priority condition and the fog devices are not capable, then the service will be allocated to the cloud. In only one situation, when the fog devices are not capable of processing high-priority services, they will be allocated to the cloud for further processing.
Figure 1 depicts various types of fog, IoT, and healthcare equipment within a hospital environment. The hospital contains numerous patients (
, …,
) who are undergoing health check-ups. Moreover, the hospital offers a variety of services (
, …,
) to patients. Some patients are seeking treatment for dental problems, immunization, lung issues, kidney and internal medicine problems, diabetes, eye problems, brain disorders, pregnancy, and heart conditions. In our scenario, we regard these health issues that patients experience as components of services (S). In other words, each user can have one or more services. When a user has a service, the service (
) will contain all the patient and test data.
Furthermore, analyzing image and video data may require more processing capacity than numerical analyses like blood test results or ECG results. This is due to their volume and the methods they employ, indicating that the capabilities of the fog layer must be sufficiently robust to handle these services. As a result, because fog devices have limited processing capability when compared to cloud devices, it is not viable to implement these services on them. Due to resource-constrained devices in regard to hardware, service allocation is a crucial part of fog architecture. Furthermore, certain fog devices remain unused due to their limited power capabilities for service execution. This implies that although these fog devices are required for data processing, they are overlooked due to power limitations. This situation can worsen when billions of services are sent to numerous devices and executed by them. This signifies that there is a waste of network devices, which may cause the computation time to be delayed. The waste of devices occurs when devices are not used owing to restrictions and remain in the network unused, losing the available resources. The main challenge is determining which service should be allocated to which device in a fog architecture while maintaining overall efficiency. This is analogous to optimization problems, which can be deemed highly suitable for allocation problems.
3.1. Assumptions
We assume that the fog layer’s devices have limited RAM capabilities compared to cloud devices. For our experiments, a synthetic dataset is generated. The dataset has services’ technical requirements, fog devices’ capabilities, and the priorities of services. The dataset has 800 services with varying technical requirements, and there are 50 fog devices with varying capabilities. The technical needs of services and the devices’ capabilities are known. The connection between devices in our experiments is outside the scope of our study.
3.2. Process
The model starts by building synthetic data for both the requirements of services and the capabilities of devices to prepare them for the allocation model. The fog devices’ capabilities are predefined, with fog devices being less capable when compared to cloud devices. The allocation technique is used to distribute services based on service requirements, service priority, and device capabilities. Services will be allocated across fog or cloud devices depending on the needs of the services, considering device capabilities and service priority.
4. Methodology
We propose the PSA and SSA techniques, which are techniques for allocating resources based on a list that includes all fog devices connected to the network. This method allows us to determine the sequence in which different services are executed by various devices. The actual capacities of devices, such as RAM, are used to arrange the list of devices. As a result, for each physical aspect, all devices’ capabilities are maintained in a list. The main purpose is to allocate services to devices in an effective and optimized manner. The allocation technique is utilized to allocate all or a part of the services to a specific number of fog devices or to various cloud devices with varied capabilities according to their capability. Furthermore, the allocation approach aims to maximize fog device usage and minimize data communication over the network. An overview of our proposed strategy is presented below with equations.
The main goal
G is to allocate the services
to fog devices
as much as possible in an effective manner. We can represent this as:
where
is a binary variable that represents whether or not service
is allocated to fog device
. If
, then service
is allocated to fog device
, and if
, then service
is not allocated to fog device
. The notation
calculates the total number of services allocated to fog device
, where
N is the total number of services. The objective is to maximize this quantity over all possible allocations to fog devices.
The services will be allocated by the fog device to either fog devices
or cloud devices
, dependent on the capabilities of the devices and the computing needs of the services. We can represent this as:
The services will then be allocated according to their requirements to the fog devices since this is the focus of our strategy. We can represent this as:
If the fog devices are unable to manage the load, the remaining services will be allocated to the cloud-based devices. We can represent this as:
Therefore, to have efficient results, we used both fog devices and cloud devices for service allocation. We can represent this by combining the previous two relations as follows:
4.1. Objective Function
We have a multi-criteria optimization problem. The goal is to maximize the weighted sum of two objective functions,
for decreasing delay and
for optimizing the usage of resources. The weighting variables
and
are used to balance the significance of the two objectives and manage the trade-off between conflicting goals. These can be considered performance objectives for our strategy. The function that needs to be maximized is described below:
where
is the objective function for minimizing latency (i.e., the time it takes for a service to be allocated from fog to cloud), and
is the objective function for maximizing fog resource utilization (i.e., using the fog devices as much as possible while minimizing resource wastage). Here,
x is a vector of variables, and
and
are weighting factors used to balance the importance of the two objectives.
The minus sign in front of indicates that we are maximizing the negative of , which is equivalent to minimizing . Similarly, we maximize by multiplying it with a positive weight . The aim of integrating two objectives into a single objective function is to determine the optimal trade-off between them. By maximizing , we intend to find x values that simultaneously minimize and maximize , with appropriate weightings. The range of values of + = 1.
4.1.1. Best Fit
The presented algorithm, called “Best Fit”, is used to allocate services to devices depending on their capacity and technical requirements of services. We provide the best fit code in Algorithm 1 to maximize device usage while delivering services to devices based on their capabilities. We require the service requirements
and device capabilities
as input. Then, for each service, we find the smallest possible device capability that may accommodate the current service.
If a device is found, it should be assigned to the current service. If a device cannot be found, we disregard it and proceed with the other services. We do not break down the services into smaller ones, but rather assign them to one of the devices, either a fog device or a cloud device, according to their capabilities.
Algorithm 1 Best Fit |
Input: [],
[] Output: [] for
to
do for to do if then if then else if then end if end if end for if then end if end for |
In other words, services are assigned to available devices based on the best fit criteria. The algorithm takes two parameters: and . Each device’s capacity is represented by , and the service request is represented by . The algorithm begins with two nested for-loops. The outer loop starts at 0 and iterates up to the length of , while the inner loop starts at 0 and goes up to the length of . The outer loop processes every service request one at a time, while the inner loop checks every device’s capacity to see if it can handle the present service request.
The is initially set to −1. If the capacity of the device at index y is greater than or equal to the capacity of the service request at index x, the is assigned to y in the inner loop. If remains −1, it signifies that no device is currently allocated to the service. If has been assigned a value, a comparison is made between the present device’s capacity () and the device assigned previously (). If the current device’s capacity is smaller than that of the earlier assigned device, the is changed to the present device (y).
After the inner loop completes, if is not −1, the current service is assigned to the device with the best fit (). The allocation is recorded by updating the list, and the capacity of the device is decreased by the service request. The algorithm will keep running the outer loop until all the service requests are processed, and the devices are allocated to the services. The method returns , which represents the index of the device allocated to the service. The result of the algorithm is the allocation of services to the devices.
For instance, let us consider the following fog device capabilities: FDC1 = 16,384 MB, FDC2 = 8192 MB, FDC3 = 4096 MB, and FDC4 = 2048 MB; along with the following service requirements: 2048 MB, 2048 MB, 2048 MB, 2048 MB.
Table 2 shows the results of best fit example after running the code.
Service request = 2048, allocation ID = 1, fog device = 2048. This indicates that the first service requirement, which has a size of 2048 units, is assigned to a fog device with a RAM of 2048.
Service request = 2048, allocation ID = 2, fog device = 4096. The second service request, also of size 2048 units, is assigned to a different fog device with a RAM of 4096. Because this device has a capacity of at least 2048, it can accommodate the service request.
Service request = 2048, allocation ID = 3, fog device = 4096. The third service request, also with a size of 2048 units, is assigned to the same fog device as the second request. The fog device’s capacity is still adequate to handle this request.
Service request = 2048, allocation ID = 4, fog device = 8192. The fourth service request, also with a size of 2048 units, is assigned to a different fog device with an ID of 8192. This device has enough capacity to accommodate the request.
In summary, the allocation process involves assigning each service request to a specific fog device based on available capacity. The allocation IDs help track which request is assigned to which fog device. The process ensures that fog devices with sufficient capacity are selected to handle the requests. As the allocation progresses, the capacity of the fog devices is adjusted accordingly.
4.1.2. Worst Fit
We provide the worst fit code in Algorithm 2 to optimize device usage while assigning services to devices and considering device capabilities. We require service requirements
and device capabilities
as input. Following that, we select each service and identify the most capable device that can support the current service.
If a device is found, it should be assigned to the current service. If a device cannot be found, ignore it and continue investigating the other services.
The method then iterates through each service request in the array . It changes the value of to −1 for each service request, indicating that no device has been allocated to the service yet. Next, the method iterates over the device capacities in the array . If a device has adequate capacity to satisfy the current service request, the algorithm determines whether it is the first device discovered with sufficient capacity or if its capacity is more than the current . If the device’s capacity is greater, the algorithm assigns to the present device’s ID.
Following the completion of the inner loop, the algorithm checks if a device has been allocated to the current service requirement. If a device is allocated, the algorithm updates the list by distributing the current service requirement the value of . The algorithm also decreases the allocated device’s capacity by the magnitude of the service request. The aforementioned stages are repeated by the algorithm for all service requests. After the outer loop has been completed, the algorithm returns the list, which contains the list of allocated services to devices.
The worst fit algorithm allocates the services to devices to ensure that each service is allocated to the fog device with the most available capacity, maximizing resource consumption in a multi-device scenario.
Algorithm 2 Worst Fit |
Input: [],
[] Output: [] for
to
do for to do if then if then else if then end if end if end for if then end if end for |
4.1.3. First Fit
To maximize device utilization while allocating services to devices based on their capabilities, we present the first fit code in Algorithm 3. We need service requirements
and device capabilities
as input. After that, we select a service and determine whether it is compatible with the current device. If the
is equal to the
, we assign it and proceed to the next
. If not, we move on to investigate the next
.
Algorithm 3 First Fit |
Input: ,
Output: [] for
to
do for to do if then break end if end for end for |
In other words, the method has two inputs: (device capabilities), (service needs); and one output: (allocated IDs). The algorithm’s purpose is to allocate services in to devices in and record the allocation in .
The algorithm begins with two nested for-loops, where x is the length of and y is the length of . The method examines whether is larger than or equal to in every iteration of the inner loop. If the condition is met, the algorithm assigns the present service () to the current device () by changing to y and lowering the current device’s capacity by the service requirement (). Finally, the algorithm exits the inner loop after locating a device capable of allocating the current service and proceeds to the following service in the outer loop. This operation is repeated by the algorithm until all services are assigned to devices.
4.1.4. Priority-Based Service Allocation
We present the code for the priority-based allocation in Algorithm 4 to select the service allocation process and if the services should be handled in the fog or cloud. We need service requirements
and device capabilities
as input. The services are then allocated to the fog devices using the
method. Following that, one of the algorithms presented previously will be executed. Following that, we will evaluate the capabilities of fog computing in order to allocate services. If no fog devices are available to handle the service, we assign it to cloud devices by calling and forwarding the remainder of the services to
.
Algorithm 4 Priority-Based Allocation |
Require: : list of available devices, : list of service requirements, : list of allocation IDs Ensure: 1: empty list 2: for each service request x in do 3: if priority of is high then 4: Allocate to fog devices with sufficient capacity 5: if then 6: Increment by 1 7: else 8: Append to 9: end if 10: else if priority of is low then 11: Allocate to fog devices with sufficient capacity 12: if then 13: Increment by 1 14: else 15: if there is sufficient capacity in fog devices then 16: Allocate to a fog device 17: else 18: Append to 19: end if 20: end if 21: end if 22: end for 23: if is full then 24: Allocate remaining services to cloud devices 25: end if |
Based on the importance of the service request, the algorithm decides whether to distribute services to fog or cloud devices. The algorithm prioritizes service requests by initially assigning them to the fog devices. The algorithm begins the process by determining the level of priority of the service demand. If the service is high-priority, the algorithm inputs the device capability and service requirement. If fog devices are capable of handling the services, they will be allocated to fog devices. If fog devices are unable to handle the low-priority service, the algorithm will allocate it to cloud devices instead.
The algorithm begins by allocating services to fog devices. To distribute services to fog devices, the algorithm employs one of three allocation algorithms: best fit Algorithm 1, worst fit method Algorithm 2, or first fit Algorithm 3. The method then iterates across the length of the service request using a for loop. In every iteration, the algorithm determines whether or not the service has already been assigned to a device by determining whether or not the is greater than −1. If the is not equal to −1, it is increased by one. By incrementing the in such cases, the algorithm ensures that each service request allocated to fog devices receives a unique identifier, preventing conflicts and ambiguity in the allocation process. If the is −1, the service request is saved in the list.
The algorithm checks if the list is empty at the end of the for-loop. If the list is empty, the algorithm has been completed and all services have been allocated to the devices. If the list is not empty, the method “cloudDevice” with the list as input is called. The “cloudDevice” function is in charge of distributing the remainder of services to cloud devices. The priority-based allocation mechanism routes service requests to either the fog or cloud layers based on their priority. The method assigns services to fog devices utilizing one of three allocation techniques: best fit, worst fit, or first fit, with the remaining services given to the cloud.
4.1.5. Sort-Based Service Allocation
We employed dual-pivot quicksort, an efficient sorting algorithm commonly used in computer science and data-processing applications, especially for sorting primitive data types such as int, double, and float. Dual-pivot quicksort, according to the authors’ findings [
47], is typically quicker and more effective than alternative quicksort algorithms, especially on big datasets. They point out that dual-pivot quicksort works effectively with both randomly ordered and partly sorted data, and that it has a minimal amount of comparisons and swaps.
Sorting may be a valuable technique in the context of fog computing for optimizing service allocation and lowering the level of complexity of service distribution for fog devices. Sorting the data prior to them reaching the fog devices makes it easier to deploy resources and maximize the network’s overall performance. We classify the technical needs of services in ascending order, from lowest to greatest, to assist service allocation techniques for fog devices. We also sort the capabilities of fog devices. This allows for faster and more efficient service allocation.
4.2. Architecture
Our architecture is organized into three major sections: a sensor layer, a fog Layer, and a cloud layer. First, the sensor layer has IoMT sensors and IoMT devices that send data to the fog layer. Second, the fog layer is responsible for distributing services to devices in an effective and optimized manner by ensuring that all available resources are utilized and serving users by offering accessible services. Last, the cloud layer can manage all of the data and services, as well as provide essential services to the edge and fog layers.
The architecture shown in
Figure 2 incorporates three devices, including IoMT, fog, and cloud, as shown below:
The IoMT sensors and devices are situated in the sensor layer of the network system and are typically integrated into real-world objects. IoMT sensors are small and cost-effective, making the installation process straightforward and cost-efficient. These devices communicate with the fog devices using wireless communication. The IoT ecosystem should be beneficial in a variety of ways, including energy savings, lower costs, better resource use, and lower data transmission costs via the network. The IoMT sensors and devices generate data for each patient, which are then integrated into the service. This ensures that each service possesses data about the patient and their medical diagnosis. Then, after fusing all the data into services, the services will be sent to the fog layer. Additionally, this layer is responsible for sorting and prioritizing services, aiding the fog layer in allocating services to devices.
The fog devices reside adjacent to the sensor layer or within the communication channel and gather services and use a service allocation strategy to allocate the services to the fog devices as the priority is to process the services closer to the data source. However, whenever the fog devices cannot handle the services due to the lack of power of fog devices, then the services will be sent to the cloud using the proposed allocation strategy. Additionally, the fog devices are responsible for allocating services to either fog or cloud devices based on the priority of the service. Clearly, fog devices have very little power and a narrower global data perspective than cloud devices; thus, they can store less data and provide fewer services.
The cloud devices receive services from fog devices. The computational power and data storage capacity of the cloud are significantly greater than those of fog devices and IoMT devices. Cloud devices can be used for further analysis and storage when required to have the full picture of the data.
6. Results
In this section, we explore the outcomes of several techniques for allocating services to fog or cloud depending on priority, size, and algorithms employed. The outcomes of the allocation approach are shown here. As previously stated, the technique would first allocate services to fog nodes based on their capabilities and then assign services that could not be managed in the fog to cloud devices. We will examine and provide the findings of the three methods, namely worst fit, best fit, and first fit. According to Statista [
48], the average upload speed for transmitting services from fog to the cloud using mobile is 8.5 Mbps. However, the average upload speed using fixed broadband to transfer services from fog to the cloud is 28.5 Mbps.
To begin, we give two charts in
Figure 3 and
Figure 4 that illustrates the distribution of high and low-priority services to fog or cloud using various methodologies. Standard, priority, and sort are the strategies used in our experiments. The allocation is provided separately for high- and low-priority services. Second, in
Figure 5a,b, we provide a bar chart that indicates the number of unused fog devices in GB after assigning services to fog. Furthermore, the values in the table represent the amount of unused RAM in GB for each algorithm and each level of fog device configuration: low and medium. In the charts, we did not show the results of high level configuration of fog devices as all the services were handled in the fog. Then, in
Figure 6a,b, we show a chart and a table that provide information about allocating services to fog or cloud using three different strategies: standard, priority, and sort. The services are categorized as high- or low-priority, and their sizes are indicated in gigabytes (GB). Finally, we talk about the time it takes for services to travel from fog devices to the cloud, considering a variety of techniques.
The findings are reported in terms of the time required to assign services via mobile and broadband networks, and the time is determined based on the upload speed supplied by Statista [
48].
Figure 3 and
Figure 4 display the quantity of high- and low-priority services assigned to fog or cloud using various techniques, including standard, priority, and sort. The allocation is displayed separately for high-priority and low-priority services. “Standard” refers to a situation in which there is no differentiation between high- and low-priority services. Priority denotes a situation in which high-priority services take precedence over low-priority services. Sort denotes a scenario in which services are first sorted and then assigned using the best fit, worst fit, or first fit algorithm. According to the findings, the allocation approach has a substantial influence on the number of services provided to fog and cloud environments. In general, the priority method results in more high-priority services being assigned to the fog environment and more low-priority services being assigned to the cloud environment. When it comes to sorting services, the allocation approach has less of an influence on the number of services distributed to the fog and cloud environments. However, the allocation algorithm utilized does make a difference. For example, the worst fit algorithm allocates more services to the fog environment, but the first fit algorithm allocates more services to the cloud environment.
For each combination of distribution strategy and service priority, the chart illustrates the number of distributed high and low-priority services. The charts show that the number of high-priority services allocated to the fog is lower than that in the cloud for the standard strategy, while the converse is true for low-priority services. We did not include the results of high-capacity fog devices in the table since their exceptional capabilities allowed them to manage all services in the fog as mentioned earlier. It is clear from the charts that all algorithms are doing well in terms of allocating services to fog and cloud, but as our intention was to push the processing near the data source, a priority strategy can be a good choice. Among the three algorithms, we can realize that the best fit can be selected as the best in most cases.
Overall, our findings imply that a careful evaluation of allocation methods and algorithms could be useful in optimizing service allocation in fog and cloud situations. A priority approach, in particular, that prioritizes high-priority services, can help guarantee that important services are allocated to the fog environment, where they can be handled quickly and efficiently. Whereas the standard and sort strategies appear inefficient since they allocate services without regard for priority.
The number of distributed services (NDS) is calculated using the following equation: it is a metric for determining the proportion of services delivered or allocated to fog devices within a given configuration.
The resultant number represents the proportion of services that are effectively distributed or allocated to fog devices within the given configuration based on the specified strategy. A higher score indicates that more services have been successfully allocated. The results are presented in
Table 5 and
Table 6.
The bar charts in
Figure 5a,b illustrate the number of unused fog devices in GB after assigning services to fog. The values in the table indicate the quantity of unused RAM in GB for each algorithm and fog device configuration: low, medium, and high. Worst fit low: This allocation approach directs resources to the fog gadget that produces the most waste. According to the chart, this technique wastes 2 GB for devices with low capacity within the standard strategy. When priority is set, the wasted space is reduced to 1.5 GB. Worst fit medium: This allocation approach produces the largest waste among medium- and low-configuration devices. According to the charts, this technique wastes 7 GB for devices in standard and 6 GB with priority.
However, when medium-configuration devices are sorted, the strategy wastes 42 GB. Best fit: This allocation strategy allocates resources to the fog device with the least wastage. The table shows that this strategy results in 0 GB of wastage for devices in all strategies. First fit low: This allocation strategy allocates resources to the first available fog device. The table shows that this strategy results in 1.5 GB of wastage for devices with low capacity within the standard and 6 GB within the sort strategy, but 1 GB within the priority strategy. First fit medium: This allocation strategy allocates resources to the first available fog device among devices with medium capacity. The table shows that this strategy results in 2 GB of wastage for devices within the standard and 1.5 GB of wastage when priority is given; however, the wastage increases to 6 GB when the sort strategy is used.
Overall, we did not reveal the high-config devices since there was no waste because the fog devices had high capabilities, which allocated all services to the fog devices. Finally, the table shows that the Worst Fit strategy results in the most waste for both low- and medium-capacity devices, especially when the sort is provided. In all circumstances, the best fit technique results in the least amount of waste. The first fit approach stands somewhere between the other two.
The charts in
Figure 6a,b show the RAM size of services allocated to fog or cloud based on three alternative strategies: standard, priority, and sort. The services are classified as high- or low-priority, and their volumes are measured in gigabytes (GB). The low-configuration devices have a total of 100 GB and the medium-configuration devices have a total of 330 GB, as mentioned earlier. This indicates that in each configuration of low, medium, and high experiments, there is a maximum size of RAM to handle services. For example, the worst fit low experiment allocated 98 GB of services to fog devices of that size out of 100 GB; the remaining 2 GB is the wastage discussed earlier. It is clear that the strategy used most of the fog devices’ RAM, but most of the services traveled to the cloud because of the limited capabilities of the fog devices. It is clear that the best fit low and medium strategies are the best among others in terms of the usage of fog devices and allocating all services that can fit the fog devices without wastage. In the low configuration, the sort strategy stands better than the standard strategy in worst fit and best fit, but worse in sort. In the medium configuration, the sort strategy has better results than the standard in all algorithms. Overall, the table provides valuable information about the allocation of services to the fog or cloud and highlights the importance of considering service size, algorithm, and strategy when making these allocation decisions.
Table 7 illustrates how long it takes for services to travel from fog devices to the cloud using various techniques. The algorithms employed were standard, priority, and sort. The findings are reported in terms of the amount of time required to distribute services using mobile and broadband networks. The data clearly show that the time required to distribute services to the cloud is often longer for the mobile network than for the broadband network. This is most likely due to the fact that the mobile network has more constraints and requirements for service distribution than the broadband network. In terms of the various algorithms utilized, we can observe that the best fit algorithm outperformed the others for both mobile and broadband networks. For the mobile network, the worst fit algorithm performed the worst, but it was comparable with the other methods for the broadband network. The first fit method performed effectively in the broadband network but not so well on the mobile network. It is clear that the high-configuration setup of fog devices had no cost over the network as all the services were handled locally. Overall, the table findings indicate that the best fit algorithm may be the most effective method for distributing services from the fog to the cloud. However, the particular method used may be determined by the network’s specific requirements and constraints.
The following equation illustrates the data communication reduction (DCR) in hours. Time_of_services_using_strategy is obtained from the
Figure 6a,b. The results of enhancement are presented in
Table 8. In addition, time of total services without strategy is obtained from
Table 9 and the data are used in the equation.
For example, the time it takes for services to travel between the fog and the cloud in worst fit low using mobile in standard strategy is 3 days, 7 h, and 45 min. This should be converted to hours, and when it is converted to hours, it will be 79.75 h out of 107 h in total. Then, this number will be used in the equation.
6.1. Total Services Allocated to the Cloud
In this experiment, we allocated all services to the cloud in order to compare our techniques against allocation without a strategy and to investigate architecture-based allocation.
Table 9 clearly shows that “No of Services” indicates 0 services out of a total of 800 services assigned to fog devices and 800 services out of 800 services assigned to cloud computing. In other words, the fog devices receive 0% of the allocated services, while the cloud devices receive 100% of the services. The column “Allocated Services in GB” in the table indicates that 0 services of 0 GB in size are allocated to the fog and 383 GB are allocated to the cloud devices. The time of service allocation is then represented as “Time of service allocation (mobile)”, which indicates that the amount of time it takes for a mobile network to allocate the services to fog is 0 due to no costs associated with local data communication. but it takes 4 days, 11 h, and 0 min to allocate the 383 GB of services from fog to cloud using the mobile network. However, “Time of service allocation (broadband)” means that the period of time it takes to allocate services from fog to the cloud using the fixed broadband network is 1 day, 1 h, and 40 min.
Table 10 shows the execution time of each algorithm in three strategies, namely standard, priority, and sort. The most effective strategy is the sort strategy; when compared to the standard and priority methods, the sort strategy consistently has shorter execution times. The sort strategy involves a sorting technique, which optimizes resource allocation and results in faster algorithm execution times. As a result, the sort strategy is the optimal method for reducing execution times and optimizing resource allocation efficiency. However, without any priority or sorting factors, the standard method often has longer execution durations than the other techniques. In terms of optimizing resource allocation efficiency, it lacks the benefits of priority levels and sorting approaches. As a result, the standard approach is the least effective in terms of execution times and resource allocation efficiency.
The priority strategy may outperform the standard strategy in terms of resource allocation efficiency. In terms of reducing execution times and optimizing resource allocation efficiency, the Sort method outperforms both the priority and sort strategies. In summary, the sort strategy is the optimal strategy in terms of execution time, since it reduces execution times. The standard method is considered the least favorable since it lacks the advantages of priority and sort, while the priority approach can occasionally give better resource allocation efficiency than the standard strategy.
We conducted three experiments using three methods, namely best fit, first fit, and worst fit. Based on the results, the worst fit results were lower than the best fit and first fit; it is clear that the data communication over the network is reduced with all strategies when compared to total service allocation to the cloud, and most of the services are allocated to the fog devices. Since reducing data transfer across the network was our primary goal, it fits with our proposed technique. Furthermore, the second aim was to use the priority aspect to allocate the services as much as possible to the fog devices, and based on the results, this aim was achieved, as 90% or more of the services were allocated to the fog devices.
We conducted a total of twenty-seven experiments using the best fit, first fit, and worst fit methodologies. According to the results, the worst fit and first fit results were lower than the best fit, indicating that data traffic via the network decreased with all methods when compared to the entire service allocation to the cloud, with the fog devices receiving the majority of the services. It fits with our proposed technique because reducing data transfer across the network was our primary goal. Furthermore, the second goal was to use the priority aspect to allocate as many high-priority services as possible to fog devices, and based on the results, this goal was achieved because 90% or more of the priority services were allocated.
We compared the performance of the algorithms, namely best fit, worst fit, and first fit, while allocating services to fog devices based on the variable capability of fog devices and variable service requirements. The focus was on the number of services allocated to fog, resource usage, and data communication over the network. The first fit algorithm allocates services to the first fog device that can handle them. It may, however, produce some wastage, lowering fog device usage. The use of fog devices was approximately 90%. The best fit algorithm allocates services to the smallest fog device that can handle them. This algorithm tries to reduce waste and maximize fog device use. The wastage was found to be the lowest. The use of fog devices in the priority strategy was 100%, and in other strategies, it was more than 90%. The worst fit algorithm allocates services to the largest available fog device that can handle them. However, this algorithm leads to increased wastage. The wastage was found to be the highest. Additionally, the fog device usage was better than the first fit, and better than the best fit in some of the experiments, but generally worse than the best fit. In terms of waste, the best fit algorithm outperformed the first fit and worst fit, attaining the lowest wastage. The worst fit algorithm generated the most wastage. As a result, the best fit algorithm is regarded as the most advantageous of the three for the variable capability of fog devices and variable services requirements scheme, since it reduces waste and maximizes fog device use. Based on our knowledge, the worst fit can lead to high wastage (fragmentation) and the best fit can be best in terms of wastage. However, in some cases, the worst fit can increase the usage of resources [
49].