Adaptive adjustment method, device, electronic device and storage medium of cache mechanism

Through the adaptive adjustment method of the cache mechanism driven by machine learning and combined with a hybrid strategy of multiple cache policies, the traditional cache strategy lacks performance in high concurrency scenarios is solved, and the data hit rate and response speed are improved.

CN118760626BActive Publication Date: 2025-01-14JIHUA LAB
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411257654.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2025-01-14
Estimated Expiration
2044-09-09

AI Technical Summary

Technical Problem

Traditional cache strategies such as LRU, LFU, and FIFO lack dynamic adjustment and intelligent optimization capabilities when facing complex and changing access modes, resulting in a decrease in cache hit rate and limited system performance. The existing technology has failed to effectively solve high concurrent access and fast Responsive challenges.

Method used

Adaptive adjustment method of cache mechanism based on machine learning is adopted, and features are extracted by monitoring data access behavior, pre-trained cache mechanism prediction model is used to generate cache strategies, dynamically adjust the cache mechanism used in cache space, and combine LFU, LRU, FIFO and other strategies. The hybrid mechanism strategy meets the complex access needs of high concurrency scenarios.

Benefits of technology

It improves data hit rate and response speed, optimizes cache effect, and is suitable for complex and changeable high-concurrency access scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760626B_ABST
    Figure CN118760626B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data caching, and specifically discloses a method, device, electronic device and storage medium for adaptively adjusting a cache mechanism, wherein the method comprises the following steps: monitoring data access behavior and extracting corresponding data access features; generating a cache strategy according to the data access features based on a pre-trained cache mechanism prediction model; adjusting the cache mechanism according to the cache strategy; the method predicts and obtains the cache strategy according to the data access behavior based on a machine learning method, so as to dynamically adjust the cache mechanism adopted by the cache space based on the cache strategy, so that the cache mechanism currently adopted by the cache space is suitable for the current data access behavior, which can effectively improve the data hit rate and the data response speed, achieve the best cache effect, and effectively meet the complex and changeable access requirements of high-concurrency web scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data caching, and in particular to a method, device, electronic device and storage medium for adaptively adjusting a caching mechanism. Background Art

[0002] With the rapid development of big data, the Internet and the Internet of Things technologies, B / S architecture has become the mainstream of the market due to its flexibility and scalability, and is widely used in fields such as factory digitalization.

[0003] However, high-concurrency access and rapid response have become key challenges that need to be urgently addressed under this architecture. Maintaining continuous client connections to deliver the latest information has exacerbated the severity of the high-concurrency problem.

[0004] In this context, the cache mechanism has become the core strategy to improve system performance and response speed. However, traditional cache strategies such as LRU, LFU, FIFO, etc., are weak in the face of complex and changing access patterns, lacking dynamic adjustment and intelligent optimization capabilities, resulting in a decrease in cache hit rate and limited system performance.

[0005] There is currently no effective technical solution to the above problems. Summary of the invention

[0006] The purpose of the present application is to provide a method, device, electronic device and storage medium for adaptive adjustment of a cache mechanism, so as to realize adaptive dynamic adjustment of the cache mechanism.

[0007] In a first aspect, the present application provides a method for adaptively adjusting a cache mechanism, for adjusting a cache mechanism, the method comprising the following steps:

[0008] S1. Monitor data access behavior and extract corresponding data access features, where the data access features include one or more of frequency features, time features, interval features, size features, source features, and pattern features;

[0009] S2. Generate a cache strategy based on the data access feature based on a pre-trained cache mechanism prediction model, wherein the cache strategy includes one of LFU, LRU, and FIFO, or a hybrid mechanism strategy of two or more, and the hybrid mechanism strategy is used to divide the cache space into sub-cache spaces managed by a single cache mechanism of different types;

[0010] S3. Adjust the cache mechanism according to the cache strategy.

