Method and device for adaptively scattering cache expiration duration

By monitoring the load rate and cache hit rate of distributed systems in real time, and dynamically adjusting the breaking range of cache expiration time, the problem that the fixed breaking strategy in the existing technology cannot adapt to system changes, and improves system stability and cache efficiency.

CN119988249APending Publication Date: 2025-05-13BEIJING IQIYI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510165921.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-14
Publication Date
2025-05-13

AI Technical Summary

Technical Problem

The fixed breaking strategy in the prior art cannot adapt to changes in system load and access mode, resulting in inefficient cache efficiency, increased back-end service pressure, or frequent cache updates under low load conditions, wasted resources.

Method used

By obtaining the system load rate and cache hit rate of the distributed system in real time, the preset breaking model is used to dynamically adjust the breaking range of the cache expiration time to determine the final expiration time.

Benefits of technology

The cache expiration time and system status are matched, avoiding the problems of centralized cache expiration under high load and frequent cache updates under low load, and improving system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119988249A_ABST
    Figure CN119988249A_ABST
Patent Text Reader

Abstract

The invention provides a method and a device for adaptively scattering cache expiration duration. The method comprises the following steps: acquiring a current system load rate and a cache hit rate from a distributed system; the system load rate and the cache hit rate are processed through a preset scattering model, the scattering range of the cache expiration duration is determined, and the scattering range is a dynamic time interval; when it is detected that the cache data is written into the cache, the basic expiration duration of the cache data is determined; and increasing the scattering range on the basis of the basic expiration duration to obtain the final expiration duration of the cached data. The stability of the system can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of distributed systems, and in particular to a method and device for adaptively breaking up cache expiration time. Background Art

[0002] In distributed systems, cache technology is widely used to improve performance and reduce the access pressure on backend services. The design of cache expiration strategy is an important part of the cache system, which directly affects the performance and stability of the system. For example, in the bullet comment scene, especially the bullet comment of a new hot drama, there are a lot of concurrent requests, and cache is needed to ensure the service experience.

[0003] The cache system in the prior art usually adopts a fixed time scattering strategy, such as simply extending or shortening the cache expiration time through random numbers or predefined rules, in order to avoid the concentrated expiration of the cache (Cache Stampede) causing a surge in instantaneous pressure on the system. However, this fixed scattering range cannot adapt to changes in system load and access patterns. In certain cases of high load or uneven access distribution, the fixed scattering range may lead to inefficient cache and increase the pressure on backend services; in low load conditions, fixed scattering may lead to frequent cache updates and waste computing and storage resources. Therefore, the current fixed scattering strategy has the problem of affecting system stability. Summary of the invention

[0004] In order to solve the above technical problem or at least partially solve the above technical problem, the present application provides a method and device for adaptively breaking up cache expiration time.

[0005] In a first aspect, the present application provides a method for adaptively breaking up cache expiration time, the method comprising:

[0006] Get the current system load rate and cache hit rate from the distributed system;

[0007] The system load rate and the cache hit rate are processed by a preset scattering model to determine a scattering range of the cache expiration time, wherein the scattering range is a dynamic time interval;

[0008] When detecting that cache data is written into the cache, determining a basic expiration time of the cache data;

[0009] The scatter range is increased on the basis of the basic expiration time to obtain a final expiration time of the cached data.

[0010] Optionally, processing the system load rate and the cache hit rate by using a preset scattering model includes:

[0011] Determining the service priority of the cached data according to the data access frequency of the cached data, wherein the higher the data access frequency, the higher the service priority;

[0012] The system load rate, the cache hit rate and the service priority are processed by a preset scattering model to determine a scattering range of the cache expiration time.

[0013] Optionally, the system load rate, the cache hit rate, and the service priority are processed by a preset scattering model to determine a scattering range of the cache expiration time, including:

[0014] Get the preset maximum and minimum scatter range;

[0015] Calculating a system state weight according to the system load rate, the cache hit rate, the service priority and the set adjustment parameters, wherein the system state weight is used to indicate the current stress level of the system;

