Disclosure of Invention
The embodiment of the application provides a cache management optimization method and system, which are used for solving the problems of low performance and efficiency of a cache management system in the prior art.
In a first aspect, an embodiment of the present application provides a method for optimizing cache management, including:
receiving a cache access request initiated by an application program, wherein the cache access request comprises identification information of data to be accessed;
based on the identification information, evaluating the access heat of the data to be accessed, and dynamically adjusting the position of the data to be accessed in a cache hierarchical structure by combining the current cache state and a preset cache strategy;
When the insufficient cache space is detected, predicting the access requirement in a future period of time according to the access mode of the data to be accessed, preferentially retaining the high-value data to be accessed, and selectively transferring the low-value data to be accessed to a low-level cache or storage device through an intelligent algorithm;
And continuously optimizing a caching strategy according to the historical access record and the real-time access condition, ensuring the efficient utilization of the caching resources and simultaneously reducing the access delay to the back-end storage system.
Optionally, the evaluating the access heat of the data to be accessed based on the identification information and dynamically adjusting the position of the data to be accessed in the cache hierarchy in combination with the current cache state and a preset cache policy includes:
acquiring corresponding cache entries according to the identification information, and collecting and analyzing historical access records of the data to be accessed from the cache entries, wherein the historical access records comprise indexes of access frequency, last access time and average access interval so as to evaluate the access heat of the data to be accessed;
and according to the access heat, determining the optimal position of the data to be accessed in the cache hierarchical structure by combining the state of the current cache hierarchical structure and a preset cache strategy.
Optionally, when the cache space is detected to be insufficient, predicting an access requirement in a future period of time according to an access mode of the data to be accessed, preferentially retaining the high-value data to be accessed, and selectively migrating the low-value data to be accessed to a lower-level cache or storage device through an intelligent algorithm, including:
monitoring the use state of the cache system in real time, and triggering a cache optimization process when the available cache space is found to be lower than a preset threshold value;
Based on the historical access record and the acquired real-time access condition, predicting the access requirement of the data to be accessed in a future period of time, and generating an access requirement prediction model;
Calculating the value score of the data to be accessed according to the prediction result of the access demand prediction model, wherein factors of high access frequency, short access interval and long duration can increase the value score of the data to be accessed;
Sorting all the data to be accessed according to the value scores, taking the data to be accessed with the value scores higher than a set threshold value as high-value data to be accessed, and reserving the high-value data to be accessed;
And taking the data to be accessed with the value score lower than the set threshold value as low-value data to be accessed, and selectively migrating the low-value data to be accessed into a low-level cache or storage device through an intelligent algorithm to release the high-level cache or storage device.
Optionally, the continuously optimizing the cache policy according to the history access record and the real-time access condition ensures efficient use of the cache resource while reducing access delay to the back-end storage system includes:
The effect of the current caching strategy is evaluated by combining the historical access record and the real-time access condition, and an evaluation result is obtained;
According to the evaluation result, a cache policy optimization model is established, and the cache policy optimization model can automatically generate optimization suggestions based on different application scenes and business requirements;
dynamically adjusting cache policy parameters according to the optimization suggestion of the optimized cache policy optimization model to generate an adjusted cache policy;
and deploying the adjusted caching strategy in the actual environment, and verifying the effect of the adjusted caching strategy to ensure efficient utilization of the caching resources and reduce access delay to the back-end storage system.
Optionally, the calculating the value score of the data to be accessed includes:
Calculating a value scoring formula V i of the data to be accessed:
Wherein V i represents the value score of the ith data to be accessed, F i is the access frequency of the ith data to be accessed, and θ is the index adjustment parameter of the access frequency; Representing a sinusoidal function for introducing nonlinear variation; an exponential decay function representing the access interval of the data to be accessed, I i being the access interval of the ith data to be accessed, lambda being the decay factor of the access interval, D i being the access duration of the ith data to be accessed; The method comprises the steps of limiting the influence of long-time access, avoiding excessive influence of extreme values on scoring, enabling mu to be an adjusting parameter of access duration, enabling S i to be a security level score of ith data to be accessed according to data sensitivity and access authority, enabling Q i to be a user feedback quality score of the ith data to be accessed, indirectly reflecting the quality of the data by collecting the evaluation of the data to be accessed by a user, enabling alpha, beta, gamma, delta and eta to be weight coefficients of all factors, enabling the weight coefficients to be dynamically adjusted through a machine learning algorithm to adapt to different application scenes, enabling F max to be the maximum access frequency in all the data to be accessed, and normalizing the access frequency.
Introducing a time decay factor to obtain an adjusted value score, wherein the adjusted value score is defined as:
Vi(t)=Vi·e-ρt
Wherein, V i (t) is the value score of the i-th data to be accessed after adjustment, V i is the value score of the i-th data to be accessed, t is the time interval from the last access to the present, ρ is the time attenuation coefficient, and is used for simulating the phenomenon that the data gradually lose value with the lapse of time.
Optionally, the establishing a cache policy optimization model includes:
defining an optimization target O of the overall cache performance:
Wherein O is an optimization target of the overall cache performance, N is the total number of data to be accessed in the cache, P i represents the probability that the ith data to be accessed is correctly predicted, V i (t) represents the value score of the ith data to be accessed, and time attenuation is considered; The method is a nonlinear function used for adjusting the influence of the prediction probability on the score, k represents a parameter for adjusting the influence speed of the prediction probability on the score, P 0 represents a threshold value of the prediction probability, C represents the maintenance cost of a cache system in unit time, L represents the average delay of loading or transferring data of the cache system, ζ represents a weight coefficient of a system health index, H represents the system health index, E represents an energy consumption index which is quantified by calculating the energy consumed by the cache operation in unit time, ω represents the weight coefficient of the energy consumption index, and the importance of energy conservation and emission reduction in cache policy optimization is reflected.
In a second aspect, an embodiment of the present application provides an optimization system for cache management, including:
The receiving module is used for receiving a cache access request initiated by an application program, wherein the cache access request comprises identification information of data to be accessed;
The adjustment module is used for evaluating the access heat of the data to be accessed based on the identification information and dynamically adjusting the position of the data in a cache hierarchical structure by combining the current cache state and a preset cache strategy;
the detection migration module is used for predicting the access requirement in a period of time in the future according to the access mode of the data to be accessed when the cache space is detected to be insufficient, preferentially retaining the high-value data to be accessed, and selectively migrating the low-value data to be accessed into a low-level cache or storage device through an intelligent algorithm;
And the optimization module is used for continuously optimizing the cache strategy according to the historical access record and the real-time access condition, ensuring the efficient utilization of the cache resources and reducing the access delay to the back-end storage system.
In a third aspect, an embodiment of the present application provides a computing device, including a processing component and a storage component, where the storage component stores one or more computer instructions, and the one or more computer instructions are configured to be invoked and executed by the processing component to implement a method for cache management optimization according to any one of the first aspects.
In a fourth aspect, an embodiment of the present application provides a computer storage medium storing a computer program, where the computer program when executed by a computer implements a method for cache management optimization according to any one of the first aspects.
According to the embodiment of the application, a cache access request initiated by an application program is received, the cache access request contains identification information of data to be accessed, the access heat of the data to be accessed is evaluated based on the identification information, the position of the data to be accessed in a cache hierarchical structure is dynamically adjusted by combining the current cache state and a preset cache strategy, when the cache space is detected to be insufficient, the access requirement in a period of time in the future is predicted according to the access mode of the data to be accessed, the high-value data to be accessed is preferentially reserved, the low-value data to be accessed is selectively migrated to a low-level cache or storage device through an intelligent algorithm, and the cache strategy is continuously optimized according to the historical access record and the real-time access condition, so that the high-efficiency utilization of cache resources is ensured, and the access delay to a rear-end storage system is reduced. The technical scheme provided by the application improves the performance and efficiency of the cache management system.
These and other aspects of the application will be more readily apparent from the following description of the embodiments.
Detailed Description
In order to enable those skilled in the art to better understand the present application, the following description will make clear and complete descriptions of the technical solutions according to the embodiments of the present application with reference to the accompanying drawings.
In some of the flows described in the specification and claims of the present application and in the foregoing figures, a plurality of operations occurring in a particular order are included, but it should be understood that the operations may be performed out of order or performed in parallel, with the order of operations such as 101, 102, etc., being merely used to distinguish between the various operations, the order of the operations themselves not representing any order of execution. In addition, the flows may include more or fewer operations, and the operations may be performed sequentially or in parallel. It should be noted that, the descriptions of "first" and "second" herein are used to distinguish different messages, devices, modules, etc., and do not represent a sequence, and are not limited to the "first" and the "second" being different types.
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to fall within the scope of the application.
Fig. 1 is a flowchart of a method for cache management optimization according to an embodiment of the present application, where, as shown in fig. 1, the method includes:
101. Receiving a cache access request initiated by an application program, wherein the cache access request comprises identification information of data to be accessed;
In this step, a cache access request is a request issued by an application, intended to acquire or update specific data from the cache. The identification information of the data to be accessed is an identifier for uniquely identifying the data in the cache, which may be a file name, a database key, or other form of unique identifier. The access heat is an indicator of how frequently data is accessed and is typically used to determine the location of the data in the cache hierarchy. A cache hierarchy is a hierarchical cache architecture, with different levels of caches having different performance characteristics. In general, the closer to the top level the cache access speed is but the higher the cost is. A caching policy is a set of rules defining how to manage and maintain a cache, including but not limited to, joining, retirement, and migration of data, among others. Intelligent algorithms are algorithms that utilize machine learning or artificial intelligence techniques to predict and optimize data access patterns. Historical access records are the history of data accessed over a period of time, used to analyze access patterns and predict future access needs.
In this step, the cache management system first receives a request from the application program, the request including unique identification information of the data to be accessed. This process is the entry point for the entire data access flow, ensuring that the system is able to accurately locate the specific data that the user wants to access.
In the embodiment of the present application, it is assumed that an e-commerce web site is being operated, which provides a browsing function of a large amount of commodity information. In order to improve user experience, a multi-level cache system is realized to accelerate loading time of the commodity detail page. The following is a typical cache access request processing procedure of the system:
a customer clicks on a particular item link on the web site and wishes to view the item's details.
Upon receiving the request from the client, the application server of the website constructs a cache access request, which includes the unique ID of the commodity (e.g., the commodity ID is 123456).
The application server sends this request to the cache management system. At this time, the cache management system receives the request and parses out the identification information of the data to be accessed, namely, the commodity ID123456.
The system then searches the corresponding cache data according to the commodity ID, if so, the corresponding cache data is directly returned to the application server, and if not, the data needs to be read from the back-end database and whether the data is added into the cache or not is considered for future quick access.
By implementing the scheme, delay caused by frequent access to the back-end database can be remarkably reduced, and the response speed and user experience of the website are improved. Meanwhile, limited cache resources can be effectively utilized by intelligently managing cache contents, and the operation cost is reduced. In addition, for commodity information with high access quantity, since the commodity information can be preferentially kept in a high-level cache, the access speed of the hot spot data can be further accelerated, which is important for improving the overall performance of the website.
102. Based on the identification information, evaluating the access heat of the data to be accessed, and dynamically adjusting the position of the data to be accessed in a cache hierarchical structure by combining the current cache state and a preset cache strategy;
In this step, upon receiving the request, the system analyzes the access frequency and pattern of the data to determine its "heat. And then, according to the current caching state and a preset caching strategy, determining whether the position of the data in the multi-level caching system needs to be adjusted so as to achieve the optimal access performance.
In the embodiment of the application, if a movie is found to be popular, the system may move the movie from a lower level cache to a higher level cache, so as to respond to the user's viewing request more quickly, assuming an online video platform.
In existing cache management systems, static cache policies are typically employed to manage the location of data, which, while simple, are not flexible enough to face complex and variable access patterns. In particular, there are several major problems in that static caching policies cannot dynamically adjust the location of data according to the actual access situation of the data, resulting in hot spot data that may be placed in an inefficient cache hierarchy, affecting access performance. Static policies may result in overcrowding of some cache levels while others are idle, resulting in wasted resources. When a system suddenly faces a large number of access requests, static policies are difficult to quickly adjust, resulting in performance bottlenecks.
In order to solve the problems, the embodiment of the invention provides an alternative scheme for dynamically adjusting the cache position, which is used for dynamically adjusting the position of the data in the cache hierarchical structure by more finely evaluating the access heat of the data and combining the current cache state and a preset cache strategy, thereby improving the utilization rate and the access performance of cache resources.
The alternative scheme is specifically as follows:
Optionally, the step 102 of evaluating the access heat of the data to be accessed based on the identification information and dynamically adjusting the position of the data to be accessed in the cache hierarchy in combination with the current cache state and a preset cache policy includes acquiring corresponding cache entries according to the identification information, collecting and analyzing historical access records of the data to be accessed from the cache entries, including indexes of access frequency, last access time and average access interval, to evaluate the access heat of the data to be accessed, and determining the optimal position of the data to be accessed in the cache hierarchy in combination with the state of the current cache hierarchy and the preset cache policy according to the access heat.
In this step, the cache entry is a data item stored in the cache, typically containing the data itself and its metadata. The access popularity is a comprehensive index for measuring the frequency of data access and the latest access time, and is used for determining the position of data in a cache hierarchy. The historical access record records the access condition of the data in the past period of time, including the access frequency, the last access time, the average access interval and the like. The cache hierarchy is a multi-level cache architecture, with different levels of caches having different performance characteristics, generally the higher the level the faster but more costly the cache access. A caching policy is a set of rules defining how to manage and maintain the cache, including the addition, elimination, and migration of data, etc.
Firstly, the system searches the corresponding cache entry from the cache according to the identification information in the cache access request. The cache entry contains not only the data itself, but also metadata related to the data, such as access time, frequency, etc.
Secondly, the system extracts historical access records from the cache entries, including indexes such as access frequency, last access time, average access interval and the like, and the historical access records are used for evaluating the access heat of the data.
Further, according to the access heat, determining an optimal position of the data to be accessed in the cache hierarchical structure by combining the state of the current cache hierarchical structure and a preset cache policy
In the embodiment of the present application, it is assumed that an e-commerce web site is being operated, which provides a browsing function of a large amount of commodity information. In order to improve user experience, a multi-level cache system is realized to accelerate loading time of the commodity detail page. The following is a typical cache access request processing procedure of the system:
A customer clicks on a particular item link on the web site and wishes to view the item's details. The commodity ID is 123456.
After receiving the request from the client, the application server of the website constructs a cache access request, which contains the commodity ID123456.
The application server sends this request to the cache management system. The system searches a corresponding cache entry from the cache according to the commodity ID123456, wherein the entry contains the following information:
commodity data
Last access time: 2024-09-2510:00:00
Access frequency 10 times per day
Average access interval 1 hour
The system extracts the historical access record from the cache entry and evaluates that the commodity has higher access heat.
The system checks the state of the current cache hierarchy and finds that the memory cache has sufficient space. According to a preset caching strategy, the system decides to migrate the commodity data from the disk cache to the memory cache.
The system rapidly reads commodity data from the memory cache, returns the commodity data to the application server and finally displays the commodity data to the user.
By implementing the alternative scheme, the hot spot data can be dynamically adjusted to a higher-level cache, so that access delay is reduced, and user experience is improved. The system can dynamically adjust the cache content according to the actual access condition, thereby avoiding the waste of resources and improving the utilization rate of cache resources. The system can respond to the change of the access mode rapidly, dynamically adjust the cache strategy, effectively respond to the burst access request and keep the high performance of the system.
In summary, the optional scheme solves the problem of inflexibility of cache management in the prior art by more finely evaluating the access heat of data and dynamically adjusting the cache position, and remarkably improves the performance and resource utilization rate of the system.
103. When the insufficient cache space is detected, predicting the access requirement in a future period of time according to the access mode of the data to be accessed, preferentially retaining the high-value data to be accessed, and selectively transferring the low-value data to be accessed to a low-level cache or storage device through an intelligent algorithm;
In this step, when the system detects that the cache space is about to be exhausted, a predictive algorithm is used to estimate the access requirements for each item of data over a period of time in the future. Based on these predictions, the system will selectively eliminate those data for which access is expected to be small, or migrate them to lower-level storage devices, thereby making room for more frequently accessed data.
In the embodiment of the application, assuming that the buffer space of the video platform is tense and the number of times of watching a certain movie is obviously reduced, the system may automatically transfer the data of the movies from the cache to a slower but larger-capacity storage device, such as a cloud storage service.
In existing cache management systems, when the cache space is insufficient, a simple elimination strategy is generally adopted to release the space. However, these strategies tend to be too simple to adequately account for future access needs of the data, resulting in some high value data being misphased out while low value data is retained. In particular, there are several major problems with conventional elimination strategies based only on current or past data access conditions, and the inability to predict future access needs may result in the false elimination of important data. Simple elimination strategies may result in frequent data migration, increase overhead, and may also result in wasted cache resources. Conventional elimination strategies may lead to unstable system performance when the cache space is insufficient, especially under high load conditions.
In order to solve the problems, the embodiment of the invention provides a cache optimization scheme based on access mode prediction and an intelligent algorithm, which is used for preferentially reserving high-value data and migrating low-value data to low-level cache or storage equipment by more accurately evaluating the future access requirements of the data, so that the utilization rate of cache resources and the overall performance of a system are improved.
The alternative scheme is specifically as follows:
Optionally, when the buffer space is detected to be insufficient, predicting an access demand in a future period according to an access mode of the data to be accessed, preferentially retaining high-value data to be accessed, selectively migrating low-value data to a buffer or a storage device of a lower level through an intelligent algorithm, wherein the method comprises the steps of monitoring a use state of a buffer system in real time, triggering a buffer optimization process when the available buffer space is found to be lower than a preset threshold, predicting the access demand of the data to be accessed in the future period based on the historical access record and the acquired real-time access condition, generating an access demand prediction model, calculating a value score of the data to be accessed according to a prediction result of the access demand prediction model, sorting all the data to be accessed according to the value score, taking the data to be accessed with the value score higher than the set threshold as the high-value data to be accessed, retaining the high-value data to be accessed, and migrating the value score lower than the set value data to the low-value data to be accessed level through the intelligent algorithm, or storing the low-value data to be accessed level through the intelligent algorithm, and storing the low-value data to the low-level to be accessed.
In this step, insufficient buffer space means that the available space of the buffer system is lower than a preset threshold, and measures need to be taken to release the space. The access pattern is a combination of characteristics of access frequency, access interval, access duration, etc. of the data for predicting future access needs. The access demand prediction model is a model generated by a machine learning or statistical method based on historical access records and real-time access conditions and is used for predicting the access demand of data in a future period of time. The value score is an index for quantitatively evaluating the importance of the data by comprehensively considering factors such as access frequency, access interval, access duration and the like. Intelligent algorithms are algorithms that automatically selectively migrate low value data into a low level cache or storage device using machine learning or optimization algorithms.
Firstly, the system continuously monitors the use state of the cache, and when the available cache space is lower than a preset threshold value, a cache optimization process is started to release the space.
Secondly, the system generates an access demand prediction model by utilizing a historical access record and a real-time access condition through a machine learning or statistical method, and predicts the access demand of data in a future period.
Next, the system calculates a value score for each data based on the prediction results of the access demand prediction model. Factors such as high access frequency, short access interval, long duration, etc., can increase the value score of the data. The way to calculate the value score may be set according to the requirement, for example, through a preset formula, which is not limited in the embodiment of the present application.
Further, the system ranks all data according to the calculated value score, marks data with a value score above a set threshold as high value data, and retains the data.
Finally, the system marks data with a value score below a set threshold as low value data and selectively migrates the data to a low level cache or storage device through intelligent algorithms to free up high level cache space.
In the embodiment of the present application, it is assumed that an e-commerce web site is being operated, which provides a browsing function of a large amount of commodity information. In order to improve user experience, a multi-level cache system is realized to accelerate loading time of the commodity detail page. The following is the case where the system handles insufficient buffer space:
The system continuously monitors the use condition of the buffer memory, and when the available buffer memory space is detected to be reduced to 8%, the buffer memory optimizing process is triggered.
The system collects access records for all data in the past month, including access frequency, last access time, and average access interval. In combination with real-time access to the data, the system generates an access demand prediction model for predicting the access demand of each data in the future week.
The system calculates a value score for each piece of data based on the results of the access demand prediction model.
The system ranks all data according to the calculated value score, assuming a threshold of 0.6, retaining data with a value score above 6.0. The system migrates the data with the value score lower than 6.0 from the memory cache to the disk cache, and releases the space of the memory cache.
By implementing the alternative scheme, the system has the advantages that by predicting future access demands, the system can keep high-value data in the high-level cache, access delay is reduced, and user experience is improved. The system can more reasonably allocate the cache resources, avoid resource waste and improve the utilization rate of the cache resources. The system can dynamically adjust the cache content, effectively cope with burst access requests, and keep high performance and stability of the system. The intelligent algorithm selectively migrates low-value data, so that frequent data migration and elimination operations are reduced, and the risk of system performance fluctuation is reduced.
In summary, the cache optimization based on the access mode prediction solves the problem of inflexibility of cache management in the prior art, remarkably improves the performance and resource utilization rate of the system, and improves the user experience.
In the existing cache management technology, when the system detects that the cache space is insufficient, a simple strategy such as LRU or LFU is generally adopted to determine which data should be eliminated from the cache. However, these methods tend to ignore the actual value of the data, i.e., the likelihood that they will be revisited in the future and the importance of the visit. This may result in some high value data being misphased out, while some low value data occupies valuable cache space, thereby reducing the overall performance and user experience of the system.
In order to solve the problem, the embodiment of the invention provides an intelligent cache management scheme based on data access mode prediction. According to the scheme, not only is the historical access frequency of the data considered, but also a plurality of dimensions such as the access interval, the access duration, the security level score, the user feedback quality score and the like of the data are integrated, the value score of each piece of data is calculated through an intelligent algorithm, a more reasonable caching decision is made according to the value score, and the utilization rate of a caching space and the response efficiency of a system are effectively improved.
The alternative scheme is specifically as follows:
optionally, the calculating a value score of the data to be accessed in step 103 includes:
Calculating a value scoring formula V i of the data to be accessed:
Wherein V i represents the value score of the ith data to be accessed, F i is the access frequency of the ith data to be accessed, and θ is the index adjustment parameter of the access frequency; Representing a sinusoidal function for introducing nonlinear variation; an exponential decay function representing the access interval of the data to be accessed, I i being the access interval of the ith data to be accessed, lambda being the decay factor of the access interval, D i being the access duration of the ith data to be accessed; The method comprises the steps of limiting the influence of long-time access, avoiding excessive influence of extreme values on scoring, enabling mu to be an adjusting parameter of access duration, enabling S i to be a security level score of ith data to be accessed according to data sensitivity and access authority, enabling Q i to be a user feedback quality score of the ith data to be accessed, indirectly reflecting the quality of the data by collecting the evaluation of the data to be accessed by a user, enabling alpha, beta, gamma, delta and eta to be weight coefficients of all factors, enabling the weight coefficients to be dynamically adjusted through a machine learning algorithm to adapt to different application scenes, enabling F max to be the maximum access frequency in all the data to be accessed, and normalizing the access frequency.
Introducing a time decay factor to obtain an adjusted value score, wherein the adjusted value score is defined as:
Vi(t)=Vi·e-ρt
Wherein, V i (t) is the value score of the i-th data to be accessed after adjustment, V i is the value score of the i-th data to be accessed, t is the time interval from the last access to the present, ρ is the time attenuation coefficient, and is used for simulating the phenomenon that the data gradually lose value with the lapse of time.
In this step, the present scheme first applies the following formula:
The value score V i of each piece of data to be accessed is calculated, the factors such as the access frequency, access interval, access duration, security level score and user feedback quality score of the data are comprehensively considered by a formula, and the final score can accurately reflect the real value of the data by endowing the corresponding weight coefficients alpha, beta, gamma, delta and eta to different factors.
Wherein V i represents the value score of the ith data to be accessed, F i is the access frequency of the ith data to be accessed, and θ is the index adjustment parameter of the access frequency; Representing a sinusoidal function for introducing nonlinear variation; an exponential decay function representing the access interval of the data to be accessed, I i being the access interval of the ith data to be accessed, lambda being the decay factor of the access interval, D i being the access duration of the ith data to be accessed; The method comprises the steps of limiting the influence of long-time access, avoiding excessive influence of extreme values on scoring, enabling mu to be an adjusting parameter of access duration, enabling S i to be a security level score of ith data to be accessed according to data sensitivity and access authority, enabling Q i to be a user feedback quality score of the ith data to be accessed, indirectly reflecting the quality of the data by collecting the evaluation of the data to be accessed by a user, enabling alpha, beta, gamma, delta and eta to be weight coefficients of all factors, enabling the weight coefficients to be dynamically adjusted through a machine learning algorithm to adapt to different application scenes, enabling F max to be the maximum access frequency in all the data to be accessed, and normalizing the access frequency.
Subsequently, to more accurately reflect the value of the data over time, a time decay factor is introduced, resulting in an adjusted value score V i(t)=Vi·e-ρt, where t represents the time interval from the last visit to the present. This ensures that data that has not been accessed for a long period of time will gradually decrease in value and will be preferentially eliminated when the cache space is tight.
Wherein, V i (t) is the value score of the i-th data to be accessed after adjustment, V i is the value score of the i-th data to be accessed, t is the time interval from the last access to the present, ρ is the time attenuation coefficient, and is used for simulating the phenomenon that the data gradually lose value with the lapse of time.
In the embodiment of the application, it is assumed that in a cache management system of an online video platform, there are two pieces of data a and B to be accessed, and relevant parameters are as follows:
Data a, F A=100,IA =2 hours, D A =30 minutes, S A=8,QA =9;
Data B, F B=50,IB =10 hours, D B =10 minutes, S B=6,QB =7;
Fmax=100,α=0.4,β=0.2,γ=0.1,δ=0.2,ζ=0.1,θ=1.5,λ=0.1,μ=0.05,ρ=0.01;
The value score for data a is:
the value scores for data B were:
assuming that the time interval t from last visit to present is 1 day and 2 days for data a and B, respectively, the adjusted value scores are:
VA(1)=162.8945·e-0.01·24≈162.8945·0.7871≈128.17
VB(2)=81.0939·e-0.01·48≈81.0939·0.6065≈49.21
From the above calculation, it can be seen that even though the initial value score of the data a is higher, the adjusted value score is still higher than that of the data B due to the shorter access interval, so that the data a should be preferentially reserved when the buffer space is insufficient.
According to the scheme, the data value is evaluated through integrating a plurality of dimensions, so that the intelligent level of cache management is improved, the risk that high-value data are eliminated possibly brought by a traditional method is effectively avoided, and the system is ensured to provide better service quality and user experience under limited resources.
104. And continuously optimizing a caching strategy according to the historical access record and the real-time access condition, ensuring the efficient utilization of the caching resources and simultaneously reducing the access delay to the back-end storage system.
In this step, to ensure long-term optimal performance, the system will constantly learn and adapt to new access patterns, automatically adjust caching policies, including but not limited to data migration rules, cache size allocation, etc., by analyzing historical access records and current access trends to minimize latency and maximize cache utilization.
In the embodiment of the application, the video platform is assumed to periodically examine the change of the watching behavior of the user, for example, the newly-launched movie tends to have a large initial access amount and gradually decreases with the lapse of time. Based on such observation, the system can automatically adjust the caching strategy of the new content, and ensure that the hot content can be loaded quickly all the time without occupying excessive long-term caching resources.
In existing cache management techniques, the cache policy is often static, i.e., it does not change easily once determined. However, such static caching policies are difficult to cope with changing access patterns and traffic demands, resulting in low utilization of cache resources and possibly even increased access latency to the back-end storage system. Particularly in internet applications, the user behavior and business requirements change very frequently, and static caching strategies cannot adapt to the changes in time, so that the performance and user experience of the system are affected.
In order to solve the problem, the embodiment of the invention provides a dynamic cache strategy optimization scheme based on historical access records and real-time access conditions. According to the scheme, the effect of the current caching strategy is continuously evaluated, the optimization suggestion is automatically generated according to the evaluation result, and the caching strategy parameters are dynamically adjusted, so that efficient utilization of caching resources is ensured, and meanwhile, access delay to a back-end storage system is reduced.
The alternative scheme is specifically as follows:
Optionally, the step 104 of continuously optimizing the cache policy according to the historical access record and the real-time access condition, ensuring the efficient utilization of the cache resources and reducing the access delay to the back-end storage system simultaneously includes evaluating the effect of the current cache policy by combining the historical access record and the real-time access condition to obtain an evaluation result, establishing a cache policy optimization model according to the evaluation result, wherein the cache policy optimization model can automatically generate optimization suggestions based on different application scenes and business requirements, dynamically adjusting the cache policy parameters according to the optimization suggestions of the optimized cache policy optimization model to generate an adjusted cache policy, deploying the adjusted cache policy in the actual environment, and verifying the effect of the adjusted cache policy to ensure the efficient utilization of the cache resources and simultaneously reducing the access delay to the back-end storage system.
In this step, the historical access record refers to a detailed record of all access requests in the past period of time of the system, including information such as access time, access frequency, access data, etc. The real-time access condition refers to an access request currently occurring in the system, and comprises information such as current access frequency, access mode and the like. The evaluation result is that the effect evaluation of the current cache policy, including indexes such as cache hit rate, access delay and the like, is obtained by analyzing the history access record and the real-time access condition. The cache policy optimization model is a model based on machine learning or optimization algorithm, and can automatically generate optimization suggestions according to the evaluation result to help dynamically adjust cache policy parameters. The cache policy parameters include cache size, cache replacement algorithm, data prefetching policy, etc., which directly affect the performance of the cache. The adjusted caching strategy is adjusted according to the optimization suggestion, and aims to improve the utilization rate of caching resources and reduce access delay.
Firstly, the effect of the current caching strategy is evaluated by combining the historical access record and the real-time access condition, and an evaluation result is obtained. The evaluation result generally includes key indexes such as cache hit rate, average access delay and the like.
And secondly, establishing a cache strategy optimization model according to the evaluation result. The model can automatically generate optimization suggestions based on different application scenes and business requirements. Optimization suggestions may include adjusting cache size, replacing cache replacement algorithms, optimizing data prefetch policies, and the like.
Further, according to the optimization suggestion of the optimized cache policy optimization model, the cache policy parameters are dynamically adjusted, and an adjusted cache policy is generated. These adjustments may be made in real time to accommodate changing access patterns and business requirements.
And finally, deploying the adjusted cache strategy in the actual environment, verifying the effect of the cache strategy, ensuring the efficient utilization of the cache resources and reducing the access delay to the back-end storage system. If the verification result shows that the effect is poor, the optimization model can be continued to generate new optimization suggestions until the expected effect is achieved.
In the embodiment of the application, it is assumed that in a cache management system of an e-commerce platform, the effect evaluation result of the current cache policy is as follows:
The cache hit rate is 70%
Average access delay 200ms
By analyzing the history access records and the real-time access conditions, the problems that the access frequency of some hot spot commodities is very high, but the cache hit rate is low are found. Some cold goods occupy a certain proportion of buffer space, but the access frequency is very low.
And establishing a caching strategy optimization model based on machine learning according to the evaluation result. The model generates optimization suggestions by increasing the cache space of hot spot commodities and reducing the cache space of cold gate commodities. Switching from LRU algorithm to LFU algorithm is suitable for accessing data with high frequency. And pre-fetching commodity data which is possibly accessed in advance according to the browsing behavior of the user.
And according to the optimization suggestion, dynamically adjusting the caching strategy parameters, namely increasing the caching space of the hot spot commodity from 10% to 30%. The cache replacement algorithm is switched from LRU to LFU. A data pre-fetching policy based on user behavior is enabled.
The adjusted caching strategy is deployed in the actual environment, and the effect is verified:
The cache hit rate is raised to 85%
Average access delay of down to 150ms
Through the dynamic cache policy optimization scheme, the cache system of the e-commerce platform can more effectively utilize cache resources, the cache hit rate is remarkably improved, and the access delay to the back-end storage system is reduced. The system not only improves the overall performance of the system, but also improves the user experience, and particularly under the condition of high concurrent access, the system can better cope with burst traffic and ensure the stability and reliability of service.
In existing cache management techniques, optimization of cache policies typically relies on static rules or simple performance metrics such as cache hit rate and access latency. However, these approaches tend to ignore the overall performance of the cache system, including several aspects of cost, latency, system health, and power consumption. The single optimization method is difficult to comprehensively meet the requirements of different application scenes, and particularly in a large-scale distributed system, the efficient utilization of cache resources and performance optimization become more complex.
In order to solve the problem, the embodiment of the invention provides a cache policy optimization model based on multi-objective optimization. The model establishes an optimization target of overall cache performance by comprehensively considering a plurality of factors such as cache performance, cost, delay, system health, energy consumption and the like, ensures high-efficiency utilization of cache resources by dynamically adjusting cache policy parameters, and reduces access delay to a back-end storage system.
The alternative scheme is specifically as follows:
Optionally, the establishing a cache policy optimization model in step 104 includes:
defining an optimization target O of the overall cache performance:
Wherein O is an optimization target of the overall cache performance, N is the total number of data to be accessed in the cache, P i represents the probability that the ith data to be accessed is correctly predicted, V i (t) represents the value score of the ith data to be accessed, and time attenuation is considered; The method is a nonlinear function used for adjusting the influence of the prediction probability on the score, k represents a parameter for adjusting the influence speed of the prediction probability on the score, P 0 represents a threshold value of the prediction probability, C represents the maintenance cost of a cache system in unit time, L represents the average delay of loading or transferring data of the cache system, ζ represents a weight coefficient of a system health index, H represents the system health index, E represents an energy consumption index which is quantified by calculating the energy consumed by the cache operation in unit time, ω represents the weight coefficient of the energy consumption index, and the importance of energy conservation and emission reduction in cache policy optimization is reflected.
In this step, first, the following formula is used:
An optimization objective O of overall cache performance is defined. The formula comprehensively considers a plurality of factors such as the prediction probability, the value score, the system maintenance cost, the loading delay, the system health degree and the energy consumption of the data.
Wherein O is an optimization target of the overall cache performance, N is the total number of data to be accessed in the cache, P i represents the probability that the ith data to be accessed is correctly predicted, V i (t) represents the value score of the ith data to be accessed, and time attenuation is considered; The method is a nonlinear function used for adjusting the influence of the prediction probability on the score, k represents a parameter for adjusting the influence speed of the prediction probability on the score, P 0 represents a threshold value of the prediction probability, C represents the maintenance cost of a cache system in unit time, L represents the average delay of loading or transferring data of the cache system, ζ represents a weight coefficient of a system health index, H represents the system health index, E represents an energy consumption index which is quantified by calculating the energy consumed by the cache operation in unit time, ω represents the weight coefficient of the energy consumption index, and the importance of energy conservation and emission reduction in cache policy optimization is reflected.
And secondly, evaluating the effect of the current caching strategy by combining the historical access record and the real-time access condition to obtain an evaluation result.
And then, establishing a cache strategy optimization model according to the evaluation result. The model can automatically generate optimization suggestions based on different application scenes and business requirements.
Further, according to the optimization suggestion of the optimized cache policy optimization model, the cache policy parameters are dynamically adjusted, and an adjusted cache policy is generated.
And finally, deploying the adjusted cache strategy in the actual environment, verifying the effect of the cache strategy, ensuring the efficient utilization of the cache resources and reducing the access delay to the back-end storage system.
In the embodiment of the application, it is assumed that in a cache management system of a large-scale e-commerce website, the effect evaluation result of the current cache policy is as follows:
The cache hit rate is 70%
Average access delay 200ms
System health degree 85 (full 100)
The energy consumption is 1000 watt-hours/hour
According to the formulaAn optimization objective O of overall cache performance is defined. Wherein n=1000, p i has an average value of 0.8, v i (t) has an average value of 150, k= 5;P 0 =0.5, c=10, l=200, ζ=0.1, h=85, ω=0.05, e=1000;
Calculating O:
The nonlinear function part is calculated first:
The sum portion is recalculated:
And finally, calculating an optimization target O of the overall cache performance:
O=72000-10·200-0.1·85-0.05·1000
O=69941.5
by analyzing the history access records and the real-time access conditions, the problems that the access frequency of some hot spot commodities is very high, but the cache hit rate is low are found. Some cold goods occupy a certain proportion of buffer space, but the access frequency is very low.
And establishing a caching strategy optimization model based on machine learning according to the evaluation result. The model generates optimization suggestions by increasing the cache space of hot spot commodities and reducing the cache space of cold gate commodities. Switching from LRU algorithm to LFU algorithm is suitable for accessing data with high frequency. And pre-fetching commodity data which is possibly accessed in advance according to the browsing behavior of the user.
And according to the optimization suggestion, dynamically adjusting the caching strategy parameters, namely increasing the caching space of the hot spot commodity from 10% to 30%. The cache replacement algorithm is switched from LRU to LFU. A data pre-fetching policy based on user behavior is enabled.
The adjusted caching strategy is deployed in the actual environment, and the effect is verified:
The cache hit rate is raised to 85%
Average access delay of down to 150ms
The health degree of the system is raised to 90
The energy consumption is reduced to 800 watt-hours/hour
Recalculating an optimization target O of the overall cache performance after optimization:
The nonlinear function part is calculated first:
The sum portion is recalculated:
And finally, calculating an optimization target O of the overall cache performance:
O=77460-10·150-0.1·90-0.05·800
O=75911
Through the dynamic cache policy optimization scheme, the cache system of the e-commerce platform not only remarkably improves the cache hit rate and reduces access delay, but also improves the system health and reduces energy consumption. The system not only optimizes the overall performance of the system, but also improves the user experience, and particularly under the condition of high concurrent access, the system can better cope with burst traffic and ensure the stability and reliability of service. In addition, the energy conservation and emission reduction are realized, the requirements of environmental protection are met, and important economic and social benefits are realized.
Fig. 2 is a schematic structural diagram of an optimization system for cache management according to an embodiment of the present application, where, as shown in fig. 2, the system includes:
A receiving module 21, configured to receive a cache access request initiated by an application program, where the cache access request includes identification information of data to be accessed;
The adjustment module 22 is configured to evaluate the access heat of the data to be accessed based on the identification information, and dynamically adjust the position of the data in the cache hierarchy in combination with the current cache state and a preset cache policy;
The detection migration module 23 is configured to predict an access requirement in a future period according to an access mode of the data to be accessed when the cache space is detected to be insufficient, preferentially reserve high-value data to be accessed, and selectively migrate low-value data to be accessed to a low-level cache or storage device through an intelligent algorithm;
And the optimization module 24 is used for continuously optimizing the cache policy according to the historical access record and the real-time access condition, ensuring the efficient utilization of the cache resources and simultaneously reducing the access delay to the back-end storage system.
The optimization system for cache management described in fig. 2 may implement the optimization system for cache management described in the embodiment shown in fig. 1, and its implementation principles and technical effects are not repeated. The specific manner in which the various modules and units perform operations in the above-described optimization system for cache management in the embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
In one possible design, the optimization system for cache management of the embodiment shown in FIG. 2 may be implemented as a computing device, which may include a storage component 31 and a processing component 32, as shown in FIG. 3;
the storage component 31 stores one or more computer instructions for execution by the processing component 32.
The processing component 32 is configured to receive a cache access request initiated by an application program, where the cache access request includes identification information of data to be accessed, evaluate access heat of the data to be accessed based on the identification information, dynamically adjust a position of the data to be accessed in a cache hierarchy in combination with a current cache state and a preset cache policy, predict an access requirement in a future period according to an access mode of the data to be accessed when a cache space is detected to be insufficient, preferentially reserve the high-value data to be accessed, and selectively migrate the low-value data to be accessed to a low-level cache or a storage device through an intelligent algorithm, and continuously optimize the cache policy according to a historical access record and a real-time access condition, ensure efficient utilization of cache resources and simultaneously reduce access delay to a back-end storage system.
Wherein the processing component 32 may include one or more processors to execute computer instructions to perform all or part of the steps of the methods described above. Of course, the processing component may also be implemented as one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic elements for executing the methods described above.
The storage component 31 is configured to store various types of data to support operations at the terminal. The memory component may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
Of course, the computing device may necessarily include other components as well, such as input/output interfaces, display components, communication components, and the like.
The input/output interface provides an interface between the processing component and a peripheral interface module, which may be an output device, an input device, etc.
The communication component is configured to facilitate wired or wireless communication between the computing device and other devices, and the like.
The computing device may be a physical device or an elastic computing host provided by the cloud computing platform, and at this time, the computing device may be a cloud server, and the processing component, the storage component, and the like may be a base server resource rented or purchased from the cloud computing platform.
The embodiment of the application also provides a computer storage medium, which stores a computer program, and the computer program can realize the optimization method of cache management in the embodiment shown in fig. 1 when being executed by a computer.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
The system embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the respective embodiments or some parts of the embodiments.
It should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present application, and not for limiting the same, and although the present application has been described in detail with reference to the above-mentioned embodiments, it should be understood by those skilled in the art that the technical solution described in the above-mentioned embodiments may be modified or some technical features may be equivalently replaced, and these modifications or substitutions do not make the essence of the corresponding technical solution deviate from the spirit and scope of the technical solution of the embodiments of the present application.