[0011] The adaptive adjustment method of the cache mechanism of the present application is based on machine learning to predict and obtain the cache strategy according to the data access behavior, so as to dynamically adjust the cache mechanism adopted by the cache space based on the cache strategy, so that the cache mechanism currently adopted by the cache space is suitable for the current data access behavior, which can effectively improve the data hit rate, improve the data response speed, and achieve the best cache effect; secondly, the cache strategy includes more than two hybrid mechanism strategies of LFU, LRU, and FIFO, which can effectively meet the complex and changeable access requirements of high-concurrency web scenarios.

[0012] The adaptive adjustment method of the cache mechanism, wherein the data access characteristics include frequency characteristics, time characteristics, interval characteristics, size characteristics, source characteristics and pattern characteristics.

[0013] In this example, the data access features include all of the above features, and the corresponding data access features used for training the cache mechanism prediction model also include the above features, so that the cache mechanism prediction model can more accurately focus on the access characteristics or changes in data access behavior to make more effective cache strategies.

[0014] The adaptive adjustment method of the cache mechanism, wherein the training process of the cache mechanism prediction model includes:

[0015] A1. Collect a training data set and a corresponding label data set, where the elements in the training data set are data access features, and the elements in the label data set are cache strategies that match the data access features;

[0016] A2. Train a machine learning model based on the data access features of the training data set and the cache strategy in the label data set that matches the data access features at the next moment of the data access features to obtain the cache mechanism prediction model.

[0017] The adaptive adjustment method of the cache mechanism, wherein the training process of the cache mechanism prediction model further includes the following steps performed after step A2:

[0018] A3. Verify the performance of the cache mechanism prediction model based on evaluation indicators.

[0019] In the adaptive adjustment method of the cache mechanism, step S1 is performed continuously in real time, or is triggered when the performance index of the current cache mechanism does not meet the preset index value.

[0020] In the adaptive adjustment method of the cache mechanism, the performance indicators are paired with different preset indicator values ​​in different usage periods.

[0021] The adaptive adjustment method of the cache mechanism, wherein the hybrid mechanism strategy includes the proportion of different cache mechanisms.

[0022] In a second aspect, the present application further provides an adaptive adjustment device for a cache mechanism, which is used to adjust the cache mechanism, and the device includes:

[0023] A collection module, used to monitor data access behavior and extract corresponding data access features, wherein the data access features include one or more of frequency features, time features, interval features, size features, source features and pattern features;

[0024] A strategy module, used to generate a cache strategy according to the data access characteristics based on a pre-trained cache mechanism prediction model, wherein the cache strategy includes a mechanism strategy of LFU, LRU, FIFO or a hybrid mechanism strategy of two or more, and the hybrid mechanism strategy is used to divide the cache space into sub-cache spaces managed by a single cache mechanism of different types;

[0025] An adjustment module is used to adjust the cache mechanism according to the cache strategy.

[0026] The adaptive adjustment device of the cache mechanism of the present application predicts and obtains the cache strategy according to the data access behavior based on the machine learning method, so as to dynamically adjust the cache mechanism adopted by the cache space based on the cache strategy, so that the cache mechanism currently adopted by the cache space is suitable for the current data access behavior, which can effectively improve the data hit rate, improve the data response speed, and achieve the best cache effect; secondly, the cache strategy includes more than two hybrid mechanism strategies of LFU, LRU, and FIFO, which can effectively meet the complex and changeable access requirements of high-concurrency web scenarios.

[0027] In a third aspect, the present application further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps in the method provided in the first aspect are executed.

[0028] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps in the method provided in the first aspect are executed.

[0029] From the above, it can be seen that the present application provides an adaptive adjustment method, device, electronic device and storage medium for a cache mechanism, wherein the adaptive adjustment method for the cache mechanism of the present application is based on a machine learning method to predict and obtain a cache strategy according to data access behavior, so as to dynamically adjust the cache mechanism adopted by the cache space based on the cache strategy, so that the cache mechanism currently adopted by the cache space is suitable for the current data access behavior, which can effectively improve the data hit rate, improve the data response speed, and achieve the best cache effect; secondly, the cache strategy includes more than two hybrid mechanism strategies of LFU, LRU, and FIFO, which can effectively meet the complex and changeable access requirements of high-concurrency web scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 A flowchart of a method for adaptively adjusting a cache mechanism provided in an embodiment of the present application.