[0016] The dispersal range is determined according to the maximum dispersal range, the minimum dispersal range and the system state weight.

[0017] Optionally, the formula for calculating the system state weight is:

[0018] W=αL+β(1-H)+λD, where W is the system state weight, α, β, and λ are adjustment parameters, L is the system load, H is the cache hit rate, and D is the service priority.

[0019] Optionally, the formula for calculating the breakup range is:

[0020] R=Rmin+(Rmax-Rmin)*W, where R is the dispersion range, Rmin is the minimum dispersion range, Rmax is the maximum dispersion range, and W is the system state weight.

[0021] Optionally, the method further comprises:

[0022] When the system load is greater than a set load threshold, increasing the scattering range to disperse the expired data;

[0023] When the cache hit rate is less than a set hit rate threshold, the scatter range is reduced to reduce the cache update frequency.

[0024] Optionally, the service priority of the cached data is divided into hot data, ordinary data and long-tail data. Under the condition of the same system load and the same cache hit rate, the scattering ranges corresponding to the hot data, the ordinary data and the long-tail data decrease in sequence.

[0025] In a second aspect, the present application provides a device for adaptively breaking up cache expiration time, the device comprising:

[0026] The acquisition module is used to obtain the current system load rate and cache hit rate from the distributed system;

[0027] A processing module, used to process the system load rate and the cache hit rate through a preset scattering model to determine a scattering range of the cache expiration time, wherein the scattering range is a dynamic time interval;

[0028] A determination module, configured to determine a basic expiration time of the cached data when detecting that the cached data is written into the cache;

[0029] The obtaining module is used to increase the scattering range based on the basic expiration time to obtain the final expiration time of the cached data.

[0030] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0031] Memory, used to store computer programs;

[0032] The processor is used to implement any of the method steps for adaptively breaking up the cache expiration time when executing a program stored in the memory.

[0033] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps of any of the methods for adaptively breaking up the cache expiration period are implemented.

[0034] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:

[0035] The method provided in the embodiment of the present application dynamically adjusts the scattering range through the real-time system load rate and cache hit rate, and then adds the scattering range to the basic expiration time to obtain the final expiration time. The present application dynamically and adaptively adjusts the scattering range to ensure that the set final expiration time matches the system state, avoiding the problem of concentrated expiration of system resources at the same time point under high load and frequent cache updates under low load. The present application can improve the stability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0038] Figure 1 A flowchart of a method for adaptively breaking up cache expiration time provided in an embodiment of the present application;

[0039] Figure 2 A schematic diagram of a system for adaptively breaking up cache expiration time provided in an embodiment of the present application;

[0040] Figure 3 A schematic diagram of the structure of a device for adaptively breaking up cache expiration time provided in an embodiment of the present application;

[0041] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution 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 part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0043] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present application and have no specific meaning. Therefore, "module" and "component" can be used interchangeably.

[0044] In order to solve the problem mentioned in the background technology, according to one aspect of an embodiment of the present application, an embodiment of a method for adaptively breaking up cache expiration time is provided.

[0045] In an embodiment of the present application, the above-mentioned method of adaptively breaking up the cache expiration period can be applied to server nodes in a distributed system to improve system stability.

[0046] The following will be combined with a specific implementation method to provide a method for adaptively breaking up the cache expiration time provided by the embodiment of the present application in detail. Figure 1 As shown, the specific steps are as follows:

[0047] Step 101: Obtain the current system load rate and cache hit rate from the distributed system;

[0048] Step 102: Process the system load rate and cache hit rate through a preset scattering model to determine a scattering range of the cache expiration time, wherein the scattering range is a dynamic time interval;

[0049] Step 103: when it is detected that the cache data is written into the cache, determining the basic expiration time of the cache data;

[0050] Step 104: Add the scattered range on the basis of the basic expiration time to obtain the final expiration time of the cached data.

