Optimal Design of Hierarchical Cloud-Fog&Edge Computing Networks with Caching

This paper investigates the optimal design of a hierarchical cloud-fog&edge computing (FEC) network, which consists of three tiers, i.e., the cloud tier, the fog&edge tier, and the device tier. The device in the device tier processes its task via three computing modes, i.e., cache-assisted computing mode, cloud-assisted computing mode, and joint device-fog&edge computing mode. Specifically, the task corresponds to being completed via the content caching in the FEC tier, the computation offloading to the cloud tier, and the joint computing in the fog&edge and device tier, respectively. For such a system, an energy minimization problem is formulated by jointly optimizing the computing mode selection, the local computing ratio, the computation frequency, and the transmit power, while guaranteeing multiple system constraints, including the task completion deadline time, the achievable computation capability, and the achievable transmit power threshold. Since the problem is a mixed integer nonlinear programming problem, which is hard to solve with known standard methods, it is decomposed into three subproblems, and the optimal solution to each subproblem is derived. Then, an efficient optimal caching, cloud, and joint computing (CCJ) algorithm to solve the primary problem is proposed. Simulation results show that the system performance achieved by our proposed optimal design outperforms that achieved by the benchmark schemes. Moreover, the smaller the achievable transmit power threshold of the device, the more energy is saved. Besides, with the increment of the data size of the task, the lesser is the local computing ratio.


Background
With the rapid development of wireless communications technologies and the wide deployment of mass smart devices, a large number of emerging applications [1], such as artificial intelligence (AI) [2], augmented reality (AR) [3], and virtual reality (VR) [4], have been arising in Internet of Things (IoT) networks, which put forward higher requirements for computation capability and transmit power to the smart device in the IoT network [5]. As we all know, most smart devices usually have limited communication, computation, storage, and energy resources, which is a huge challenge to complete such computation-intensive and delay-sensitive applications [6][7][8][9][10].
To solve these problems, fog&edge computing (FEC) is regarded as a potential solution via providing computing service to smart devices on the edge of the network, which meets the requirements of the smart device for processing the computation-intensive and delay-sensitive tasks in real time [11][12][13]. The FEC has two advantages: (i) Compared with local computing by the device The main contributions of our work are summarized as follows. • A three-tier network framework is considered, and correspondingly, we propose three computing modes to process the computation task of the device, i.e., cache-assisted computing mode, cloud-assisted computing mode, and joint device-fog&edge computing mode. Specifically, the task corresponds to being completed via the content caching in the FEC tier, the computation offloading to the cloud tier, and the joint computing in the fog&edge and device tier, respectively. • For such a system, an energy minimization problem is formulated by jointly optimizing the computing mode selection, the local computing ratio, the computation frequency, and the transmit power, while guaranteeing multiple system constraints, including the task completion deadline time, the achievable computation capability, and the achievable transmit power threshold.

•
Since the problem is a mixed integer nonlinear programming problem, which is hard to solve with known standard methods, it is decomposed into three subproblems, and the optimal solution to each subproblem is derived. Then, an efficient optimal caching, cloud, and joint computing (CCJ) algorithm to solve the primary problem is proposed.

•
Simulation results show that the system performance achieved by our proposed optimal design outperforms that achieved by the benchmark schemes. Moreover, the smaller the achievable transmit power threshold of the device, the more energy is saved. Besides, with the increment of the data size of the task, the lesser is the local computing ratio.
The rest of this paper is organized as follows. Section 2 describes the system model, and the optimization problem is formulated. In Section 3, the closed-form and semi-closed-form solutions to the three subproblems are derived, and an efficient algorithm, i.e., the CCJ algorithm, is presented. Section 4 provides some simulation results, and finally, Section 5 summarizes this paper.