[0031] Figure 2 A schematic diagram of the structure of an adaptive adjustment device for a cache mechanism provided in an embodiment of the present application.

[0032] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0033] Figure numerals: 201, acquisition module; 202, strategy module; 203, adjustment module; 301, processor; 302, memory; 303, communication bus. DETAILED DESCRIPTION

[0034] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0035] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0036] First, please refer to Figure 1Some embodiments of the present application provide a method for adaptively adjusting a cache mechanism, which is used to adjust the cache mechanism. The method includes the following steps:

[0037] S1. Monitor data access behavior and extract corresponding data access features, where the data access features include one or more of frequency features, time features, interval features, size features, source features, and pattern features;

[0038] S2, generating a cache strategy based on a pre-trained cache mechanism prediction model according to data access characteristics, the cache strategy including one of LFU, LRU, FIFO or a hybrid mechanism strategy of two or more, the hybrid mechanism strategy is used to divide the cache space into sub-cache spaces managed by a single cache mechanism based on different types;

[0039] S3. Adjust the cache mechanism according to the cache strategy.

[0040] Specifically, the adaptive adjustment method of the cache mechanism of the embodiment of the present application is suitable for scenarios with high concurrent access volume, such as high concurrent web scenarios. It can predict and adjust the cache mechanism according to the actual access volume to meet the complex and changeable access requirements of the web scenarios.

[0041] More specifically, step S1 can be intermittent or continuous monitoring of data access behavior, which is actually monitoring and recording a data access behavior or a data access behavior within a continuous period of time performed by the corresponding scenario carrier (such as an electronic computer), and collecting the original access features of the corresponding access behavior, and then processing these original access features to extract data access features that meet the usage requirements of the cache mechanism prediction model.

[0042] More specifically, the original access feature is the characteristic data attached to the data access behavior that can be directly obtained during the monitoring process, mainly including one or more of the access frequency feature, access time feature, access interval feature, data size feature, access source feature, and access pattern feature. The type and quantity of the characteristic data contained therein are consistent with the type and quantity of the characteristic data contained in the data access feature used by the subsequent cache mechanism prediction model; both the original access feature and the data access feature reflect the access method and access characteristics of each data item during the monitoring period, among which, in the original access feature, the access frequency feature represents the number of times each data item in the corresponding data access behavior is accessed within a certain time window (preset duration), the access time feature represents the access time point of the corresponding data access behavior, the access interval feature represents the time interval between two accesses to the same data item in the corresponding data access behavior, the data size feature represents the size of each data item in the corresponding data access behavior (such as the number of bytes), the access source feature represents the source of the access request of the corresponding data access behavior (such as IP address or user IP), and the access pattern feature represents the spatiotemporal pattern of access in the corresponding data access behavior (such as concentrated access or peak access).

[0043] It should be noted that, in some other implementations, the original access characteristics may also include cache status characteristics, which characterize the cache status (such as hit or miss) of the data item corresponding to the data access behavior under the current cache mechanism, and can be used as a judgment indicator for subsequent real-time evaluation or monitoring of the pros and cons of the current cache strategy.

[0044] More specifically, data access features are input data that can be matched to machine learning models (i.e., cache mechanism prediction models) after feature engineering (extraction and / or conversion) based on original access features. Therefore, frequency features characterize the access frequency of each data item in different time windows, time features are time data standardized based on access time features, interval features are statistical features (such as mean and standard deviation) obtained based on access interval feature statistics, size features are data sizes standardized based on data size features, source features are data features encoded based on access source features, and pattern features are statistical features obtained based on access pattern statistics.

[0045] It should be noted that the above data items all refer to the data items accessed in the corresponding data access behavior.

