# Two-Layer Network Caching for Different Service Requirements
## 3 Model
### Caching Problems
#### 3.3.3 Case 3: Guaranteed Download Time
As for the Algorithm4, in addition to the bandwidth limitations, we consider the stochastic links between layer-1 and layer-2 caches. Note that all links have a probability of being active that is lower than the probability acceptance threshold. However, due to the introduction of virtual caches, which is central in Algorithm4, the caching system is turned from unavailable to available with an appreciable performance, although not at the same level of the other situations analyzed above. It is interesting to associate the observations of the performance shown in Figure 5 with the behavior shown in Figure 6. It shows the fraction of hits collected at the layer-1 caches vs. cache size. This figure confirms the compensating role of the layer-1 caches when the allocation in layer-2 caches is not optimal. For some situations, in particular for Algorithm3 and Algorithm4, this fraction is significant, and for both algorithms the effect of bandwidth limitations is even more evident. Notice that the evidence of this compensating effect is not only an interesting result per se, but makes the performance difference between the algorithms observed in Figure 5 even more evident. The asymptotic difference in Figure 6 between Algorithm1 and LFU is due to the first miss that happens in caches the first time an item is requested. The presence of multiple caches compensate this effect almost totally, since if a content is cached in a layer-2 cache, the first miss for that content does not happen for the other users that can access the cache for receiving the same content. Figure 5: Hit ratio, case 1, N = 2000. For what concerns the performance of the proposed algorithms when the content popularity is estimated, Figures 7 and 8 show the hit ratio for fixed content size. Popularity is estimated by using the LFU estimation procedure, based on a sliding window, for all algorithms. Note that our approach could be used in conjunction with other estimation algorithms, such as that one used for implementing the TinyLFU [19]. Hence, in the case of pre-allocation of contents, that is for Algorithm1, Algorithm3, and Algorithm4, the popularity values estimated by LFU during an estimation window are used, so that the comparison is fair. Figure 7, relevant to an estimation window of 2000 interarrival times, shows that the performance of Algorithm1 is lower than the theoretical one. The performance degradation is due to the use of estimated popularity values. Nevertheless, Algorithm1 still outperforms LFU. A slight performance degradation is observed also for Algorithm3 and Algorithm4. It is interesting to observe in Figure 8 that the performance degradation is present also in layer-1 caches. This effect can be explained with the coarse estimation of the popularity of less frequently requested items over an (almost) fixes window. These items are typically found in layer-1 queues. However, their contribution to the average hit ratio is quite limited, and the observed degradation is acceptable. If the estimation window increases to 10,000 inter-arrival times, in Figures 9 and 10 we can observe that the performance degradation is negligible. Algorithm1 still outperforms LFU, and in case of Algorithm3 and Algorithm4 the performance is mostly determined by bandwidth limitations and stochastic links than by estimated popularity values. Given the well assessed performance comparison between Algorithm1 and LFU, the following experiments, based on variable content size, will focus in Algorithm2, which is the extension of Algorithm1 for handling variable size, Algorithm3 and Algorithm4. Figure 6: Fraction of hits at 1 st layer caches, case 1, N = 2000. Figure 8: Fraction of hits at 1 st layer caches, case 2, N = 2000. Figure 7: Hit ratio, case 2, N = 2000. Figures 11 and 12 are relevant to an experiment with known content popularity and variable content size. The curve labelled as _theoretical_ shows the hit ratio computed by (2) by considering popularity only. Differently, the proposed algorithms make use of the density of popularity.