System Model
Consider a hierarchical cloud-FEC network as shown in Figure 1, which consists of three tiers, i.e., the cloud tier, the fog&edge tier, and the device tier. Specifically, in the device tier, the smart device generates K different computation tasks, which follow the uniform distribution of K, where K denotes the set of task types with K {1, ..., K}. Each task is computed locally or offloaded. In the FEC tier, the FEC server is deployed at the base station (BS), which has the content caching and the computation capability to process the offloaded tasks. Besides, the BS is connected to the cloud server in the cloud tier via optical fiber. For any task k, for example, face recognition is a typical application scenario, which usually consists of five main computing components, including image acquisition, face detection, preprocessing, feature extraction, and classification. Image acquisition components can be executed on devices to support the user interface, but other complex computing components, such as signal processing and the machine learning (ML) algorithm, can be offloaded to the fog&edge computing or cloud computing to execute. Some of the components are cached in the FEC server in advance, which could reduce computing delay and energy consumption of the device.
We define task k as τ k {a k , C k , d k , T max k }, where a k ∈ {0, 1} is the caching indicator. When a k = 1, it indicates that the kth task has been cached in the FEC tier, and when a k = 0, it indicates that the kth task has not been cached. C k is the number of central processing unit (CPU) cycles required for computing one bit of the kth task; d k is the data size of the kth task; and T max k is the completion deadline time of the kth task.
For the FEC tier, due to limited caching space, we assume that the FEC server only caches several of the most popular files. The popularity of the files follows a Zipf distribution. Therefore, the popularity of the kth task is described as: where µ is the shape parameter and is regarded as constant [44,45]. For our considered system, denote Z as the caching threshold according to the popularity. When z k ≥ Z, the kth task is cached; otherwise, the task is not cached. For each task, the transmit protocol is shown in Figure 2. When the task is cached, it is processed in the caching computing mode.  Figure 2. Illustration of the transmit protocol for a given time block.

Caching-Assisted Computing Mode
For the caching-assisted computing mode, the delay includes two parts. One is the task request time T req k , which is too small to be ignored. The other is the result feedback time T r k , which depends on the data size of the results. The delay of task k in the caching-assisted computing mode is given by: where δ is the data ratio of the results. |h| 2 , p FEC , f FEC , B, and σ 2 are the channel coefficient between the device and the FEC tier, the transmit power and the computing capability of the FEC server, and the system bandwidth and the noise power, respectively. The energy consumption of device for task k in the caching-assisted computing mode is given by: where p c is the circuit power of the device for waiting. When the task is not cached, it is processed in the joint device-fog&edge computing mode or the cloud-assisted computing mode. Furthermore, we define γ k ∈ {0, 1} as the uncached task execution decision, where γ k = 1 indicates that the cloud-assisted computing mode is selected; otherwise, the joint device-fog&edge computing mode is selected.

Cloud-Assisted Computing Mode
Consider a cloud tier with a strong enough computation capability, so the execute time in the cloud tier can be neglected. For the cloud-assisted computing mode, the delay includes three parts. One is the task transmission time between the device and the FEC tier T ts k . One is the task transmission time between the FEC tier and the cloud tier T d , which depends on the distance between the FEC tier and the cloud tier and is regarded as a constant in this work. The other one is the result feedback time T r k . Therefore, the total delay of task k is given by: Meanwhile, the energy consumption of the device for task k is given by: where p tx k is the transmit power of the device for task k.

Joint Device-Fog&Edge Computing Mode
For joint device-fog&edge computing mode, the device portions each task into two parts. One part executes by local computing. The other one executes by offloading to the FEC tier for computing.

•
Local execution According to most existing related works, to achieve minimal energy consumption, an identical CPU frequency should be adopted for each CPU cycle. Thus, we denote f loc k as the average computation frequency of the device for each bit of the kth task. Therefore, the execution time of task k is given by: where β k ∈ [0, 1] is the ratio of task k for local execution at the device and (1 − β k ) represents the offloading ratio of task k for FEC execution.
The energy consumption of the device for task k is given by: where κ is the effective switched capacitor depending on the chip architecture.
The FEC execution delay includes three parts. The first one is task offloading time T tx k . The last one is FEC execution time T FEC k . The other is the result feedback time T fd k . Thus, the delay of FEC execution for task k is given by: The energy consumption of the device in FEC execution for task k is given by: As a result, the total delay of task k in the joint device-fog&edge computing mode is: and the energy consumption of the device for task k in this mode is given by: Denote K 1 , K 2 , K 3 as the set in the caching-assisted computing, cloud-assisted computing, and joint device-fog&edge computing mode, respectively. |K 1 |, |K 2 |, and |K 3 | are the element number of K 1 , K 2 , and K 3 , respectively. Then, the average energy consumption of the device is given by:

Problem Formulation
Our goal is to minimize the average energy consumption of the device in the hierarchical cloud-FEC system. Mathematically, the average energy minimization problem is formulated as: .., f loc K ] T denote the local computing ratio, the computing mode selection, the transmit power, and the computation frequency of the device, respectively. f max and p max denote the maximal achievable computation frequency and transmit power of the device, respectively. Constraints (13a), (13b), and (13c) mean that the delay in the three computing modes cannot exceed the completion deadline time, respectively. Constraints (13d) and (13e) represent the computation capability constraint and transmit power of the device, respectively.