[0051] The present application provides a method for adaptively breaking up cache expiration time, which aims to monitor the system load rate and cache hit rate in real time, determine a dynamic time interval (breaking up range) based on a preset breaking up model, so that the final expiration time matches the system load.

[0052] The application scenarios of this application include but are not limited to: product data caching in e-commerce websites, user comment caching in social platforms, barrage caching in videos, popular video caching, etc.

[0053] The system collects the system load rate and cache hit rate of each node in real time through monitoring tools or built-in interfaces, and then processes the system load rate and cache hit rate through a scattering model to calculate a dynamic scattering range R, where the scattering model is a preset algorithm or rule set. The system sets a fixed basic expiration time TTL (TimeToLive, the length of time a cached data item or network data packet survives in the system) for cached data based on business needs, data importance, and access frequency, and provides a reasonable expiration time basis for each cached data item to ensure that the data will not remain in the cache for a long time. For example, the TTL of static resources may be set to 60 seconds, while the TTL of dynamic content may be set to 5 minutes. Finally, based on the basic expiration time, a random increment or decrement within the scattering range R is generated and added to the basic expiration time to obtain the final expiration time.

[0054] Optionally, the system load rate indicates the usage ratio of current system resources (such as CPU, memory, disk I / O, etc.). For example, if the CPU usage rate is 80%, the system load rate is 80%.

[0055] Optionally, the cache hit rate indicates the proportion of requested data found in the cache. For example, if 80 out of 100 requests directly obtain data from the cache, the cache hit rate is 80%.

[0056] Optionally, the basic expiration time TTL represents the time interval from when the data item is written into the cache or the data packet enters the network to when it is considered invalid or needs to be updated.

[0057] For example, the base TTL of static resources (such as pictures and description text) on the product details page is set to 60 seconds. The scatter range R is dynamically adjusted according to the current system load and cache hit rate. If the system load is high, the scatter range R is set to ±20 seconds; if the system load is low, the scatter range R is set to ±5 seconds. For high load conditions, the actual TTL may vary randomly between 40 and 80 seconds; for low load conditions, the actual TTL may vary randomly between 55 and 65 seconds.

[0058] This application dynamically adjusts the scatter range through the real-time system load rate and cache hit rate, and then adds the scatter range to the basic expiration time to obtain the final expiration time. This application dynamically and adaptively adjusts the scatter range to ensure that the set final expiration time matches the system status, avoiding the problem of concentrated expiration of system resources at the same time point under high load and frequent cache updates under low load. This application can improve the stability of the system.

[0059] Among them, when the system load is greater than the set load threshold, the scattering range is increased to disperse the expired traffic; when the cache hit rate is less than the set hit rate threshold, the scattering range is reduced to improve the cache hit rate.

[0060] When the system load is high, it means that the current computing resources (such as CPU, memory, disk I / O, etc.) have approached or reached the limit of their processing capacity. Assuming that all data items expire at the same time, a large number of update requests will arrive at the same time, further increasing the burden on the system. Increasing R means providing a wider time interval, which can disperse these update requests to different time points, reducing the number of requests that need to be processed at a certain moment, thereby avoiding a large number of data items from expiring at the same time point, avoiding instantaneous peak loads on system resources, and alleviating instantaneous pressure on the system, thereby improving system cache efficiency.

[0061] For example, if the base TTL is 60 seconds, and the spread range R increases from ±5 seconds to ±20 seconds, the actual TTL may vary randomly between 40 and 80 seconds. This makes the expiration time more widely distributed and reduces the possibility of concentrated expiration.

[0062] When the cache hit rate is low, it means that most of the requested data is not in the cache, resulting in frequent access to the backend database or other source services. Reducing the scatter range R means a narrower time interval, which allows more data items to expire and be updated at similar time points, avoiding frequent cache updates, thereby reducing the waste of computing resources and reducing frequent access to the backend server.