[0046] More specifically, it is well known that for data access behaviors with different access characteristics, using a suitable cache mechanism for data caching can effectively maintain high resource utilization and reduce workload. The data access characteristics obtained in step S1 can reflect the access characteristics of the current data access behavior, and the changes in the access characteristics of the data access behavior generally have regularities. Therefore, the adaptive adjustment method of the cache mechanism of the embodiment of the present application predicts the cache strategy of the next stage based on the data access characteristics currently obtained by monitoring, so as to adjust the cache mechanism, so that the cache mechanism can dynamically match the access characteristics of the data access behavior for adjustment, so that the data access behavior in the corresponding scenario can be adjusted under high resource utilization, low workload, and high The cache mechanism prediction model is a pre-trained machine learning model (various existing decision models can be used). In the embodiment of the present application, the cache strategy can be output according to the current input data access characteristics. The cache strategy is a cache strategy that can be adapted to the current data access behavior, or it can be a cache strategy that is adapted to the data access behavior in the next stage. The difference lies in the difference in the label data used in the training process. In the embodiment of the present application, the latter is preferred, so that the adaptive adjustment method of the cache mechanism of the embodiment of the present application can match the access characteristics of the data access behavior in advance to adaptively and dynamically adjust the cache mechanism to meet data access requirements and improve data hit rate.

[0047] More specifically, the cache mechanism prediction model can be a single machine learning model or a fusion model composed of multiple machine learning models.

[0048] More specifically, the cache strategy generated in step S2 may also include a mechanism strategy of other types of cache mechanisms (such as random replacement, second chance, etc.) and a corresponding hybrid mechanism strategy, which is mainly determined by the type of label data used in the process of training the cache mechanism prediction model. LFU, LRU, and FIFO are commonly used cache elimination strategies in web scenarios. Therefore, the adaptive adjustment method of the cache mechanism in the embodiment of the present application limits the cache strategy to a mechanism strategy including LFU, LRU, and FIFO, or a hybrid mechanism strategy of more than two. The cache strategy can be represented based on a predetermined strategy number, that is, the cache mechanism prediction model outputs the corresponding strategy number, and determines the specific cache strategy in combination with a mapping table composed of a pre-established strategy number and a strategy. The corresponding cache strategy can also be generated based on the output of the proportion of LFU, LRU, and FIFO. For example, if the output is: LFU: 100%, LRU: 0%, FIFO: 0%, it means that the generated cache strategy is a single LFU strategy.

[0049] More specifically, LFU, LRU, and FIFO each have different application scenarios and advantages and disadvantages. These strategies are used to manage data in the cache so that when the cache reaches its capacity limit, it can decide which data should be removed to make room. Among them, the LFU (Least Frequently Used) strategy mainly decides which data should be removed based on the access frequency of the data. It believes that the data with the lowest access frequency has the lowest possibility of being accessed again in the future, so it should be removed first. The LRU (Least Recently Used) strategy mainly decides which data should be removed based on the usage time of the data. It believes that the data that has been least recently used has the lowest possibility of being accessed again in the future, so it should be removed first. The FIFO (First In First Out) strategy The first-in, first-out (FIFO) strategy mainly decides which data should be removed based on the time when the data enters the cache. It believes that the data that enters the cache earliest is least likely to be accessed again in the future, and therefore should be removed first. Therefore, these different single mechanism strategies are applicable to data access behaviors with different access characteristics; and the mixed mechanism strategy is used to divide the cache space into sub-cache spaces managed by different types of single cache mechanisms, so that the data cached in different sub-cache spaces can be updated based on the corresponding cache mechanism.

[0050] More specifically, step S3 is a process of adjusting the cache mechanism adopted by the cache space based on the cache strategy output by the cache mechanism prediction model. In some embodiments, the cache space may be configured with a flag bit for indicating the type of cache mechanism currently adopted by the cache space. Step S3 can complete the adjustment of the cache mechanism by changing the flag value of the flag bit. In other embodiments, the cache space may be divided into multiple sub-cache spaces in advance, and each sub-cache space is configured with a flag bit for indicating the type of cache mechanism currently adopted by the corresponding sub-cache space. Step S3 can complete the adjustment of the cache mechanism by changing the flag value of these flag bits, and realize the free combination of hybrid mechanism strategies.

