## 3 Efficient Caching Rate-Control for Edge Computing
### Rate-Control Using a Modified PID Controller
For example, if an app is consuming a small amount of data, and EDCrammer sends more data than it needs, the SDC could become saturated when it should handle the rest of the data. Thus, sending data about the cache capacity could be problematic. Therefore, EDCrammer limits the data using \(u(n)\leq CACHE\_MAX\), as shown in Equation (5). The pseudo-code for this is shown in Algorithm 1. In summary, Algorithm 1 controls the caching rate by computing the amount of data sent to the edge node. In addition, data are not sent for rate-control when data consumption is very low. EDCrammer controls the data transmission rate by using the \(0<u(n)\) in Equation (5). The pseudo-code for this is shown in Algorithm 2. In summary, Algorithm 2 controls the caching rate by making a decision between sending data and sending rate-control bit based on the result of Algorithm 1. \[|u(n)-u(n-1)|>K_{d}\times r(n)\times\alpha \tag{3}\]\[sign(e(n))==sign(u(n-1))\ AND\ isReachedToLimit(u(n-1)) \tag{4}\] \[0<u(n)\leq CACHE\_MAX \tag{5}\]  
```
Input :Current cache utilization from the edge node Output:The amount of calculated and regulated data for caching (u(t) or u(t-1))
1 kP = 0.7, kl = 0.5, kD = 0.7
2 deltaCounter = counter - lastCounter lastOutput = output
3
4 error = setpoint - feedback termP = error
5
6 ifsignOfLastOutput == signOfError AND isReachedToLimitthen
7 ifterml < - overshootingGuard then
8 terml = overshootingGuard
9 ifterml > overshootingGuard then
10 terml = overshooingGuard
11 else
12 terml += error
13
14 end
15
16 deltaError = error - lastError termD = deltaError/deltaCounter
17
18 output = kP * termP + kl * terml + kD * termD
19
20 ifabs(output - lastOutput) > setpoint * kD/100 then
21 lastError = error
22 lastCounter = counter
23
24 else
25 output = lastOutput
26
27
28 end
29 signOfLastOutput = sign(output)
30 ifoutput < outputMinthen
31 output = outputMin
32 ifoutput > outputMaxthen
33 output = outputMax
34
35 ifoutput == outputMin OR output == outputMaxthen
36 isReachedToLimit = True
37 else
38 isReachedToLimit = False
39
40 end
41 returnoutput
```  
**Algorithm 1**compute() algorithm of EDCrammer to control caching rate for data amount. Figure 5: An advanced PID controller. In EDCrammer, which has the advanced PID controller, data caching is performed mainly to enhance performance and meet the required QoS. Data are stored in the SDC, and the cloud service hits the data. In other respects, data production and consumption occur around the SDC, as shown in Figure 6. As data consumption increases, data production could increase, and vice versa. Therefore, to achieve efficient rate-control, an appropriate method is needed to store data in the SDC. Accordingly, the SDC has three data states: (1) stored; (2) hit; and (3) discarded. Figure 6 shows a data life cycle on the SDC. In the data production state, data are stored in the SDC. In the data consumption state, a cloud service hits the data, and then data are discarded. However, because the data could be reused, they are not discarded immediately. It is important to control the rate between data production and consumption. Put another way, it is important that rate-control be performed efficiently between the cloud node and the edge node. EDCrammer is an efficient rate-control algorithm that provides lightweight, agile caching.