[0063] For example, if the base TTL is 60 seconds and the range R is reduced from ±20 seconds to ±5 seconds, the actual TTL may vary randomly between 55 and 65 seconds. This makes the expiration time more concentrated, which helps to quickly update the cache content and improve the hit rate.

[0064] As an optional implementation, processing the system load rate and cache hit rate by using a preset scattering model includes the following steps:

[0065] Step S11: determining the service priority of the cached data according to the data access frequency of the cached data, wherein the higher the data access frequency, the higher the service priority;

[0066] Step S12: Process the system load rate, cache hit rate and service priority through a preset scattering model to determine a scattering range of the cache expiration time.

[0067] The frequency of data access to cached data is different, and its corresponding business priority is also different. Frequently accessed data is considered to be more critical business data and requires a higher priority. For example, the details page of hot products and user login information usually have a high access frequency, so their business priority is also higher. High-priority data items will receive more attention and support in system resource allocation and cache management to ensure that these data items can be updated in a timely manner and remain up-to-date.

[0068] The embodiment of the present application divides cache data into hot data, ordinary data and long-tail data according to the data access frequency. The specific contents of each type of data are as follows.

[0069] Hot data: data that is frequently accessed and requested. Usually, you need to set a shorter basic TTL and a smaller scatter range R to ensure that the data is updated in time and remains up to date.

[0070] Ordinary data: data with access frequency between hot data and long-tail data. Use a centered basic TTL and scattered range R to balance update frequency and resource consumption to ensure reasonable cache efficiency.

[0071] Long-tail data: data with low access frequency and rarely requested. You can set a longer basic TTL and a larger scatter range R to allow random distribution over a longer period of time and save cache resources.

[0072] This application monitors the system load rate and cache hit rate in real time, and dynamically adjusts the expiration time of the cached data items to break up the range R in combination with the business priority of the cached data.

[0073] This solution achieves adaptive cache expiration management by classifying cached data into hot data, ordinary data and long-tail data, and setting different scattering ranges R for them respectively. This application monitors the system load rate and cache hit rate in real time, and dynamically adjusts the expiration scattering range R of cached data items in combination with the business priority of cached data. This can not only effectively disperse the data expiration time and reduce the instantaneous pressure on the cache system, but also optimize the cache efficiency according to the characteristics of different types of data, thereby improving the performance and stability of the overall system.

[0074] As an optional implementation, in step S12, the system load rate, cache hit rate and service priority are processed by a preset scattering model, and the scattering range of the cache expiration time is determined to include the following contents:

[0075] Step S21: obtaining a preset maximum scattering range and a minimum scattering range;

[0076] Step S22: Calculate the system state weight according to the system load rate, cache hit rate, service priority and set adjustment parameters, wherein the system state weight is used to indicate the current pressure level of the system;

[0077] Step S23: Determine the dispersal range according to the maximum dispersal range, the minimum dispersal range and the system state weight.

[0078] The system reads the preset maximum scatter range Rmax and minimum scatter range Rmin from the configuration file or system parameters. The maximum scatter range Rmax defines the upper limit of the scatter range, indicating the maximum random increment or decrement allowed in the most extreme case (such as high load); the minimum scatter range nRmin defines the lower limit of the scatter range, indicating the minimum random increment or decrement allowed in the most ideal case (such as low load).

[0079] The system calculates the system status weight based on the system load rate, cache hit rate and business priority, combined with the set adjustment parameters. The formula for calculating the system status weight is:

[0080] W=αL+β(1-H)+λD, where W is the system state weight, α, β, and λ are adjustment parameters, L is the system load, H is the cache hit rate, and D is the service priority.

[0081] System load rate: reflects the current usage ratio of system resources. The higher the rate, the greater the system pressure.

[0082] Cache hit rate: indicates the proportion of requested data found in the cache. The lower the ratio, the worse the cache efficiency is and the system pressure may increase.

[0083] Business priority: Determined based on the frequency of access to cached data. The higher the priority, the more important the data is, requiring more attention and support.