[0051] More specifically, step S3 can be to directly adjust the cache mechanism, or to adjust the cache mechanism after a delay, wherein the delay duration of the delay adjustment processing method is determined based on the timing relationship between the data access characteristics and label data used for training the cache mechanism prediction model, so that the cache mechanism adjusted in step S3 can be applicable to the data access behavior at the corresponding time node.

[0052] It should be noted that the timing starting point of the delay duration is determined based on the time node when the data access behavior monitored in step S1 is generated.

[0053] The adaptive adjustment method of the cache mechanism in the embodiment of the present application is based on a machine learning method to predict and obtain a cache strategy according to data access behavior, so as to dynamically adjust the cache mechanism adopted by the cache space based on the cache strategy, so that the cache mechanism currently adopted by the cache space is suitable for the current data access behavior, which can effectively improve the data hit rate, improve the data response speed, and achieve the best cache effect; secondly, the cache strategy includes more than two hybrid mechanism strategies of LFU, LRU, and FIFO, which can effectively meet the complex and changeable access requirements of high-concurrency web scenarios.

[0054] In some preferred embodiments, the data access characteristics include frequency characteristics, time characteristics, interval characteristics, size characteristics, source characteristics and pattern characteristics.

[0055] Specifically, in this embodiment, the data access characteristics include all of the above characteristics, and the corresponding data access characteristics used for training the cache mechanism prediction model also include the above characteristics, so that the cache mechanism prediction model can more accurately focus on the access characteristics or changes in data access behavior to make more effective cache strategies.

[0056] More specifically, in an embodiment of the present application, the cache mechanism prediction model can adopt a graph attention network. Different features in the data access features belong to feature nodes in the graph attention network, which can adjust the data type in the data access features according to the attention score of the corresponding feature node (characterizing the strength of association with the cache strategy). Therefore, in other implementations, the data access features can also add more types of features according to usage requirements, and optimize the cache mechanism prediction model to enable the cache mechanism prediction model to make a more effective cache strategy.

[0057] In some preferred embodiments, the training process of the cache mechanism prediction model includes:

[0058] A1. Collect a training data set and a corresponding label data set, where the elements in the training data set are data access features, and the elements in the label data set are cache strategies that match the data access features;

[0059] A2. Train a machine learning model based on the data access features of the training data set and the cache strategy in the label data set that matches the data access features at the next moment of the data access features to obtain a cache mechanism prediction model.

[0060] Specifically, the elements in the training data set are data access features, that is, the type of data access features monitored and acquired in step S1 is completely consistent, and they are also obtained through feature engineering processing. In an embodiment of the present application, the feature engineering processing is implemented based on a pre-established feature extraction converter, that is, the data access features extracted in step S1 and the data access features in the training data set collected in step A1 are both obtained by processing the corresponding input raw data based on the feature extraction converter.

[0061] More specifically, the elements in the label data set are label data that represent cache strategies that match the data access characteristics. These label data are applicable cache strategies that are manually determined based on the data access characteristics, so that the trained cache mechanism prediction model can generate appropriate cache strategies according to the data access characteristics; wherein, if the timing of the elements in the training data set used to train the cache mechanism prediction model corresponds to the timing of the elements in the label data set, the cache mechanism prediction model can generate a corresponding matching cache strategy according to the current data access characteristics; if the timing of the elements in the training data set used to train the cache mechanism prediction model is staggered with the timing of the elements in the label data set, and the timing of the elements in the label data set matches the future moment of the elements in the training data set, such as based on x i and i+1 (where x i is the data access feature at time i, y i+1 If the cache mechanism prediction model is trained in a manner that matches the cache strategy at time i+1), the cache mechanism prediction model can generate a cache strategy for future matching based on the current data access characteristics, that is, the cache strategy prediction is realized so as to adaptively adjust the cache mechanism in advance; if the process of training the cache mechanism prediction model is to train based on the elements in the training data set at multiple consecutive moments and the label data at the next moment, the cache mechanism prediction model can predict and generate a cache strategy for future matching based on the data change characteristics between the current data access characteristics and the previous data access characteristics.

