Web Multi-Level Cache Replacement Method Based on Spectral Clustering
By introducing a multi-level cache replacement method based on spectral clustering into the cache replacement algorithm, the problem of insufficient prediction of user access mode and interest model in the prior art is solved, and more efficient cache management and computing performance improvement is achieved.
Patent Information
- Application Number
- CN202210048388.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-17
- Publication Date
- 2025-06-10
- Estimated Expiration
- 2042-01-17
AI Technical Summary
The existing cache replacement algorithms have shortcomings in predicting user access patterns, interest models and links, and complex models are computationally expensive during clustering operations, which cannot meet the efficiency needs of the Web server.
The Web multi-level cache replacement method based on spectral clustering is adopted, and the Web log data is processed and feature extracted through the prediction module on the proxy server, the cache value prediction is used to predict the cache value, and the storage location of the cache object is determined based on the predicted value, so as to achieve efficient management of the multi-level cache space.
This method can more accurately evaluate the cache value of resources, improve the reliability of cache replacement policies, reduce the computational amount of cache operations, and meet the efficiency needs of Web servers.
Smart Images

Figure CN114398573B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of cache replacement. More specifically, the present invention relates to a Web multi-level cache replacement method based on spectral clustering. Background Art
[0002] Currently, cache replacement algorithms are mainly divided into two categories: one is the method based on feature statistics, and the other is the method based on intelligent prediction algorithms.
[0003] The methods based on feature statistics include algorithms such as Least Frequently Used (LFU), Least Recently Used (LRU), and Greedy Dual Size Frequency (GDSF). Both LRU and LFU only consider using one of the features to replace the cache, and the accuracy is not high. While GDSF considers factors such as the locality, size, latency, replacement cost, and frequency of the object, and after comprehensive consideration, it selects the object with the smallest weight for replacement. These traditional methods focus on the user's access history and lack the prediction function for the user's access requests.
[0004] The methods based on intelligent prediction algorithms refer to scholars using machine learning models to predict the objects that will be accessed again, and setting replacement strategies accordingly. Some researchers predict whether a cache object is likely to be accessed again by training a Support Vector Machine (SVM) classifier, and delete the cache objects classified as not being accessed again to free up space. Some researchers use an Artificial Neural Network (ANN) to propose an adaptive method to predict the future access of web pages, but intelligent algorithms such as ANN are complex in nature and have a large amount of computation when making cache replacement decisions, taking a long time.
[0005] Defects of the prior art:
[0006] (1) It only predicts the probability of the next access of simple Web objects, lacking the prediction of the user's access pattern, the user's interest model, and the links.
[0007] (2) Complex models such as neural networks take a long time when performing clustering operations for prediction, which does not meet the high-efficiency requirements of Web servers. Summary of the Invention
[0008] An object of the present invention is to solve at least the above problems and / or defects, and provide at least the advantages described later.
[0009] To achieve these objects and other advantages according to the present invention, a Web multi-level cache replacement method based on spectral clustering is provided, including:
[0010] Step 1, a prediction module on the proxy server processes the Web log data and extracts features to obtain a corresponding set of feature attributes;
[0011] Step 2, the set of feature attributes obtained in Step 1 is sent into the spectral clustering model of the prediction module for cache value prediction to obtain corresponding predicted values;
[0012] Step 3, the cache replacement module in the proxy server starts the cache replacement mode, makes a judgment based on the predicted values obtained in Step 2 to determine the cache space of the cache object, and determines the storage location of the cache object based on the cache replacement policy;
[0013] Among them, the cache space is divided into at least two levels of cache space, and when the storage space of each space is insufficient, the storage location is determined by the way of circularly removing the last element of the queue to the lower-level cache space.
[0014] Preferably, in Step 1, it further includes:
[0015] S10, adding the resource request sent by the user from the client to the log file of the proxy server;
[0016] S11, the proxy server makes a preliminary judgment on the resource request of the user to determine whether there is a cache resource corresponding to the resource request in the cache space of the proxy server. If so, it returns to the user client, otherwise it enters Step 2;
[0017] Among them, the data processing and feature extraction of the Web log data are based on the resource request and operate in combination with the local log file to obtain a set of feature attributes <X 1 , X 2 , X 3 , X 4 , X 5 , X 6 , X 7 > that is related to the size of the requested resource and the frequency of occurrence in the log file and has a unified format;
[0018] Among them, X 1 is the address of the requested resource, X 2 is the time when the client request arrives at the proxy server, X 3 is the size of the requested resource, X 4 is the time interval since the last access of the Web object, and the initial value is -1, X 5 is the access frequency of the Web object, and the initial value is 0, X6 is the time interval within the sliding window since the last access, X 7 is the access frequency within the sliding window.
[0019] Preferably, in step one, the data processing and feature extraction are to perform attribute filtering and feature extraction on the request cache object based on the sliding window mechanism;
[0020] The sliding window is related to the feature attribute X 6 and X 7 and the calculation formula is as follows:
[0021]
[0022] x 7 = max[x 7 + 1, 1], ΔT ≤ SWL;
[0023] Where: SWL is the length of the cyclic sliding window, and ΔT is the time interval since the last request for the Web object.
[0024] Preferably, in step two, the prediction module includes a feature set array and two spectral clustering arrays;
[0025] Among them, the feature set array is the features of all requested resource objects;
[0026] The two spectral clustering arrays are respectively the frequency spectral clustering array related to the frequency feature and the time interval spectral clustering array related to the time interval;
[0027] Each spectral clustering array includes a frozen part and an active part, and the frozen part is configured as the feature set of the requested resources collected when the proxy server is just started, and the active part is the latest several requested resource feature sets taken from the feature set array.
[0028] Preferably, in step two, the prediction process of the prediction module is configured to include:
[0029] S20, perform initialization operations on the feature set array, the frequency spectral clustering array, and the time interval spectral clustering array;
[0030] S21, if the size of the requested resource object is greater than the cache upper limit, directly return the resource cache value will = 0, otherwise put the object features of the requested resource into the feature set array, and if the length of the feature set array is less than the threshold for starting clustering, return will = 0;
[0031] S22, check the feature set array to determine whether it reaches the length for generating the frozen part, and if so, generate the frozen part of the frequency clustering and the frozen part of the time interval clustering;
[0032] S23, when the length of the feature set array is sufficient to start clustering, extract from the end of the feature set array to generate an active part of the frequency clustering and an active part of the time interval clustering;
[0033] S24, splicing the frozen part and the active part of the frequency clustering to form a complete frequency clustering array, and performing a spectral clustering operation on the array; splicing the frozen part and the active part of the time interval clustering to form a complete time interval clustering array, and performing a spectral clustering operation on the array;
[0034] S25, performing an XOR operation on the first digit and the last digit in the frequency spectrum clustering result, and obtaining an XOR value which is a first prediction value related to the frequency feature; performing an XOR operation on the first digit and the last digit in the time interval spectrum clustering result, and obtaining an XOR value which is a second prediction value related to the time interval;
[0035] S26, obtaining a third prediction value of will=1 or will=0 by performing an AND operation on the first prediction value and the second prediction value.
[0036] Preferably, the cache space is divided into a first-level cache space and a second-level cache space, and the space occupancy ratio between the first-level cache space and the second-level cache space is 80% and 20%;
[0037] In step 3, the cache replacement module determines the third prediction value. If the third prediction value is 1, the requested resource is reserved to be stored in the first position of the first-level cache space. If the third prediction value is 0, the requested resource is reserved to be stored in the first position of the second-level cache space.
[0038] Before storing, it is necessary to determine whether the requested resource exists in the corresponding cache space. If so, the cache object is returned; otherwise, the cache replacement strategy is called for caching.
[0039] Preferably, in step 3, the process of caching using the cache replacement strategy is configured to include:
[0040] S30, if the requested object does not exist in the cache spaces at all levels, and the third prediction value is equal to 1, the capacity of the first-level cache space is detected, and if the capacity is sufficient, the requested object is placed in the first-level cache space, otherwise, the elements at the end of the first-level cache queue are cyclically removed to the second-level cache queue until there is enough capacity to place the object;
[0041] If the requested object does not exist in any level of cache space, and the third prediction value is equal to 0, the capacity of the secondary cache space is detected. If the capacity is sufficient, the requested object is stored in the secondary cache space, otherwise, the process proceeds to S31.
[0042] S31. When the secondary cache space is insufficient, first check whether there is available capacity in the primary cache space. If the request resource object can be temporarily placed in the primary cache, set the placeholder flag of the request resource object to 1 and temporarily place it at the end of the primary cache. If the capacity of the primary cache is not enough to borrow, loop to clear the elements at the end of the secondary cache queue until there is enough space, and then perform the corresponding placement operation.
[0043] Preferably, in S30, when placing the request object in the primary cache space, determine the resource size of the request object to determine whether to place the request object in the middle or the head of the primary cache space according to the determination result.
[0044] Preferably, in step three, when the request resource does not exist in the cache spaces at all levels, the cache replacement module sorts the request objects in the cache spaces at all levels according to the frequency within the sliding window, the global frequency, and the size-related characteristic attributes of the cache objects.
[0045] The present invention has at least the following beneficial effects:
[0046] (1) When designing the cache replacement strategy, not only a single characteristic attribute is referred to. Experiments prove that when comprehensively considering multiple characteristic attributes of the request object, the evaluation of the cache value of the resource will be more reliable.
[0047] (2) Since generally only some resources of the server have relatively high cache value, it is easy to form a sparse matrix and the attribute dimension is not high after statistically extracting the log attributes. Using spectral clustering is more effective for processing sparse matrices. It is more accurate in judging the possibility of future access to the request resource.
[0048] (3) The cache space is hierarchical. The hierarchical operation divides the storage location of the cache object more accurately. The resources in the primary cache will only fall into the secondary cache even if they are not accessed for a period of time and will not be directly cleared, reflecting their high-value characteristics. The resources in the secondary cache will be quickly rotated in and out, and have a high adaptability to the changing complex network environment.
[0049] Other advantages, objectives, and features of the present invention will be partially reflected by the following description and partially understood by those skilled in the art through the research and practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 It is a schematic diagram of the cache replacement process based on spectral clustering of the present invention;
[0051] Figure 2 It is a schematic diagram for comparing the HR values under different cache allocation ratios;
[0052] Figure 3Schematic diagram for comparing BHR values under different cache allocation ratios;
[0053] Figure 4 Schematic diagram for comparing HR values on dataset 1;
[0054] Figure 5 Schematic diagram for comparing BHR values on dataset 1;
[0055] Figure 6 Schematic diagram for comparing HR values on dataset 2;
[0056] Figure 7 Schematic diagram for comparing BHR values on dataset 2. Detailed implementation manner
[0057] The present invention will be further described in detail below with reference to the accompanying drawings so that those skilled in the art can implement it according to the description in the specification.
[0058] The present invention uses a cyclic sliding window mechanism to extract multiple temporal features and access attributes of log files, and performs clustering analysis on the filtered dataset through spectral clustering to obtain access prediction results; the cache replacement strategy comprehensively considers the local frequency, global frequency, and resource size of cache objects, can better eliminate low-value resources, and retain high-value resources at the same time.
[0059] The Web multi-level cache replacement method based on spectral clustering of the present invention has a cache framework divided into two parts, namely a prediction module and a replacement module, as Figure 1 shown. Among them, the prediction module includes feature extraction and application of spectral clustering; the replacement module includes management of a multi-level cache queue. When a user's resource request is sent from the client to the proxy server, the request is first added to the server's log file, and at the same time the proxy server checks whether it has cache resources for this request. If cache resources exist, the cache resources are directly returned to the client. If not, the prediction module extracts features from this request in combination with the local log file to obtain feature attributes such as the size of the requested resource and its frequency of occurrence in the log file; then the prediction model trained by spectral clustering is used to predict the cache value to obtain the predicted value of this resource. The predicted value represents the probability of a future re-request, and in this article, it is a binary classification result. Finally, the resource file requested from the source server will be sent to the replacement module for caching together with the predicted value. If the multi-level cache space is full, the multi-level cache management will call the FSMQ (Frequency and Size Multiple Queue) in this article to update the cache resources.
[0060] Specifically, it includes the following steps:
[0061] Step 1: The prediction module on the proxy server processes the Web log data and extracts features to obtain the corresponding feature attribute set;
[0062] Step 2: The feature attribute set obtained in Step 1 is sent into the spectral clustering model of the prediction module for cache value prediction to obtain the corresponding prediction value. The prediction result after clustering provides a reference basis for which cache level the requested resource should be placed in.
[0063] The principle of spectral clustering is as follows:
[0064] Construct the similarity matrix W of the samples according to the generation method of the input similarity matrix:
[0065]
[0066]
[0067] W is the similarity matrix composed of S in formula (1) ij
[0068] D is the n*n diagonal matrix composed of d in formula (2) i ;
[0069] Calculate the Laplacian matrix: L = D - W;
[0070] Calculate the eigenvalues of L, sort the eigenvalues from small to large, take the first k eigenvalues, and calculate the eigenvectors u 1 , u 2 , …, u k ;
[0071] Form the matrix U = {u 1 , u 2 , …, u k} with the above k column vectors, U ∈ R n*k ;
[0072] Let y i ∈ R K be the vector of the i-th row, where i = 1, 2, 3,.., n;
[0073] Use the clustering algorithm to cluster the new sample points into clusters C 1 , C 2 , …, C K ;
[0074] Output clusters A 1 , A 2 , …, A k , where A i = {j | y j ∈ C i}.
[0075] Step 3: The cache replacement module in the proxy server starts the cache replacement mode, makes a judgment based on the predicted value obtained in Step 2 to determine the cache space for the cache object, and determines the storage location of the cache object based on the cache replacement policy;
[0076] Among them, the cache space is divided into at least two levels of cache spaces, and when the storage space of each space is insufficient, the storage location is determined by the way of circularly removing the last element of the queue to the lower-level cache space.
[0077] Preferably, Step 1 further includes:
[0078] S10: Add the resource request sent by the user from the client to the log file of the proxy server;
[0079] S11: The proxy server makes a preliminary judgment on the user's resource request to determine whether there is a cache resource corresponding to the resource request in the cache space of the proxy server. If it exists, it returns to the user client; otherwise, it enters Step 2.
[0080] Among them, the data processing and feature extraction of the Web log data are based on the resource request and operate in combination with the local log file to obtain a feature attribute set <X 1 ,X 2 ,X 3 ,X 4 ,X 5 ,X 6 ,X 7 > that is related to the size of the requested resource and the frequency of occurrence in the log file and has a unified format;
[0081] Among them, X 1 is the requested resource address, X 2 is the time when the client request arrives at the proxy server, X 3 is the size of the requested resource, X 4 is the time interval since the last access of the Web object, and the initial value is -1, X 5 is the access frequency of the Web object, and the initial value is 0, X 6 is the time interval since the last access within the sliding window, X 7is the access frequency within the sliding window. In practical applications, the server's log file collects the request records of users over a period of time, which includes the host IP address, access time, URL, status code, size of the accessed resource, and so on. In addition to most records being normal, there are inevitably some abnormal records, such as invalid records with missing information or abnormal status codes. In addition, extremely high-frequency accesses from the same host within a very short time interval are also considered invalid. Therefore, before performing spectral clustering on the log data, we need to filter, clean, and extract features from the original data.
[0082] Considering that the data in the log file has a certain temporal correlation and time series, a sliding window mechanism is introduced to further extract features from the request records. After filtering, cleaning, and extracting features from each request record, a feature attribute set in a unified format will be formed.
[0083] In step one, the data processing and feature extraction are based on the sliding window mechanism to filter attributes and extract features from the request cache object;
[0084] X 4 has an initial value of -1, and X 5 has an initial value of 0. The sliding window is related to the feature attributes X 6 and X 7 and the calculation formula is as follows:
[0085]
[0086] x 7 = max[x 7 + 1, 1], ΔT ≤ SWL;
[0087] where: SWL is the length of the cyclic sliding window, and ΔT is the time interval since the last request for the Web object.
[0088] In step two, there is a feature set array and two spectral clustering arrays in the prediction module. The feature set array contains the features of all requested resource objects. The two spectral clustering arrays are the spectral clustering array of frequency features and the spectral clustering array of time intervals respectively. The spectral clustering array is denoted as S. Each spectral clustering array is composed of two parts, a frozen part and an active part, denoted as S1 and S2 respectively. Each part contains several requested resource features. Where S = S1 + S2.
[0089] (1) The frozen part is a feature set of requested resources collected when the proxy server is just started. The data in this part will not change, and its function is to identify the predicted value category of the user's latest resource request. Since the changes in the initially recorded resource features are not obvious, and it is reasonable to set the predicted value as not being accessed in the future. After all, at the initial moment, there is no access record for each requested resource in the log file. When the clustering result of the latest resource request is opposite to that of the frozen part, it indicates that this resource request will be accessed in the future according to the frequency or time interval, and it should be put into the first-level cache, and vice versa.
[0090] (2) The active part is the latest several feature sets of requested resources taken from the feature set array. The data in this part is different in each prediction, and the last requested resource feature is the latest resource request feature of the current user. The role of the active part is to make the clustering data contain diverse and up-to-date resource features, so that the clustering result is closer to the true value and more accurate.
[0091] From the spectral clustering operation of the frequency feature, we can obtain the predicted value regarding the frequency feature. From the spectral clustering operation of the time interval, we can obtain the predicted value regarding the time interval. Then, perform an AND operation on the two predicted values to obtain the final predicted value. If the final predicted value is 1, it indicates that the requested resource should be put into the first-level cache of the multi-level cache of the replacement module. If the final predicted value is 0, it should be put into the second-level cache.
[0092] In step two, the prediction process of the prediction module is configured to include:
[0093] Initialize the feature set array, the frequency clustering array, and the time interval clustering array. If the size of the requested resource object is greater than the cache upper limit, directly return the resource cache value will = 0; otherwise, first put the feature of the requested resource object into the feature set array. If the length of the feature set array is still less than the threshold for starting clustering at this time, while returning will = 0, check whether the length for generating the frozen part is reached. If it is reached, generate the frozen part of the frequency clustering array and the frozen part of the time interval. If the length of the feature set array can start clustering, extract from the end of the feature set array to generate the active part of the frequency clustering array and the active part of the time interval. Then, splice the frozen part and the active part of the frequency clustering to form a complete frequency clustering array, and perform spectral clustering on this array; similarly, form a complete time interval clustering array and also perform spectral clustering operation. Exclusive OR the first bit (the first bit of the frozen part) and the last bit (the target resource object) in the clustering result of the frequency to obtain the exclusive OR value, which represents the first predicted value of the frequency feature; similarly, the second predicted value of the time interval can be obtained. Finally, perform an AND operation on the two to obtain the final third predicted value, that is, will = 1 or will = 0.
[0094] The cache space is divided into a first-level cache space and a second-level cache space, and the space occupancy ratio between the first-level cache space and the second-level cache space is 80% and 20%;
[0095] In step 3, the cache replacement module determines the third prediction value. If the third prediction value is 1, the requested resource is reserved to be stored in the first position of the first-level cache space. If the third prediction value is 0, the requested resource is reserved to be stored in the first position of the second-level cache space.
[0096] Among them, before storage, it is necessary to determine whether the requested resource exists in the corresponding cache space. If it exists, the cache object is returned, otherwise the cache replacement strategy is called for caching. The replacement module manages a multi-level cache space, which is where the requested resources are stored. The multi-level cache space consists of two arrays, namely the first-level cache array and the second-level cache array. When the requested resource is not stored in the multi-level cache, it will be selectively placed according to the predicted value will provided by the prediction module; if it is stored in the multi-level cache, the cache resource that hits will be placed at the top of the array. Since each downgrade of the cache resource of the first-level cache or the removal of the cache resource of the second-level cache starts from the end of the array, this can keep the active cache resource that just hit in the cache space as much as possible.
[0097] When the requested resource is placed in the L2 cache and the L2 cache is full, and the L1 cache has excess capacity, this article will change the placeholder flag of the requested resource to temporary occupation, and then store it in the L1 cache. This allows the requested resource to be stored in the cache space without removing the L2 cache resources, increasing the cache hit area, and beneficially increasing the initial request hit rate and byte hit rate. This is also the placeholder flag method mentioned above. However, this method will put resources that do not belong to the L1 cache into the L1 cache, squeezing the space that originally belongs to the L1 cache request resources. Therefore, the replacement module will sort all cache resources in the L1 cache according to the placeholder flag at the end of each call to the cache replacement strategy to ensure that the temporarily occupied cache resources are kept at the end of the L1 cache, so that such temporarily occupied cache resources can be replaced first.
[0098] The replacement module divides the requested resources into large resources and small resources according to their sizes. This different division of resource sizes affects the position where the requested resources are placed in the cache array. If the requested resources are determined to be small resources, they will be placed at the beginning of the cache array; if they are determined to be large resources, they will be placed in the middle of the cache array. Doing so can, to a certain extent, quickly replace large resources, enabling more requested resources to be cached, improving the hit rate while reducing the cache cost of the proxy server. When the cached resources in the first-level cache need to be replaced, the cached resources are not directly cleared but downgraded from the first-level cache to the second-level cache for storage; when the cached resources in the second-level cache need to be replaced, the cached resources are directly removed from the second-level cache array, releasing some second-level cache space. This also shows that the cached resources in the first-level cache will be cached in the multi-level cache for a longer time. On the contrary, the cached resources in the second-level cache are updated and iterated at a relatively high frequency. This is why the requested resources with different cache values are placed in different cache spaces according to the prediction module.
[0099] In step three, the process of caching using the cache replacement strategy is configured to include:
[0100] Initialize the first-level cache array and the second-level cache array, and set the placeholder flag of the requested resource object to 0. First, check whether the request object exists in the first-level cache or the second-level cache. If it already exists in the cache, move the position of the cached object to the beginning of the cache array where it is located;
[0101] If it does not exist in the cache and the will value of the requested resource object is 1, check the remaining capacity of the first-level cache space. If the remaining capacity is sufficient, place it in different positions of the first-level cache according to its own resource size. If it is determined to be a large resource, it will be placed in the middle of the first-level cache; if it is a small resource, it will be placed at the beginning of the first-level cache. If the remaining capacity is not enough, the last element of the first-level cache will be cyclically moved to the second-level cache until there is enough space to place it, and then the above placement operation will be executed.
[0102] If it does not exist in the cache and the will value of the requested resource object is 0, check the remaining capacity of the second-level cache space. If the remaining capacity is sufficient, execute the above similar placement operation; if the remaining capacity of the second-level cache is not enough to place the requested resource object, first check whether there is capacity available in the first-level cache space. If the first-level cache can temporarily place the requested resource object, set the placeholder flag of the requested resource object to 1, and then temporarily place it in the first-level cache; if the capacity of the first-level cache is not enough to borrow, cyclically clear the last element of the second-level cache array until there is enough space, and then execute the above similar placement operation.
[0103] Finally, after the requested resource object is placed in the multi-level cache space in any way, the cache objects with the placeholder flag of 1 in the first-level cache array will be placed at the end of the first-level cache array to ensure that the temporarily occupied cache resources are preferentially replaced. In practical applications, when the resource request records in the log file are not enough, that is, the length of the feature set array does not reach the start threshold of the spectral clustering quantity, the final predicted value of each resource request by the prediction model directly returns 0 until the request quantity accumulates to the point where spectral clustering prediction can start. The consequence of this is that the second-level cache space in the replacement module will be quickly filled with requested resources. Subsequently, when resources are in the second-level cache, the cache replacement strategy will be used to remove old resources. At the same time, there is no cache resource in the first-level cache, which will greatly affect the request hit rate and byte hit rate in the initial stage. This problem is effectively solved by the placeholder flag method in the replacement strategy.
[0104] In step three, when the requested resource does not exist in the cache spaces at all levels, the cache replacement module sorts the request objects in the cache spaces at all levels according to the frequency within the sliding window, the global frequency, and the size-related characteristic attributes of the cache objects. That is, in this process, except for the hit elements, the active frequencies of all cache objects decrease. Then, the elements in the cache space are sorted in the order of first considering the size of the active frequency and then the size of the cache resource. This ensures that cache objects with low frequency and large occupied space will be preferentially removed. At the same time, the spectral clustering prediction objects are further retrained and updated, so as to be able to predict a more accurate will value.
[0105] Embodiment:
[0106] The method of the present invention includes the following:
[0107] (1) Web log data filtering and feature extraction
[0108] The loop sliding window mechanism is used to extract features from the request records. After filtering, cleaning, and feature extraction of each request record, a feature attribute set <X 1 , X 2 , X 3 , X 4 , X 5 , X 6 , X 7 > in a unified format will be formed.
[0109] (2) Spectral clustering model prediction
[0110] The processed feature set is put into the spectral clustering algorithm for clustering to obtain two clusters, and the predicted value will is obtained. It is stipulated that when will is 0, the request object is placed in the first-level cache space, and when the will value is 1, the request object is placed in the second-level cache space.
[0111] (3) Multi-level Cache Space Allocation
[0112] In order to explore how to allocate space in the multi-level cache to achieve the highest performance, on the premise that the cache space is set to 8M, the first-level cache and the second-level cache are set to 90% and 10% respectively for performance testing. After the test is completed, the first-level cache is reduced and the second-level cache is increased (the sum is 100%), and the test is carried out until the first-level cache is 10% and the second-level cache is 90%.
[0113] (4) Replacement Policy Research
[0114] The multi-level cache designed in this patent combines time and frequency attributes. After absorbing the respective advantages of LRU, LFU (time-frequency characteristics) and MQ (longer retention of high-value data), the FSMQ cache replacement policy mechanism in this article is designed.
[0115] The cache replacement policy mechanism includes: (1) Determine whether the size of the requested object is greater than the upper limit of the cache space capacity. If it is greater, directly obtain it from the source server and the cache hit fails.
[0116] (2) Use the sliding window mechanism to filter and extract the attributes of the requested object to form a feature attribute set <X 1 , X 2 , X 3 , X 4 , X 5 , X 6 , X 7 > in a unified format.
[0117] (3) Use the spectral clustering prediction object in FMSQ to determine the will value. will = 1 means that the resource object will be directly stored in the first-level cache, and will = 0 means that the resource object will be stored in the second-level cache.
[0118] (4) Determine whether the resource object hits in the multi-level cache. If it hits, return the cache object; otherwise, call the cache replacement policy for caching. If will = 1, when the first-level cache space is insufficient, the elements at the end of the first-level cache queue are cyclically removed to the second-level cache queue until there is enough capacity to put in; if will = 0, when the second-level cache space is insufficient, the elements at the end of the second-level cache queue are cyclically removed to release space until it can be put in.
[0119] (5) Except for the hit elements, the active frequency of all cache objects decreases. Then, the elements in the cache space are sorted in the order of first considering the active frequency size and then the cache resource size. Thus, it is ensured that the cache objects with low frequency and large occupied space will be removed first.
[0120] (6) The spectral clustering prediction object is retrained and updated, so as to predict a more accurate will value.
[0121] 1. Data Description
[0122] The experimental data is selected from a website log file on CSDN, and the size of the compressed file is 21.59 MB. Two log files record the historical records of user access at different times. Dataset 1 is the log file data from 17:38 to 24:00, with a total of 548,160 access records. Dataset 2 is the log file data from 24:00 of the current day to 24:00 of the next day, with a total of 1,400,629 access records. In this experiment, the spectral clustering analysis is used to request the record features, and the predicted values are given to assist the implementation of the cache storage of the multi-level cache replacement strategy mechanism in this paper. After comparing the performance with the common cache replacement strategies LRU, LFU, RC, and FIFO, it can be seen that the cache strategy of spectral clustering and multi-level cache proposed in this paper has good performance advantages.
[0123] 2. Experimental Environment
[0124] The experimental environment uses PaddlePaddle AI Studio under the Baidu platform, and its cloud computing power configuration is as follows:
[0125] GPU: Tesla V100 * 4
[0126] CPU: Intel Xeon * 32
[0127] RAM:: DDR4 128GB
[0128] 3. Experimental Settings
[0129] A copy of a log file is obtained on the proxy server. Each access record in it contains user ip, access time, requested resource path, resource size, status code, etc. In addition to removing the default or abnormal data, the sliding window mechanism is used to obtain the frequency and timestamp within the sliding window time, and finally seven filtered attributes are obtained: ip, timestamp, resource size, time interval, frequency, time interval within the sliding window, and frequency within the sliding window. At the same time, the space allocation ratio in the first-level cache and the second-level cache in the multi-level cache of FSMQ is set.
[0130] In order to explore how to allocate space in the multi-level cache to achieve the highest performance, on the premise that the cache space is set to 8M, the first-level cache and the second-level cache are set to 90% and 10% for performance testing. After the test is completed, the first-level cache is reduced and the second-level cache is increased (the sum is 100%), and the test is carried out until the first-level cache is 10% and the second-level cache is 90%. The test results are as Figure 2 and Figure 3As shown in the figure, it can be seen that different multi-level cache space settings have a certain impact on the performance of the FSMQ cache replacement policy. Among them, when the capacity of the first-level cache space accounts for 80% of the total cache space size, both the request hit rate and the byte hit rate of the cache replacement policy are the best. Therefore, the allocation of the multi-level cache space always adopts [0.8, 0.2], that is, the first-level cache accounts for 80% of the total space and the second-level space accounts for 20% to conduct subsequent comprehensive experiments.
[0131] 4. Performance Comparison
[0132] In the selection of different clustering algorithms, the present invention considers partial frequency, global frequency, and resource size on the basis of the multi-level queue MQ, and designs the FSMQ cache replacement policy. Taking the traditional cache replacement policies LRU, LFU, RC, and FIFO as control algorithms, experiments are carried out on different cache space sizes; the experimental results are as Figures 4 - 7 shown. Figures 4 - 5 shows the HR and BHR of 5 cache replacement policies on different cache space sizes for dataset 1, Figures 6 - 7 shows the HR and BHR of 5 cache replacement policies on different cache space sizes for dataset 2.
[0133] Specifically, as Figure 4 shown, in the case of dataset 1 and the first-level cache accounting for 80% of the total space and the second-level space accounting for 20%, when the cache capacity upper limit is from 2^6KB to 2^9KB, the difference in the request hit rate between FSMQ and LFU is not significant. Compared with the other 3 cache replacement policies, it is on average 2.55%, 4.6%, 5.49%, and 10.6% higher under the above different cache capacities. As the cache capacity continues to increase, the gap becomes more obvious. When the cache capacity upper limit is from 2^10KB to 2^14KB, FSMQ is respectively 7.69%, 9.49%, 5.06%, 6.58%, and 4.34% higher than LFU. On average, it is 6.632% higher.
[0134] As Figure 5 shown, in the case of dataset 1 and the first-level cache accounting for 80% of the total space and the second-level space accounting for 20%, when the cache capacity upper limit is from 2^6KB to 2^9KB, the difference in the byte hit rate between FSMQ and LFU is not significant. Compared with the other 3 cache replacement policies, it is on average 0.27%, 1.34%, 2.72%, and 6.43% higher under the above different cache capacities. As the cache capacity continues to increase, the gap becomes more obvious. When the cache capacity upper limit is from 2^10KB to 2^14KB, FSMQ is respectively 6.02%, 3.49%, 0.45%, 1.26%, and 2.4% higher than LFU. On average, it is 2.724% higher.
[0135] As Figure 6As shown, when the dataset is 2, the primary cache accounts for 80% of the total space, and the secondary cache accounts for 20%, and the cache capacity upper limit is from 2^6KB to 2^9KB, the difference in the request hit rates between FSMQ and LFU is not significant. Compared with the other three cache replacement policies, it is on average 1.62%, 4.57%, 6.3%, and 8.8% higher under the above different cache capacities. As the cache capacity continues to increase, the gap becomes more obvious. When the cache capacity upper limit is from 2^10KB to 2^14KB, FSMQ is respectively 4.56%, 7.03%, 4.81%, 6.85%, and 6.18% higher than LFU, with an average of 5.886% higher.
[0136] As Figure 7 shown, when the dataset is 2, the primary cache accounts for 80% of the total space, and the secondary cache accounts for 20%, and the cache capacity upper limit is from 2^6KB to 2^9KB, the difference in the byte hit rates between FSMQ and LFU is not significant. Compared with the other three cache replacement policies, it is on average 0.02%, 0.84%, 2.24%, and 5.38% higher under the above different cache capacities. As the cache capacity continues to increase, the gap becomes more obvious. When the cache capacity upper limit is from 2^10KB to 2^14KB, FSMQ is respectively 2.66%, 2.12%, 1.38%, 1.86%, and 2.61% higher than LFU.
[0137] With an average of 2.126% higher
[0138] The above solution is only an illustration of a preferred example, but is not limited thereto. When implementing the present invention, appropriate substitutions and / or modifications can be made according to the needs of users.
[0139] The number of devices and the processing scale described here are used to simplify the description of the present invention. The application, modification, and variation of the present invention are obvious to those skilled in the art.
[0140] Although the embodiments of the present invention have been disclosed above, it is not limited to the applications listed in the specification and embodiments. It can be fully applied to various fields suitable for the present invention. For those familiar with the field, additional modifications can be easily implemented. Therefore, without departing from the general concept defined by the claims and the equivalent scope, the present invention is not limited to the specific details and the illustrations shown and described here.
Claims
1. A Web multi-level cache replacement method based on spectral clustering, characterized in that, it includes: Step 1, a prediction module on the proxy server processes the Web log data and extracts features to obtain a corresponding feature attribute set; Step 2, the feature attribute set obtained in Step 1 is sent into the spectral clustering model of the prediction module for cache value prediction to obtain corresponding predicted values; Step 3, the cache replacement module in the proxy server starts the cache replacement mode, makes a judgment based on the predicted values obtained in Step 2 to determine the cache space of the cache object, and determines the storage location of the cache object based on the cache replacement policy; wherein, the cache space is divided into at least two levels of cache spaces, and when the storage space of each space is insufficient, the storage location is determined by the way of circularly removing the elements at the end of the queue to the lower-level cache space; In Step 1, it also includes: S10, adding the resource request sent by the user from the client to the log file of the proxy server; S11, the proxy server makes a preliminary judgment on the user's resource request to determine whether there is a cache resource corresponding to the resource request in the cache space of the proxy server. If so, it returns to the user client, otherwise it enters Step 2; Among them, the data processing and feature extraction of the Web log data are based on the resource request and operate in combination with the local log file to obtain a feature attribute set <X that is related to the size of the requested resource and the frequency of occurrence in the log file and has a unified format 1 , X 2 , X 3 , X 4 , X 5 , X 6 ,X 7 >; Among them, X 1 is the requested resource address, X 2 is the time when the client request arrives at the proxy server, X 3 is the size of the requested resource, X 4 is the time interval since the last access to the Web object, and the initial value is -1, X 5 is the access frequency of the Web object, and the initial value is 0, X 6 is the time interval since the last access within the sliding window, X 7 is the access frequency within the sliding window; In Step 1, the data processing and feature extraction are to filter the attributes and extract features of the requested cache object based on the sliding window mechanism; The sliding window and the feature attribute X 6 and X 7 are related, and the calculation formula is as follows: Wherein: SWL is the length of the cyclic sliding window, is the time interval since the last request for the Web object; In Step 2, the prediction module includes a feature set array and two spectral clustering arrays; wherein, the feature set array is the features of all requested resource objects; The two spectral clustering arrays are respectively a frequency spectral clustering array related to frequency features and a time interval spectral clustering array related to time intervals; Each spectral clustering array includes a frozen part and an active part, and the frozen part is configured as the feature set of the requested resources collected when the proxy server just starts, and the active part is the latest several requested resource feature sets taken from the feature set array; In Step 2, the prediction process of the prediction module is configured to include: S20, perform initialization operations on the feature set array, the frequency spectral clustering array, and the time interval spectral clustering array; S21, if the size of the requested resource object is greater than the cache upper limit, directly return the resource cache value will = 0, otherwise put the object features of the requested resource into the feature set array. If the length of the feature set array is less than the threshold for starting clustering, return will = 0; S22, check the feature set array to determine whether it reaches the length for generating the frozen part. If so, generate the frozen part of frequency clustering and the frozen part of time interval clustering; S23, when the length of the feature set array can start clustering, extract from the end of the feature set array to generate the active part of frequency clustering and the active part of time interval clustering; S24, splice the frozen part and the active part of frequency clustering to form a complete frequency clustering array, and perform spectral clustering operations on this array; splice the frozen part and the active part of time interval clustering to form a complete time interval clustering array, and perform spectral clustering operations on this array; S25, performing an XOR operation on the first digit and the last digit in the frequency spectrum clustering result, and obtaining an XOR value which is a first prediction value related to the frequency feature; performing an XOR operation on the first digit and the last digit in the time interval spectrum clustering result, and obtaining an XOR value which is a second prediction value related to the time interval; S26, obtaining a third prediction value of will=1 or will=0 by performing an AND operation on the first prediction value and the second prediction value.
2. The Web multi-level cache replacement method based on spectral clustering as claimed in claim 1, It is characterized in that The cache space is divided into a first-level cache space and a second-level cache space, and the space occupancy ratio between the first-level cache space and the second-level cache space is 80% and 20%; In step 3, the cache replacement module determines the third prediction value. If the third prediction value is 1, the requested resource is reserved to be stored in the first position of the first-level cache space. If the third prediction value is 0, the requested resource is reserved to be stored in the first position of the second-level cache space. Before storing, it is necessary to determine whether the requested resource exists in the corresponding cache space. If so, the cache object is returned; otherwise, the cache replacement strategy is called for caching.
3. The Web multi-level cache replacement method based on spectral clustering as claimed in claim 1, It is characterized in that In step 3, the process of caching using the cache replacement strategy is configured to include: S30, if the requested object does not exist in the cache spaces at all levels, and the third prediction value is equal to 1, the capacity of the first-level cache space is detected, and if the capacity is sufficient, the requested object is placed in the first-level cache space, otherwise, the elements at the end of the first-level cache queue are cyclically removed to the second-level cache queue until there is enough capacity to place the object; If the requested object does not exist in any level of cache space, and the third prediction value is equal to 0, the capacity of the secondary cache space is detected. If the capacity is sufficient, the requested object is stored in the secondary cache space, otherwise, the process proceeds to S31. S31, when the L2 cache space is insufficient, first check whether there is capacity in the L1 cache space that can be borrowed. If the L1 cache can temporarily place the requested resource object, then set the placeholder flag of the requested resource object to 1 and temporarily place it at the end of the L1 cache. If the L1 cache capacity is insufficient and cannot be borrowed, then clear the elements at the end of the L2 cache queue in a loop until there is enough space, and then perform the corresponding placement operation.
4. The Web multi-level cache replacement method based on spectral clustering as claimed in claim 3, It is characterized in that In S30, when placing the request object into the first-level cache space, the resource size of the request object is determined to determine whether to place the request object into the middle or the head of the first-level cache space according to the determination result.
5. The Web multi-level cache replacement method based on spectral clustering as claimed in claim 1, It is characterized in that In step three, when the requested resource does not exist in the cache space at each level, the cache replacement module prioritizes the requested object in the cache space at each level according to the frequency in the sliding window, the global frequency, and the size-related characteristic attributes of the cache object.