Optimal Solution Approach
In this section, in order to solve Problem P 0 , we shall first decompose it into three subproblems. Then, by respectively solving them, the optimal solution to Problem P 0 is derived.

Optimization of the Caching-Assisted Computing Mode
As mentioned above, when z i ≥ Z, i ∈ K 1 and the caching-assisted computing mode is employed. In this mode, the optimal energy consumption is: Proposition 1. When p FEC has its maximal achievable threshold, E cache i achieves the optimal value.
Proof of Proposition 1. The larger p FEC is, the smaller T r i is, and the smaller E cache i is. Therefore, when p FEC is with its maximal achievable threshold, the energy consumption of the device reaches its minimum value. Therefore, the optimal E cache i can be obtained. Thus, Proposition 1 is proven.

Optimization of the Cloud-Assisted Computing Mode
When z j < Z and γ j = 1, j ∈ K 2 and the cloud-assisted computing mode is employed. In this mode, the optimal problem is expressed as: By expanding the expressions of the variables of Problem P 1 , it is equivalently rewritten as: ). The second order derivative of f (p tx j ) is always larger than zero, so the objective function of Problem P 1_A is convex. The first constraint is rewritten as g(p tx j ) ≤ 0, i.e., and its second order derivative is also always larger than zero. Therefore, the first constraint is also convex. Therefore, Problem P 1_A is a convex optimization problem. Lemma 1 is proven.
With Lemma 1 and the derivative of g(p tx j ) = 0, the optimal solution to Problem P 1_A is that

Optimization of the Joint Device-Fog&Edge Computing Mode
When z k < Z and γ k = 0, k ∈ K 3 and the joint device-fog&edge computing mode is employed. The optimization problem can be expressed as: We design an alternating iteration method to solve Problem P 2 . Firstly, we fix β k , and the primal Problem P 2 becomes a sub-problem in terms of p tx k and f loc k . Then, we substitute the optimal values of p tx k and f loc k into Problem P 2 , and Problem P 2 is reformulated as a subproblem in terms of β k . Hence, Problem P 2 is divided into two sub-problems as follows, i.e., Problem P 3 w.r.t. the transmit power p tx k and computation frequency f loc k and Problem P 4 w.r.t. the local computing ratio β k . Let β (0) k be the feasible point to Problem P 2 . Problem P 2 is re-expressed as: To solve Problem P 3 , we expand the expressions of the variables of Problem P 3 to be: Problem P 3_A is a convex optimization problem.
Proof of Lemma 2. Let the objective function as β ). The second order derivatives of h 1 ( f loc k ) and h 2 (p tx k ) are respectively given by: which means that the objective function is convex. The first constraint is re-written as β The second order derivatives of h 3 ( f loc k ) and h 4 (p tx k ) are respectively derived as: Therefore, the constraint is also convex. Lemma 2 is proven.
Lemma 2 indicates that Problem P 3 is a joint convex optimization problem w.r.t. f loc k and p tx k , which can be solved by using some standard convex optimization tools, such as CVX. According to Proposition 1, when p FEC = p max and f FEC = f max , the optimal E joint k can be achieved.
By substituting the optimal solution of f loc k and p tx k into Problem P 3 to get E loc(0) k and E off(0) k , we have: Since the objective function of Problem P 4 is linear w.r.t. β k , it is solved by several well-studied method.
: Calculate E ave according to (13); With the closed-form or well-structured solutions to the cloud-assisted computing mode and the joint device-fog&edge computing mode in Sections 3.2 and 3.3, the minimal energy consumption (i.e., E cloud j and E joint k ) can be calculated. Therefore, for uncached task k, ∀k ∈ K 2 , K 3 , the computing mode selection can be determined by: In order to show our proposed algorithm clearly, i.e, the optimal caching, cloud, and joint computing (CCJ) algorithm, we summarize it as shown in Algorithm 1. It is able to converge to the global optimal solution with low computational complexity.