[0062] In some preferred embodiments, the training process of the cache mechanism prediction model further includes the following steps performed after step A2:

[0063] A3. Verify the performance of the cache mechanism prediction model based on evaluation indicators.

[0064] Specifically, the evaluation indicators include one or more of accuracy, recall, and F1 score; the cache mechanism prediction model can be used normally only after passing the verification of step A3, otherwise it needs to continue training.

[0065] In some preferred embodiments, the training process of the cache mechanism prediction model further includes the following steps performed after step A3:

[0066] A4. Verify the performance indicators of the cache strategy generated by the cache mechanism prediction model based on simulation tests.

[0067] Specifically, the performance indicator characterizes the performance of the cache space after executing the corresponding cache strategy (adjusting the cache mechanism), and can be used to measure the adaptability of the currently used cache mechanism to the current data access behavior. If the performance indicator of the cache strategy in the simulation test is lower than expected, it may be due to the insufficient accuracy of the labeled data set. It is necessary to manually design a new labeled data set to retrain the cache mechanism prediction model so that the cache mechanism prediction model can generate a cache strategy with performance indicators that meet the usage requirements, and can also indirectly verify the validity of the labeled data set.

[0068] In some preferred implementations, the performance indicators include one or more of cache hit rate, average response time, and system load.

[0069] Specifically, the cache hit rate is used to measure the effectiveness of the cache strategy, which is generally the ratio of the number of cache hits to the total number of cache accesses; the average response time is used to measure the response performance of the system after executing the cache strategy; the system load reflects the load of the server in processing requests, which is usually measured by indicators such as CPU utilization and memory utilization; the process of verifying performance indicators is to determine whether the actual performance indicators meet the corresponding preset indicator values, such as setting the cache hit rate to more than 80%, the average response time to less than 60ms, and the system load to meet the CPU utilization rate below 60% and the memory utilization rate below 70%.

[0070] In some preferred implementations, step S1 is performed continuously in real time, or is triggered when a performance indicator of the current cache mechanism does not meet a preset indicator value.

[0071] Specifically, the implementation of the continuous step S1 can enable the adaptive adjustment method of the cache mechanism of the embodiment of the present application to dynamically adjust the cache mechanism in real time and continuously, and can always ensure the effectiveness of the cache mechanism, but it needs to consume more adjustment processing resources; the latter trigger adjustment method can effectively balance the effectiveness of the cache mechanism and the adjustment processing resources; among them, the latter trigger method makes judgments through continuous monitoring or periodic monitoring of the performance indicators of the cache mechanism, and the periodic monitoring method can further save monitoring resources.

[0072] In some preferred implementations, the performance indicators are paired with different preset indicator values ​​in different usage periods.

[0073] Specifically, under normal circumstances, a system using the adaptive adjustment method of the cache mechanism of the embodiment of the present application has different data access requirements at different time periods, that is, it generates data access frequencies that vary greatly. The amount of concurrent data access generated during peak hours (i.e., the time when there is a peak in access) is several times that of normal times, and the cache data in the cache space is updated more frequently. Therefore, it is necessary to design different preset indicator values ​​for performance indicators according to different time periods so that the corresponding system can more effectively adjust the cache mechanism; among which, since the preset indicator values ​​designed for peak hours are more stringent than the preset indicator values ​​for normal hours, the cache mechanism can be maintained within a higher effectiveness range during peak hours, so as to complete data access tasks more efficiently and with lower consumption, such as the preset indicators for peak hours. The values ​​are designed to be: cache hit rate 90%, average response time 40ms, CPU utilization 50%, and memory utilization 60%. The adaptive adjustment method of the cache mechanism in the embodiment of the present application triggers the adjustment of the cache mechanism when any of the conditions of "cache hit rate lower than 90%, average response time higher than 40ms, CPU utilization higher than 50%, and memory utilization higher than 60%" are met. Relatively speaking, the preset indicator values ​​for normal time periods can be designed to be: cache hit rate 85%, average response time 50ms, CPU utilization 30%, and memory utilization 50%; during normal time periods, the system has a large amount of redundant processing resources, so there is no need to frequently adjust the cache mechanism, and it is only necessary to ensure that the effectiveness of the cache mechanism is within a reasonable range.

