Cache determination method and apparatus, and device and storage medium
By analyzing the business data reading requirements of the business interface, predicting the cache hit rate, determining the target cache duration, optimizing the cache performance, solving the reading bottleneck problem caused by database congestion in the business interface, and improving the efficiency of business data processing.
Patent Information
- Application Number
- PCT/CN2024/091933
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-09
- Filing Date
- 2024-05-09
- Publication Date
- 2024-11-14
Smart Images

Figure CN2024091933_14112024_PF_FP_ABST
Abstract
Description
Cache determination method, device, equipment and storage medium
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application is based on the Chinese application with application number 202310519966.5 and application date May 9, 2023, and claims its priority. The disclosed content of the Chinese application is hereby introduced as a whole into this application. Technical Field
[0003] The embodiments of the present application relate to the field of data processing technology, and in particular to a cache determination method, apparatus, device, and storage medium. Background Art
[0004] When a client executes a task, such as displaying various web pages, it typically requests the corresponding data from the server. As the scale of the business grows, multiple application programming interface (API) servers (for short) are typically developed on the server to serve as the corresponding business interfaces in order to efficiently process large amounts of business data.
[0005] When the client initiates a corresponding business request to the server, it will call a business interface in the server to search for the corresponding business data from the database (DataBase, referred to as DB) and send it to the client. As the business scale continues to grow, the business interface will receive more and more business requests, causing corresponding business congestion in the DB database. Therefore, by adding a corresponding cache library for each business interface between the business interface and the DB database, the business interface can cache a certain business data in the corresponding cache library after reading it from the DB database for the first time. Then, when the business interface receives a business request from the client, it can first obtain the corresponding business data from the corresponding cache library. If the business data is not cached in the cache library, it can then obtain the business data from the DB database, thereby reducing the business reading bottleneck caused by the business interface due to the congestion of the DB database's business volume.
[0006] Summary of the Invention
[0007] Embodiments of the present application provide a cache determination method, apparatus, device, and storage medium.
[0008] According to one aspect, an embodiment of the present application provides a cache determination method, the method comprising:
[0009] For each service interface, determining a set of candidate cache durations for the service interface;
[0010] Predicting a cache hit rate of the service interface under each candidate cache duration according to service request information in a target service period corresponding to each candidate cache duration in the candidate cache duration set;
[0011] A target cache duration of the service interface is determined according to a cache hit rate of the service interface under each candidate cache duration.
[0012] According to another aspect, an embodiment of the present application provides a cache determination device, the device comprising:
[0013] A candidate duration determination module, configured to determine, for each service interface, a set of candidate cache durations for the service interface;
[0014] a cache hit rate prediction module, configured to predict the cache hit rate of the service interface under each candidate cache duration according to service request information in a target service period corresponding to each candidate cache duration in the candidate cache duration set;
[0015] The cache determination module is used to determine the target cache duration of the service interface according to the cache hit rate of the service interface under each candidate cache duration.
[0016] According to another aspect, an embodiment of the present application provides an electronic device, including:
[0017] A processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the cache determination method provided in the first aspect of the present application.
[0018] According to another aspect, an embodiment of the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program enables a computer to execute the cache determination method provided in the first aspect of the present application.
[0019] According to another aspect, an embodiment of the present application provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the cache determination method provided in the first aspect of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0021] 1a and 1b are schematic diagrams showing the principles of a service request processing process according to an embodiment of the present application;
[0022] FIG2 is a flow chart of a cache determination method shown in an embodiment of the present application;
[0023] FIG3 is a schematic diagram showing the principles of online and offline processing of a service request according to an embodiment of the present application;
[0024] FIG4 is a flowchart of another cache determination method shown in an embodiment of the present application;
[0025] FIG5 is a functional block diagram of a cache determination device according to an embodiment of the present application;
[0026] FIG6 is a schematic block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0029] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or solution described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or solutions. Specifically, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0030] Considering that the client usually needs to initiate a service request to the server to obtain the corresponding service data in order to accurately execute the client service, before introducing the specific technical solution of this application, we first explain the specific service data acquisition process performed by each service interface after receiving a service request initiated by the client:
[0031] Before the business scale is expanded, the client initiates relatively few business requests to the server. Therefore, as shown in Figure 1a, when the client initiates a corresponding business request to the server, it calls a business interface on the server, which directly searches the database for the corresponding business data and sends it to the client.
[0032] As the business scale continues to grow, the business requests received by each business interface will increase, which will bring excessive pressure to the business data reading of the DB database, causing corresponding business congestion in the DB database.
[0033] At this time, in order to avoid the phenomenon that each business interface encounters a business reading bottleneck due to the business volume congestion of the DB database, as shown in Figure 1b, a corresponding cache library, such as a Redis database, can usually be added between each business interface and the DB database to form a cache layer. Then, when each business interface receives a business request from the client, it can first obtain the corresponding business data from the corresponding cache library. If the business data is not cached in the cache library, the business data is obtained from the DB database and cached in the corresponding cache library. Through the above-mentioned caching method, the business reading pressure of the business interface on the DB database can be reduced, and the corresponding cache library can share part of the business reading task, thereby avoiding the phenomenon that each business interface encounters a business reading bottleneck due to the business volume congestion of the DB database.
[0034] However, since each service interface carries different amounts of business data and types of business, the requirements for the cache library are also different. Therefore, in order to ensure that each service interface can achieve the optimal business reading efficiency, the embodiment of the present application designs a solution that can pre-evaluate the optimal cache performance that can be achieved after each service interface adds cache, thereby optimizing the cache hit rate of each service interface after adding cache, thereby improving the business reading efficiency of each service interface.
[0035] Next, the technical solution of this application is described in detail:
[0036] Figure 2 is a flow chart of a cache determination method shown in an embodiment of the present application. The method can be executed by the cache determination device provided in an embodiment of the present application, wherein the cache determination device can be implemented by any software and / or hardware. Exemplarily, the cache determination device can be applied to any electronic device, which may include but is not limited to tablet computers, mobile phones (such as foldable screen mobile phones, large screen mobile phones, etc.), wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), smart TVs, smart screens, high-definition TVs, 4K TVs, smart speakers, smart projectors and other devices. This application does not impose any restrictions on the specific types of electronic devices.
[0037] Specifically, as shown in FIG2 , the method may include the following steps:
[0038] S210: For each service interface, determine a candidate cache duration set for the service interface.
[0039] As client services continue to expand, the number of service requests initiated by clients to the server increases. Therefore, to ensure efficient and parallel processing of service requests, multiple service interfaces (API servers) are typically configured on the server. After initiating a service request to the server, the client can call a service interface to perform the corresponding service read operation.
[0040] To ensure that each service interface accurately distinguishes and executes various service requests, different service interfaces can be set to process different types of service data. For example, when a service request is used to request the live broadcast room's ranking data from the server, service interface 1 can be called, and service interface 1 will obtain the live broadcast room's ranking data and send it to the client; while when another service request is used to request the live broadcast room's gift list from the server, service interface 2 can be called, and service interface 2 will obtain the live broadcast room's gift data and send it to the client.
[0041] Each business interface, used to process different types of business data, handles a different amount of data, resulting in different processing performance requirements. Therefore, as business scale continues to expand and additional caching is needed to mitigate potential bottlenecks in business reads across each business interface, we can analyze each interface's data read caching requirements and add a suitable cache library to each interface, ensuring optimal caching performance.
[0042] Therefore, for each business interface configured on the server side, before adding a corresponding cache library for each business interface, this application first needs to evaluate in advance the optimal cache performance that the business interface can achieve, so as to determine whether the business reading efficiency of the business interface under the optimal cache performance is higher than the business reading efficiency before the cache library is added, so as to analyze whether each business interface needs to add a corresponding cache library.
[0043] In this application, by analyzing the cache requirements of each business interface when reading business data, the various cache durations that the cache library corresponding to the business interface can accept when caching the corresponding business data can be determined as the candidate cache durations of the business interface in this application, thereby forming a set of candidate cache durations for the business interface.
[0044] As an optional implementation scheme in the present application, for the candidate cache duration set of each business interface, the present application can be determined through the following steps: determining the acceptable cache upper limit of the business interface based on the business type to which the business interface is oriented; determining the candidate cache duration set of the business interface based on the acceptable cache upper limit of the business interface.
[0045] In other words, by analyzing the business type targeted by each business interface, we can determine the volume of business data and processing performance requirements that the business interface needs to process, thereby analyzing the cache requirements of the business interface when reading business data. Then, based on the cache requirements of each business interface when reading business data, we can determine the acceptable cache limit for each business interface when caching each business data. Furthermore, for each business interface, using a unit of time, we can enumerate multiple candidate cache durations that are less than the acceptable cache limit for the business interface, forming a set of candidate cache durations for the business interface.
[0046] For example, assuming that the acceptable cache upper limit of a certain service interface is k seconds and the unit time is 2 seconds, the candidate cache durations of the service interface may be {1s, 2s, 3s . . . , ks}.
[0047] S220 , predicting a cache hit rate of the service interface under each candidate cache duration according to service request information in a target service period corresponding to each candidate cache duration in the candidate cache duration set.
[0048] For each service interface, after determining the candidate cache durations for that service interface, different candidate cache durations will result in different cache performance for the added cache for that service interface. Therefore, this application requires pre-evaluating the cache performance that can be achieved by the service interface under various candidate cache durations before adding cache, so that a cache library that can achieve optimal cache performance can be added to the service interface.
[0049] In this application, the cache performance of the service interface can be represented by the cache hit rate. The cache hit rate can be the ratio of the number of service requests that can successfully obtain the corresponding service data from the added cache library to the total number of service requests received by the service interface per unit time.
[0050] Before adding cache to each business interface, the business interface accurately estimates the cache performance that can be achieved under various candidate cache durations. For each business request received, the business interface will directly obtain the business data corresponding to the business request from the DB database.
[0051] It is understandable that, assuming that a certain business interface has added a cache library with a certain candidate cache duration, then within a certain period of time represented by the candidate cache duration as the total duration, if the business data that needs to be read in the business request received by the business interface is read for the first time during the period, it means that the business interface needs to successfully obtain the business data from the DB database. If the business data that needs to be read in the business request received by the business interface is not read for the first time during the period, that is, a business request indicating the need to read the business data has been received during the period, it means that if the business interface has added a corresponding cache library, then the business data has been cached in the cache library during the period, so that the business interface can successfully obtain the business data from the cache library.
[0052] As can be seen from the above, for the cache performance that the service interface can achieve under each candidate cache duration, this application can divide each candidate cache duration into one or more target service periods, using each candidate cache duration as the total duration, from the entire service statistical period during which the client initiates the corresponding service request to the server. In other words, the total duration of the target service periods corresponding to each candidate cache duration is the candidate cache duration.
[0053] Then, for the target business period corresponding to each candidate cache duration, the present application can find out the business request information within the target business period. The business request information may include but is not limited to the interface path, summary information of the business request data and request time point of each business request received by all business interfaces within the target business period.
[0054] The interface path of the service request may be identification information of the service interface currently used to process the service request. The summary information of the service request data may be fixed-length signature information obtained by processing the service request data using a message digest algorithm. The message digest algorithm may include, but is not limited to, a message digest algorithm.
[0055] Then, the interface path of each business request can be used to determine whether the business request is the business request processed by the business interface currently analyzed by the cache; the summary information of the business request data that needs to be read specified by each business request can be used to determine whether the business request data is read repeatedly; and the request time point of each business request can be used to determine whether the business request is within the target business time period.
[0056] Therefore, for the target business period corresponding to each candidate cache duration of a certain business interface, by analyzing the interface path of each business request in the business request information within the target business period, the total number of business requests received by the business interface within the target business period can be determined. By analyzing the summary information of the business request data corresponding to each business request in the business request information within the target business period, it can be determined whether each business request is received for the first time by the business interface within the target business period, and the number of business requests for which business data is read for the first time by the business interface within the target business period can be determined. Among them, the business request for which business data is read for the first time requires the business interface to successfully read it from the DB database, which means that the business request has not been cached and hit by the business interface.
[0057] Therefore, according to the number of business requests for reading business data for the first time during the target business period corresponding to each candidate cache duration of the business interface and the total number of business requests received by the business interface during the target business period, the frequency of the business interface not being cached during the target business period corresponding to each candidate cache duration can be predicted. In this way, the frequency of the business interface being cached during the target business period corresponding to each candidate cache duration can be determined, and the cache hit rate of the business interface under each candidate cache duration can be obtained.
[0058] In some possible implementations, for business request information, in the entire online business process in which the client initiates a corresponding business request to the server, each business interface, when receiving a certain business request, can obtain the business data specified by the business request from the DB database and send it to the client, as shown in FIG3 . Moreover, for the business request that has been processed this time, the business interface can use an information summary algorithm to hash the business data obtained by the business request to obtain summary information of the business request data. Then, the interface path of the business request, the summary information of the business request data, and the request time point are written as a record into a pre-set message queue (Message Queue, abbreviated as MQ) to report each business request accordingly.
[0059] Furthermore, to ensure accurate offline analysis of business requests, during offline business processes, the MQ queue exports the business request information written into it to the Hive database at regular intervals. This application then uses the cache analysis system to read the business request information within the target business period corresponding to each candidate cache duration of the business interface from the Hive database to accurately estimate the cache performance that each business interface can achieve under each candidate cache duration.
[0060] The Hive table structure can be shown in Table 1 below:
[0061] Table 1
[0062] S230 : Determine a target cache duration of the service interface according to the cache hit rate of the service interface under each candidate cache duration.
[0063] In order to accurately estimate the optimal cache performance that each business interface can achieve after increasing the cache, for each business interface, after determining the cache hit rate of the business interface at each candidate cache duration, this application can judge the cache hit rate of the business interface at each candidate cache duration to determine the optimal cache performance that the business interface can achieve after increasing the cache.
[0064] Then, based on the optimal cache performance achieved by each business interface after adding cache, you can determine whether the business interface is suitable for adding a cache library. For example, if the optimal cache hit rate of a business interface is also low, it means that the business interface still needs to obtain the corresponding business data from the database for most business requests. After adding a cache library, it will increase business read time, indicating that the business interface is not suitable for adding a cache library.
[0065] Furthermore, when additional cache is required for each service interface, to ensure optimal cache performance for each service interface, this application can use the candidate cache duration corresponding to the optimal cache hit rate for each service interface as the target cache duration for that service interface. Then, when adding a corresponding cache repository for each service interface, the cache duration for the service data within that cache repository can be set as the target cache duration for that service interface, ensuring that the service interface achieves optimal cache performance after the cache is added.
[0066] As an optional implementation scheme in the present application, for the target cache duration of each business interface, the present application can use the candidate cache duration corresponding to the highest cache hit rate as the target cache duration of the business interface based on the sorting results of the cache hit rates of each business interface under each candidate cache duration.
[0067] In other words, for each service interface, the cache hit rates for each candidate cache duration can be ranked to determine the highest cache hit rate for that service interface. This highest cache hit rate represents the optimal cache performance that the service interface can achieve. The candidate cache duration corresponding to the highest cache hit rate is then used as the target cache duration for the service interface, enabling the service interface to achieve optimal cache performance after increasing the cache.
[0068] The technical solution provided in the embodiment of the present application can first determine, for each business interface, a set of acceptable candidate cache durations for the business interface. Then, based on the business request information within the target business period corresponding to each candidate cache duration in the candidate cache duration set, the cache hit rate of the business interface under each candidate cache duration is predicted, thereby determining the optimal cache hit rate that the business interface can achieve and the target cache duration corresponding to the optimal cache hit rate, thereby accurately estimating the cache performance of each business interface after the cache is increased. On the basis of avoiding the business reading bottleneck problem of the business interface, the cache hit rate of each business interface after the cache is increased is optimized, thereby improving the business reading efficiency of each business interface.
[0069] As an optional implementation scheme in this application, in order to ensure the accurate prediction of the cache hit rate of each business interface under each candidate cache duration, this application can provide a detailed explanation of the specific prediction process of the cache hit rate of the business interface under each candidate cache duration.
[0070] FIG4 is a flowchart of another cache determination method according to an embodiment of the present application. The method may include the following steps:
[0071] S410: For each service interface, determine a candidate cache duration set for the service interface.
[0072] S420 : For each candidate cache duration in the candidate cache duration set, determine a target service period corresponding to the candidate cache duration from a preset service statistics period.
[0073] In order to ensure the consistency of business references when the business interface performs cache estimation under various candidate cache durations, this application can pre-set a business statistical period for the entire online business process in which the client initiates the corresponding business request to the server, such as the period represented by [startTime, endTime].
[0074] Then, for each business interface, for each candidate cache duration in the candidate cache duration set of the business interface, the present application can use the candidate cache duration as the total duration of the target business period, divide one or more target business periods within the preset business statistical period, and obtain the target business period corresponding to each candidate cache duration.
[0075] In some implementations, the present application may divide each candidate cache duration into two parts starting from a target time point within a preset business statistics period according to the candidate cache duration to obtain a corresponding target business period.
[0076] That is, the present application can set one or more target time points within a preset business statistics period. For each candidate cache duration, the candidate cache duration can be extended backward from the target time point to obtain an end time point. Then, the period between the target time point and the end time point can be divided from the preset business statistics period to obtain the target business period corresponding to the candidate cache duration.
[0077] In other possible implementations, the present application may determine, for each candidate cache duration, a target service period corresponding to the candidate cache duration based on a sliding time window within a preset service statistics period.
[0078] In other words, a sliding time window can be set within the preset service statistics period, with each candidate cache duration as the window length and the unit service duration as the sliding step length. Then, starting from the starting point within the preset service statistics period, the sliding time window is controlled to slide within the preset service statistics period according to the unit service duration. Furthermore, during the sliding process, the time period within the preset service statistics period can be continuously divided, thereby obtaining the target service period corresponding to each candidate cache duration.
[0079] S430 : Predicting a cache hit rate of the service interface under a candidate cache duration based on service request information within the target service period.
[0080] For each business interface, when determining the target business period corresponding to each candidate cache duration of the business interface, the business request information within the target business period corresponding to each candidate cache duration can be obtained first. Then, for the target business period corresponding to each candidate cache duration, the total number of business requests received by the business interface within the target business period can be determined by analyzing the interface path of each business request in the business request information within the target business period. By analyzing the summary information of the business request data corresponding to each business request in the business request information within the target business period, it can be determined whether each business request is received for the first time by the business interface within the target business period, and the number of business requests for which the business data is read for the first time by the business interface within the target business period can be determined. Among them, the business request for which the business data is read for the first time requires the business interface to successfully read it from the DB database, which means that the business request has not been cached by the business interface.
[0081] Therefore, according to the number of business requests for reading business data for the first time during the target business period corresponding to each candidate cache duration of the business interface and the total number of business requests received by the business interface during the target business period, the frequency of the business interface not being cached during the target business period corresponding to each candidate cache duration can be predicted. In this way, the frequency of the business interface being cached during the target business period corresponding to each candidate cache duration can be determined, and the cache hit rate of the business interface under each candidate cache duration can be obtained.
[0082] As an optional implementation scheme in the present application, the cache hit rate of the business interface at each candidate cache duration can be determined by the following steps: based on the business request information within the target business time period, determine the total number of business requests and the number of deduplicated businesses of the business interface within the target business time period; based on the total number of business requests and the number of deduplicated businesses of the business interface within the target business time period, predict the cache hit rate of the business interface at the candidate cache duration.
[0083] That is to say, for the target business period corresponding to each candidate cache duration of the business interface, this application can determine the total number of business requests of the business interface within the target business period by analyzing the interface path of each business request received within the target business period.
[0084] Moreover, by comparing the summary information of the business data obtained under each business request received by the business interface during the target business period, the business requests received by the business interface during the target business period are deduplicated, and the deduplicated number of business requests of the business interface during the target business period is obtained, which can represent the number of business requests for which the business data of the business interface is read for the first time during the target business period, that is, the number of business requests that the business interface is not hit during the target business period.
[0085] At this time, the number of deduplicated services of the business interface within the target business period can indicate the number of business requests that still need to successfully read business data from the DB database within the target business period after the business interface increases the cache, that is, the number of business requests that are not cached during the target business period. Then, through the ratio between the number of deduplicated services and the total number of business requests in the target business period corresponding to each candidate cache duration of the business interface and the candidate cache duration, the non-cached hit rate of the business interface under the candidate cache duration can be determined, thereby determining the cache hit rate of the business interface under the candidate cache duration.
[0086] For example, assuming that a candidate cache duration of a certain service interface is T, the total number of service requests of the service interface in the target service period corresponding to the candidate cache duration T is totalReqCnt, and the number of service deduplication is uniqReqCnt, which can represent the number of service requests that read service data for the first time in the target service period. Then, the cache hit rate of the service interface under the candidate cache duration is
[0087] In some possible implementations, in order to ensure the accuracy of the cache hit rate of the service interface under each candidate cache duration, there may be multiple target service time periods corresponding to each candidate cache duration of the service interface. Then, if there are multiple target service time periods corresponding to each candidate cache duration of the service interface, the cache hit rate of the service interface under the candidate cache duration can be determined by the following steps: based on the total number of service requests and the number of deduplicated services of the service interface in each target service time period, the initial cache hit rate of the service interface under each target service time period is determined; the initial cache hit rate of the service interface under each target service time period is averaged to obtain the cache hit rate of the service interface under the candidate cache duration.
[0088] That is to say, for each target business period corresponding to a candidate cache duration of a business interface, this application can determine the total number of business requests and the number of deduplicated services of the business interface in each target business period. Then, according to the above-mentioned method for determining the cache hit rate, based on the total number of business requests and the number of deduplicated services of the business interface in each target business period, the cache hit rate of the business interface in each target business period can be determined as the initial cache hit rate in this application.
[0089] Then, for each candidate cache duration of the service interface, the initial cache hit rates of the service interface in each target service time period corresponding to the candidate cache duration can be summed and averaged, and the average value of the initial cache hit rates of the service interface in each target service time period corresponding to the candidate cache duration can be calculated as the cache hit rate of the service interface in the candidate cache duration.
[0090] In the same way as above, for each candidate cache duration of the service interface, the cache hit rate of the service interface under the candidate cache duration can be obtained by averaging the initial cache hit rates of the service interface under each target service period corresponding to the candidate cache duration.
[0091] S440 : Determine a target cache duration of the service interface according to the cache hit rate of the service interface under each candidate cache duration.
[0092] The technical solution provided in the embodiment of the present application can first determine, for each business interface, a set of acceptable candidate cache durations for the business interface. Then, based on the business request information within the target business period corresponding to each candidate cache duration in the candidate cache duration set, the cache hit rate of the business interface under each candidate cache duration is predicted, thereby determining the optimal cache hit rate that the business interface can achieve and the target cache duration corresponding to the optimal cache hit rate, thereby accurately estimating the cache performance of each business interface after the cache is increased. On the basis of avoiding the business reading bottleneck problem of the business interface, the cache hit rate of each business interface after the cache is increased is optimized, thereby improving the business reading efficiency of each business interface.
[0093] FIG5 is a block diagram of a cache determination device according to an embodiment of the present application. As shown in FIG5 , the device 500 may include:
[0094] The candidate duration determination module 510 is configured to determine, for each service interface, a set of candidate cache durations for the service interface;
[0095] A cache hit rate prediction module 520 is configured to predict a cache hit rate of the service interface under each candidate cache duration according to service request information within a target service period corresponding to each candidate cache duration in the candidate cache duration set;
[0096] The cache determination module 530 is configured to determine a target cache duration for the service interface according to a cache hit rate of the service interface under each candidate cache duration.
[0097] In some implementations, the cache hit rate prediction module 520 may include:
[0098] a target period determination unit, configured to determine, for each candidate cache period in the candidate cache period set, a target service period corresponding to the candidate cache period from a preset service statistics period;
[0099] The cache hit rate prediction unit is used to predict the cache hit rate of the service interface under the candidate cache duration according to the service request information in the target service time period.
[0100] In some implementations, the target time period determination unit may be specifically configured to:
[0101] According to the candidate cache duration, starting from the target time point within the preset service statistics period, a corresponding target service period is obtained; or,
[0102] Determining a target service period corresponding to the candidate cache duration according to a sliding time window within the preset service statistics period;
[0103] The sliding time window uses the candidate cache duration as the window length and the unit service duration as the sliding step length.
[0104] In some implementations, the cache hit rate prediction unit may be specifically configured to:
[0105] Determine the total number of service requests and the number of services deduplicated by the service interface within the target service period according to the service request information within the target service period;
[0106] The cache hit rate of the service interface under the candidate cache duration is predicted based on the total number of service requests and the number of deduplicated services of the service interface within the target service time period.
[0107] In some implementations, if there are multiple target service periods, the cache hit rate prediction unit may be further configured to:
[0108] Determine an initial cache hit rate of the service interface in each target service period according to the total number of service requests and the number of deduplicated services of the service interface in each target service period;
[0109] The initial cache hit rates of the service interface in each target service time period are averaged to obtain the cache hit rate of the service interface in the candidate cache duration.
[0110] In some implementations, the service request information includes an interface path for each service request, summary information of the service request data, and a request time point.
[0111] In some implementations, the candidate duration determination module 510 may be specifically configured to:
[0112] Determining an acceptable cache upper limit for the service interface based on the service type oriented by the service interface;
[0113] A set of candidate cache durations for the service interface is determined based on an acceptable cache upper limit for the service interface.
[0114] In some implementations, the cache determination module 530 may be specifically configured to:
[0115] According to the ranking results of the cache hit rates of the service interfaces under the candidate cache time periods, the candidate cache time period corresponding to the highest cache hit rate is used as the target cache time period of the service interface.
[0116] In an embodiment of the present application, first, for each service interface, a set of acceptable candidate cache durations for the service interface can be determined. Then, based on the service request information within the target service period corresponding to each candidate cache duration in the candidate cache duration set, the cache hit rate of the service interface under each candidate cache duration is predicted, thereby determining the optimal cache hit rate that the service interface can achieve and the target cache duration corresponding to the optimal cache hit rate, thereby accurately estimating the cache performance of each service interface after the cache is increased. On the basis of avoiding the service reading bottleneck problem of the service interface, the cache hit rate of each service interface after the cache is increased is optimized, thereby improving the service reading efficiency of each service interface.
[0117] It should be understood that the device embodiments and method embodiments may correspond to each other, and similar descriptions may refer to the method embodiments. To avoid repetition, they will not be described in detail here. Specifically, the device 500 shown in FIG5 can execute any method embodiment provided in this application, and the aforementioned and other operations and / or functions of each module in the device 500 are respectively for implementing the corresponding processes in each method of the embodiment of the present application. For the sake of brevity, they will not be described in detail here.
[0118] The above describes the device 500 of the embodiment of the present application from the perspective of functional modules in conjunction with the accompanying drawings. It should be understood that the functional module can be implemented in hardware form, can be implemented by instructions in software form, and can also be implemented by a combination of hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software form instructions in the processor, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. Optionally, the software module can be located in a mature storage medium in the art such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps in the above method embodiment in conjunction with its hardware.
[0119] FIG6 is a schematic block diagram of an electronic device according to an embodiment of the present application.
[0120] As shown in FIG6 , the electronic device 600 may include:
[0121] The memory 610 and the processor 620 are configured to store computer programs and transmit the program code to the processor 620. In other words, the processor 620 can call and run the computer program from the memory 610 to implement the method in the embodiment of the present application.
[0122] For example, the processor 620 may be configured to execute the above method embodiments according to instructions in the computer program.
[0123] In some embodiments of the present application, the processor 620 may include but is not limited to:
[0124] General-purpose processor, Digital Signal Processor (DSP), Application Specific Integrated Circuit (ASIC), Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
[0125] In some embodiments of the present application, the memory 610 includes but is not limited to:
[0126] Volatile memory and / or non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0127] In some embodiments of the present application, the computer program may be divided into one or more modules, which are stored in the memory 610 and executed by the processor 620 to implement the method provided by the present application. The one or more modules may be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.
[0128] As shown in FIG6 , the electronic device may further include:
[0129] The transceiver 630 may be connected to the processor 620 or the memory 610 .
[0130] The processor 620 may control the transceiver 630 to communicate with other devices. Specifically, the processor 620 may send information or data to other devices or receive information or data sent by other devices. The transceiver 630 may include a transmitter and a receiver. The transceiver 630 may further include one or more antennas.
[0131] It should be understood that the various components in the electronic device are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0132] The present application also provides a computer storage medium having a computer program stored thereon, which, when executed by a computer, enables the computer to perform the method of the above-mentioned method embodiment. In other words, the present application also provides a computer program product comprising instructions, which, when executed by a computer, enables the computer to perform the method of the above-mentioned method embodiment. In addition, the present application also provides a computer program comprising instructions, which, when executed by a computer, enables the computer to perform the method of the above-mentioned method embodiment.
[0133] When software is used for implementation, 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 according to the embodiment of the present application 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 one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. 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 digital video disc (DVD)), or a semiconductor medium (e.g., a solid state drive (SSD)).
[0134] Those skilled in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0135] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules 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 interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0136] Modules described as separate components may or may not be physically separate, and components displayed as modules may or may not be physical modules, i.e., they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected based on actual needs to achieve the purpose of the present embodiment. For example, the functional modules in the various embodiments of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into a single module.
[0137] The above content is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A cache determination method, comprising: For each service interface, determining a set of candidate cache durations for the service interface; Predicting a cache hit rate of the service interface under each candidate cache duration according to service request information in a target service period corresponding to each candidate cache duration in the candidate cache duration set; A target cache duration of the service interface is determined according to a cache hit rate of the service interface under each candidate cache duration.
2. The method according to claim 1, wherein: The predicting, according to the service request information in the target service period corresponding to each candidate cache duration in the candidate cache duration set, the cache hit rate of the service interface under each candidate cache duration includes: For each candidate cache duration in the candidate cache duration set, determining a target service period corresponding to the candidate cache duration from a preset service statistics period; The cache hit rate of the service interface under the candidate cache duration is predicted according to the service request information in the target service time period.
3. The method according to claim 2, wherein: The determining of the target service period corresponding to the candidate cache duration from within the preset service statistics period includes: According to the candidate cache duration, the target time point in the preset service statistics period is divided to obtain the corresponding target service period; or, Determine the target service period corresponding to the candidate cache duration according to the sliding time window within the preset service statistics period; The sliding time window uses the candidate cache duration as the window length and the unit service duration as the sliding step length.
4. The method according to claim 2 or 3, wherein: The predicting, according to the service request information in the target service period, a cache hit rate of the service interface under the candidate cache duration includes: Determine the service interface in the target service period according to the service request information in the target service period The total number of business requests and the number of deduplicated business requests within the database; The cache hit rate of the service interface at the candidate cache duration is predicted according to the total amount of service requests and the amount of deduplicated services of the service interface in the target service time period.
5. The method according to claim 4, wherein: If there are multiple target service time periods, predicting the cache hit rate of the service interface under the candidate cache duration according to the total service request amount and the service deduplication amount of the service interface in the target service time period includes: Determine the initial cache hit rate of the service interface in each target service period according to the total service request amount and the service deduplication amount of the service interface in each target service period; The initial cache hit rates of the service interface in each of the target service time periods are averaged to obtain the cache hit rate of the service interface in the candidate cache duration.
6. The method according to any one of claims 1 to 5, wherein: The service request information includes the interface path of each service request, summary information of the service request data and the request time point.
7. The method according to any one of claims 1 to 6, wherein: The determining of a candidate cache duration set for the service interface includes: Determining an acceptable cache upper limit of the service interface according to the service type oriented by the service interface; According to the acceptable cache upper limit of the service interface, a set of candidate cache durations of the service interface is determined.
8. The method according to any one of claims 1 to 7, wherein: The determining, according to the cache hit rate of the service interface under each candidate cache duration, a target cache duration of the service interface includes: According to the ranking results of the cache hit rates of the service interfaces under the candidate cache time periods, the candidate cache time period corresponding to the highest cache hit rate is used as the target cache time period of the service interface.
9. A cache determination device, comprising: A candidate duration determination module, used to determine, for each service interface, a set of candidate cache durations for the service interface; A cache hit rate prediction module is used to predict the cache hit rate of the service interface under each candidate cache duration according to the service request information in the target service period corresponding to each candidate cache duration in the candidate cache duration set. Rate; The cache determination module is used to determine the target cache duration of the service interface according to the cache hit rate of the service interface under each candidate cache duration.
10. An electronic device comprising: A processor and a memory, wherein the memory is used to store a computer program, and the processor is used to call and run the computer program stored in the memory to execute the cache determination method according to any one of claims 1 to 8.
11. A computer-readable storage medium, used for storing a computer program, wherein the computer program enables a computer to execute the cache determination method according to any one of claims 1 to 8.
12. A computer program product, comprising a computer program / instruction, which, when executed by a processor, implements the cache determination method according to any one of claims 1 to 8.
13. A computer program, comprising a computer program / instruction, which, when executed by a processor, implements the cache determination method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method and device for business system to visit more-read less-write system through client
CN108777718A
Method and device for distributing resource acquisition request
CN109246229A
Service data processing method and device, computer equipment and storage medium
CN110399367A
Cache configuration method and device
CN113064678A
Method and device for improving hit rate of local cache, equipment and storage medium
CN114003626A