Simulation Setup
In this section, we present some numerical results to discuss the performance of the hierarchical cloud-FEC system. We considered a centralized FEC network covered by a 200 m × 200 m area, where the BS was connected to the cloud server via optical fiber. In the device tier, the number of tasks requested by the device was K = 10. The input data size of the task was randomly distributed within [100, 1000] MB, and the data ratio of the result δ was 0.1. The corresponding number of required CPU cycles was distributed within [0.2, 1] G-cycles. The maximum achievable transmit power of the device was set as p max = 0.1 W. The circuit power of the device was p c = 0.01 W. In the FEC tier, the maximum achievable transmit power and computation capability of the FEC server was p FEC = 1 W and f FEC = 5 G-cycles, respectively. In the cloud tier, since the calculation delay in the cloud server was ignored, we set T d = 0.2 s, which was the transmission delay regarding the distance between the FEC tier and the cloud tier. In terms of communication, the system bandwidth was set as B = 3 MHz, and the white Gaussian noise was set to be σ 2 = 10 −8 W [29]. In addition, the channel gain was modeled by h = 127 + 30 × log d with independent Rayleigh fading, where d is the distance between the device and the FEC server. According to the realistic measurements in [46], we set the effective switched capacitor κ = 10 −26 . In the caching policy, we set the shape parameter µ = 0.56 and the caching threshold Z = 0.16. In this paper, all experiments were implemented in MathWorks MATLAB R2016b on a laptop equipped with a 12.00 GHz Corei5-3337U CPU and 128 GB random access memory. Every point in the figures was the result averaged over 10 4 independent channel realizations.
We compared our proposed algorithm with three different benchmark schemes as follows: • No caching (NC) scheme: This scheme supposed that the FEC system did not have a cache function. Therefore, the task could only be executed through cloud computing mode or joint computing mode.

•
Caching and joint execution (CJE) scheme: This scheme used our proposed cache policy. For the uncached task, it could be processed by the joint computing mode, that is γ = 0. • Caching and cloud execution (CCE) scheme: This scheme used our proposed cache policy. For the uncached task, it could be processed by the cloud computing mode, that is γ = 1. Figure 3 compares the average energy consumption versus different caching popularity thresholds. It is seen that with the increment of Z, the average energy consumption of the device increased. The reason is that the larger the Z, the more the task was cached and processed in the FEC tier. The energy consumption was mainly caused by the circuit consumption of the device during waiting for the FEC server to execute the task and return the results to the device.   Figure 4 shows the average energy consumption versus different maximal achievable transmit powers of the device. It is seen that with p max increasing, the average energy consumption of the device decreased and finally tended to be stable. The reason was that the higher the transmit power of the device, the faster the transmission rate, and the less the transmission time, the lower the energy consumption of the device. When p max was relatively small, the optimal solution of the transmit power was on the boundary, i.e., p max . When p max reached a certain value, the optimal solution of the transmit power shall not change.  Figure 5 compares the average energy consumption versus different system bandwidths. It is seen that with the bandwidth increasing, the average energy consumption decreased. The reason may be that the larger the system bandwidth, the larger the transmission rate, which resulted in less delay and lower energy consumption. The system bandwidth, B(MHz)   Figure 6 compares the average energy consumption versus different task data sizes. It is seen that with the data size increasing, the average energy consumption increased. The reason may be that the larger the data size of the task, the larger the transmission delay and the calculation delay, which led to the greater energy consumption of the device.  Figure 7 compares the local computing ratio versus different task data sizes. It is seen that with the increment of the data size of the task, the local computing ratio decreased. The reason was that when the data size of the task was small, it was computed locally with less energy consumption compared with offloading. When the data size of the task was large, the computation capacity of the device was not enough to support the calculation, and more parts of the task should be offloaded to the FEC tier for computing.

Conclusions
This paper studied the optimal design of a hierarchical cloud-FEC network with caching. For such a system, an energy minimization problem was formulated by jointly optimizing the computing mode selection, the local computing ratio, the computation frequency, and the transmit power of the device, while guaranteeing multiple system constraints, including the task completion deadline time, the achievable computation capability, and the achievable transmit power threshold of the device.Since the problem was a mixed integer nonlinear programming problem, which was hard to solve, it was decomposed into three subproblems, and the optimal solution for each subproblem was derived. Then, an efficient CCJ algorithm to solve the primary problem was designed. Simulation results showed that the system performance achieved by our proposed optimal design outperformed that achieved by the benchmark schemes. Specifically, compared with the NC scheme, the energy consumption reduced by our proposed optimal design by about 56%. Compared with the CJE scheme, the energy consumption reduced by our proposed optimal design by about 44%. Compared with the CCE scheme, the energy consumption reduced by our proposed optimal design by about 5%. Moreover, the smaller the achievable transmit power threshold of the device, the more energy was saved. Besides, with the increment of the data size of the task, the lesser was the local computing ratio.
Author Contributions: X.F. and H.Z. had an equal contribution to this work on the system modeling and methodology; R.J. and J.Z. contributed to the review and editing. All authors have read and agreed to the published version of the manuscript.