[0074] In some preferred implementations, the hybrid mechanism strategy includes the proportions of different cache mechanisms.

[0075] Specifically, based on the foregoing content, it can be known that the hybrid mechanism strategy is to divide the cache space into sub-cache spaces managed based on different types of cache strategies. Therefore, the sum of the proportions of each cache mechanism in the hybrid mechanism strategy is 1.

[0076] More specifically, the adjustment process of step S3 is actually a process of allocating cache strategies for different areas of the cache space based on the above-mentioned proportions, which can generate a special cache space that is different from the traditional single cache mechanism. Among them, the sub-cache space managed based on different types of cache strategies can execute the corresponding cache strategy to update data, so that the overall cache space has the advantages of various cache strategies at the same time, which can meet the frequent and changing access requirements, and is especially suitable for use during peak hours to meet the requirements of high concurrent access.

[0077] Second, please refer to Figure 2 Some embodiments of the present application further provide an adaptive adjustment device for a cache mechanism, which is used to adjust the cache mechanism. The device includes:

[0078] The acquisition module 201 is used to monitor data access behavior and extract corresponding data access features, where the data access features include one or more of frequency features, time features, interval features, size features, source features, and pattern features;

[0079] A strategy module 202, configured to generate a cache strategy according to data access characteristics based on a pre-trained cache mechanism prediction model, wherein the cache strategy includes one of LFU, LRU, and FIFO, or a hybrid mechanism strategy of two or more, wherein the hybrid mechanism strategy is used to divide the cache space into sub-cache spaces managed by a single cache mechanism of different types;

[0080] The adjustment module 203 is used to adjust the cache mechanism according to the cache strategy.

[0081] The adaptive adjustment device of the cache mechanism in the embodiment of the present application predicts and obtains the cache strategy based on the data access behavior based on the machine learning method, so as to dynamically adjust the cache mechanism adopted by the cache space based on the cache strategy, so that the cache mechanism currently adopted by the cache space is suitable for the current data access behavior, which can effectively improve the data hit rate, improve the data response speed, and achieve the best cache effect; secondly, the cache strategy includes more than two hybrid mechanism strategies of LFU, LRU, and FIFO, which can effectively meet the complex and changeable access requirements of high-concurrency web scenarios.

[0082] In some preferred implementations, the adaptive adjustment device of the cache mechanism of the embodiment of the present application is used to execute the adaptive adjustment method of the cache mechanism provided in the first aspect above.

[0083] Third, please refer to Figure 3 Some embodiments of the present application also provide a structural diagram of an electronic device. The present application provides an electronic device, including: a processor 301 and a memory 302. The processor 301 and the memory 302 are interconnected and communicate with each other through a communication bus 303 and / or other forms of connection mechanisms (not marked). The memory 302 stores computer-readable instructions executable by the processor 301. When the electronic device is running, the processor 301 executes the computer-readable instructions to execute the method in any optional implementation of the above embodiments.

[0084] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method in any optional implementation of the above embodiment is executed. The computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, 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, disk or optical disk.

[0085] In summary, the embodiments of the present application provide a method, device, electronic device and storage medium for adaptively adjusting a cache mechanism. The method for adaptively adjusting the cache mechanism of the embodiments of the present application predicts and obtains a cache strategy based on data access behavior based on a machine learning method, so as to dynamically adjust the cache mechanism adopted by the cache space based on the cache strategy, so that the cache mechanism currently adopted by the cache space is suitable for the current data access behavior, which can effectively improve the data hit rate, improve the data response speed, and achieve the best cache effect; secondly, the cache strategy includes two or more hybrid mechanism strategies of LFU, LRU, and FIFO, which can effectively meet the complex and changeable access requirements of high-concurrency web scenarios.