[0084] Adjustment parameters: used to balance the impact of different factors on the system status weight. α, β and λ represent the weight coefficients of system load, cache hit rate and business priority respectively. Different system load levels correspond to different α values, different cache hit rate levels correspond to different β values, and different business priority levels correspond to different λ values. This makes the adjustment parameter values ​​more accurate.

[0085] Finally, the system calculates the final scatter range R based on the maximum scatter range Rmax, the minimum scatter range Rmin, and the system state weight W. The formula for calculating the scatter range R is:

[0086] R=Rmin+(Rmax-Rmin)*W, where R is the dispersion range, Rmin is the minimum dispersion range, Rmax is the maximum dispersion range, and W is the system state weight.

[0087] According to the formula, under high system pressure: when W is large (that is, the system pressure is high), increase R to make the expiration time of data items more dispersed and reduce instantaneous pressure. Under low system pressure: when W is small (that is, the system pressure is low), reduce R to make the expiration time of data items more concentrated and improve the effectiveness and hit rate of the cache.

[0088] The present application calculates the system status weight W by the system load rate, cache hit rate and business priority, accurately reflecting the current system pressure level, thereby increasing the scattering range R when the system pressure is high, and reducing the scattering range R when the system pressure is low. By dynamically adjusting the scattering range R, the expiration time is dispersed under high load conditions, reducing the pressure on the server. Under low load conditions, the expiration time is concentrated, the cache hit rate is increased, and resource utilization is further improved.

[0089] For example, in the adaptive scattering of distributed cache, the QPS (Queries PerSecond), memory usage and cache hit rate of the Redis cluster are collected, and then the scattering range of hot keys is dynamically adjusted based on the real-time load, and the final expiration time of long-tail keys is shortened.

[0090] For example, in the hot data cache scattering, the bullet screen cache of the hot videos needs to avoid being expired at the same time, so a larger scattering range Rhot=10% is set for the hot video cache, and the ordinary video cache range is Rdefault=5%.

[0091] In addition, the present application can collect and analyze historical data (including the changing trend of the system load rate, the historical records of the cache hit rate, the user access patterns and behavior characteristics, and the changes in business priorities in different time periods), identify which factors have the greatest impact on system performance, and find potential optimization points. Then, through the operating status of the current system (such as real-time load, cache hit rate changes, etc.), timely understand the current state of the system, capture any anomalies or changes, and immediately adjust the scatter range R. Finally, based on historical data and real-time feedback, use machine learning algorithms or other optimization techniques to dynamically adjust the parameters in the scatter model, such as: adjusting parameters α, β and λ, as well as the maximum scatter range Rmax and the minimum scatter range Rmin.

[0092] This application optimizes the scattering strategy through historical data and real-time feedback to achieve the following functions:

[0093] Under high load conditions: If historical data shows that the system load is high and the cache hit rate is low during a certain period of time, R can be appropriately increased to make the expiration time of data items more dispersed and reduce instantaneous pressure.

[0094] Under low load conditions: If real-time feedback shows that the current system load is low and the cache hit rate is high, R can be reduced to make the expiration time of data items more concentrated, thereby improving the effectiveness and hit rate of the cache.

[0095] Business priority adjustment: Based on historical data and real-time feedback, dynamically adjust the dispersion range R of data items with different business priorities to ensure that high-priority data items can be updated in a timely manner without affecting user experience.

[0096] Adaptability: The sharding strategy is optimized through historical data and real-time feedback to adapt it to different business scenarios, which means that the solution not only relies on past successful experiences and models, but also combines the real-time status of the current system to dynamically adjust the cache management strategy. This approach ensures that the system can always maintain optimal performance in different business environments and improves system flexibility and stability.

[0097] The embodiment of the present application also provides a schematic diagram of a system for adaptively breaking up cache expiration time. Figure 2 As shown, the device includes a data acquisition module, a scatter range calculation module, a cache expiration time setting module and an adaptive feedback module, and the functions of each module are as follows:

[0098] 1.Data acquisition module.