[0086] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0087] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0088] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0089] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0090] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for adaptively adjusting a cache mechanism, for adjusting a cache mechanism, characterized in that: The method comprises the following steps: S1. Monitor data access behavior and extract corresponding data access features, where the data access features include one or more of frequency features, time features, interval features, size features, source features, and pattern features; S2. Generate a cache strategy based on the data access feature based on a pre-trained cache mechanism prediction model, wherein the cache strategy includes a hybrid mechanism strategy of two or more of LFU, LRU, and FIFO, and the hybrid mechanism strategy is used to divide the cache space into sub-cache spaces managed by a single cache mechanism of different types, and the hybrid mechanism strategy includes the proportion of different cache mechanisms, and the cache mechanism prediction model generates a corresponding cache strategy based on the proportion of output LFU, LRU, and FIFO; S3, adjusting the cache mechanism according to the cache strategy; Among them, step S1 is triggered when the performance index of the current cache mechanism does not meet the preset index value. The performance index has different preset index values ​​in different usage periods. The preset index values ​​in the peak period are designed as follows: cache hit rate 90%, average response time 40ms, CPU usage 50%, memory usage 60%, and the preset index values ​​in the normal period are designed as follows: cache hit rate 85%, average response time 50ms, CPU usage 30%, memory usage 50%; The training process of the cache mechanism prediction model includes: A1. Collect a training data set and a corresponding label data set, where the elements in the training data set are data access features, and the elements in the label data set are cache strategies that match the data access features; A2. Train a machine learning model based on the data access features of the training data set and the cache strategy in the label data set that matches the data access features at the next moment of the data access features to obtain the cache mechanism prediction model.

2. The method for adaptively adjusting the cache mechanism according to claim 1, characterized in that: The data access characteristics include frequency characteristics, time characteristics, interval characteristics, size characteristics, source characteristics and pattern characteristics.

3. The method for adaptively adjusting the cache mechanism according to claim 1, characterized in that: The training process of the cache mechanism prediction model further includes the following steps performed after step A2: A3. Verify the performance of the cache mechanism prediction model based on evaluation indicators.

4. An adaptive adjustment device for a cache mechanism, used for adjusting a cache mechanism, characterized in that: The device comprises: A collection module, used to monitor data access behavior and extract corresponding data access features, wherein the data access features include one or more of frequency features, time features, interval features, size features, source features and pattern features; A strategy module, used to generate a cache strategy according to the data access characteristics based on a pre-trained cache mechanism prediction model, wherein the cache strategy includes a hybrid mechanism strategy of two or more of LFU, LRU, and FIFO, wherein the hybrid mechanism strategy is used to divide the cache space into sub-cache spaces managed by a single cache mechanism of different types, wherein the hybrid mechanism strategy includes a proportion of different cache mechanisms, and the cache mechanism prediction model generates a corresponding cache strategy based on the proportion of output LFU, LRU, and FIFO; An adjustment module, used for adjusting the cache mechanism according to the cache strategy; The step of monitoring data access behavior and extracting corresponding data access features is triggered when the performance index of the current cache mechanism does not meet the preset index value. The performance index is paired with different preset index values ​​in different usage periods. The preset index values ​​in peak periods are designed as follows: cache hit rate 90%, average response time 40ms, CPU usage 50%, memory usage 60%, and the preset index values ​​in normal periods are designed as follows: cache hit rate 85%, average response time 50ms, CPU usage 30%, memory usage 50%; The training process of the cache mechanism prediction model includes: A1. Collect a training data set and a corresponding label data set, where the elements in the training data set are data access features, and the elements in the label data set are cache strategies that match the data access features; A2. Train a machine learning model based on the data access features of the training data set and the cache strategy in the label data set that matches the data access features at the next moment of the data access features to obtain the cache mechanism prediction model.

5. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the steps in the method according to any one of claims 1 to 3 are executed.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are executed.

Citation Information

Patent Citations

  • Management system and method for cache replacement strategy

    CN101866318A

  • Data caching method, device and apparatus, and storage medium

    CN109324761A

  • Data caching method, device and equipment and computer readable storage medium

    CN114764416A

  • Dynamic caching method and device based on deep learning, equipment and medium

    CN116684491A