[0099] The following key indicators are collected in real time:

[0100] System load L: includes CPU usage, memory usage, disk I / O, and network traffic, etc., which is used to reflect the current system pressure.

[0101] Cache hit rate H: Evaluates cache usage efficiency through cache hit statistics.

[0102] Business priority D: Distinguish data with different business priorities (such as the weights of hot data and long-tail data). For example, the bullet commentary scene evaluates the priority of bullet commentary data based on the video's online time and current popularity.

[0103] 2. Break up the range calculation module.

[0104] According to the collected real-time data, the cache expiration time is calculated to break up the range R.

[0105] 2.1 Define the system state weight: W = αL + β(1-H) + λD.

[0106] Among them: α, β, λ are adjustment parameters used to balance system load, cache hit rate and business priority. The value range of W is [0,1], which indicates the current pressure level of the system.

[0107] 2.2 Dynamically adjust the dispersion range: dynamically adjust R according to the value of W.

[0108] R=Rmin+(Rmax-Rmin)*W,

[0109] Among them, Rmin and Rmax are the minimum and maximum values ​​of the scattered range respectively.

[0110] 3. Cache expiration time setting module.

[0111] When writing cache data, an expiration time is set for each cache item based on the calculated scattered range R.

[0112] Texpiry=Tbase±R,

[0113] Among them, Tbase is the basic expiration time, and Texpiry is the final expiration time.

[0114] 4. Adaptive feedback module.

[0115] Regularly (1 minute) analyze the following effects of the cache system: 1) changes in cache hit rate; 2) system load stability; 3) adaptability of data grouping strategy.

[0116] The beneficial effects achieved by this application are as follows:

[0117] 1. Dynamically adapt to system pressure. Adjust the scatter range R according to the real-time load and cache hit rate to avoid performance bottlenecks caused by fixed strategies.

[0118] 2. Improve cache efficiency. By optimizing the scattering strategy, reduce the occurrence of cache penetration and cache breakdown, and improve the cache hit rate.

[0119] 3. Reduce resource consumption. Reduce the scope of scattering under low load conditions, reduce the frequency of cache updates, and save computing and storage resources.

[0120] 4. Enhance system stability. Avoid instantaneous pressure surges caused by concentrated cache expiration and improve the system's ability to withstand pressure.

[0121] Based on the same technical concept, the embodiment of the present application also provides a device for adaptively breaking up the cache expiration time, such as Figure 3 As shown, the device comprises:

[0122] An acquisition module 301 is used to acquire the current system load rate and cache hit rate from the distributed system;

[0123] The processing module 302 is used to process the system load rate and the cache hit rate through a preset scattering model to determine a scattering range of the cache expiration time, wherein the scattering range is a dynamic time interval;

[0124] A determination module 303 is used to determine a basic expiration time of the cached data when it is detected that the cached data is written into the cache;

[0125] Obtaining module 304 is used to increase the scattered range based on the basic expiration time to obtain the final expiration time of the cached data.

[0126] Optionally, the processing module 302 is used to:

[0127] Determine the service priority of the cached data according to the data access frequency of the cached data, wherein the higher the data access frequency, the higher the service priority;

[0128] The system load rate, cache hit rate and business priority are processed through the preset scattering model to determine the scattering range of the cache expiration time.

[0129] Optionally, the processing module 302 is used to:

[0130] Get the preset maximum and minimum scatter range;

[0131] The system status weight is calculated based on the system load rate, cache hit rate, business priority and set adjustment parameters, where the system status weight is used to indicate the current pressure level of the system;

[0132] The dispersal range is determined according to the maximum dispersal range, the minimum dispersal range and the system state weight.

[0133] Optionally, the formula for calculating the system state weight is:

[0134] W=αL+β(1-H)+λD, where W is the system state weight, α, β, and λ are adjustment parameters, L is the system load, H is the cache hit rate, and D is the service priority.

[0135] Optionally, the formula for calculating the breakup range is:

[0136] R=Rmin+(Rmax-Rmin)*W, where R is the dispersion range, Rmin is the minimum dispersion range, Rmax is the maximum dispersion range, and W is the system state weight.

[0137] Optionally, the device is also used for:

[0138] When the system load is greater than the set load threshold, the scatter range is increased to disperse the expired data;

[0139] When the cache hit rate is less than the set hit rate threshold, the scatter range is reduced to reduce the cache update frequency.

[0140] Optionally, the service priority of cached data is divided into hot data, common data and long-tail data. Under the condition of the same system load and the same cache hit rate, the scattering ranges corresponding to hot data, common data and long-tail data decrease in sequence.

[0141] Based on the same technical concept, an embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it includes a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.

[0142] Memory 403, used for storing computer programs;

[0143] The processor 401 is used to implement the above steps when executing the program stored in the memory 403.

[0144] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0145] The communication interface is used for communication between the above electronic device and other devices.

[0146] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0147] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0148] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above methods are implemented.

[0149] In another embodiment of the present invention, a computer program product including instructions is provided, which enables the computer to execute any one of the methods in the above embodiments when the computer program product is executed on the computer.

[0150] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0151] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0152] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for adaptively breaking up cache expiration time, characterized in that: The method comprises: Get the current system load rate and cache hit rate from the distributed system; The system load rate and the cache hit rate are processed by a preset scattering model to determine a scattering range of the cache expiration time, wherein the scattering range is a dynamic time interval; When detecting that cache data is written into the cache, determining a basic expiration time of the cache data; The scatter range is increased on the basis of the basic expiration time to obtain a final expiration time of the cached data.

2. The method according to claim 1, characterized in that: Processing the system load rate and the cache hit rate by using a preset scattering model includes: Determining the service priority of the cached data according to the data access frequency of the cached data, wherein the higher the data access frequency, the higher the service priority; The system load rate, the cache hit rate and the service priority are processed by a preset scattering model to determine a scattering range of the cache expiration time.

3. The method according to claim 2, characterized in that The system load rate, the cache hit rate, and the service priority are processed by a preset scattering model to determine a scattering range of the cache expiration time, including: Get the preset maximum and minimum scatter range; Calculating a system state weight according to the system load rate, the cache hit rate, the service priority and the set adjustment parameters, wherein the system state weight is used to indicate the current stress level of the system; The dispersal range is determined according to the maximum dispersal range, the minimum dispersal range and the system state weight.

4. The method according to claim 3, characterized in that The formula for calculating the system state weight is: W=αL+β(1-H)+λD, where W is the system state weight, α, β, and λ are adjustment parameters, L is the system load, H is the cache hit rate, and D is the service priority.

5. The method according to claim 3, characterized in that: The formula for calculating the breakup range is: R=Rmin+(Rmax-Rmin)*W, where R is the dispersion range, Rmin is the minimum dispersion range, Rmax is the maximum dispersion range, and W is the system state weight.

6. The method according to claim 4, characterized in that The method further comprises: When the system load is greater than a set load threshold, increasing the scattering range to disperse the expired data; When the cache hit rate is less than a set hit rate threshold, the scatter range is reduced to reduce the cache update frequency.

7. The method according to claim 3, characterized in that The service priorities of the cached data are divided into hot data, ordinary data and long-tail data. Under the condition of the same system load and the same cache hit rate, the scattering ranges corresponding to the hot data, the ordinary data and the long-tail data decrease in sequence.

8. A device for adaptively breaking up cache expiration time, characterized in that: The device comprises: The acquisition module is used to obtain the current system load rate and cache hit rate from the distributed system; A processing module, used to process the system load rate and the cache hit rate through a preset scattering model to determine a scattering range of the cache expiration time, wherein the scattering range is a dynamic time interval; A determination module, configured to determine a basic expiration time of the cached data when detecting that the cached data is written into the cache; The obtaining module is used to increase the scattering range based on the basic expiration time to obtain the final expiration time of the cached data.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 7 are implemented.