Cache determination method and device, equipment and storage medium

By determining the candidate cache duration and predicting cache hit rate for each business interface, the cache performance is optimized, the read bottleneck caused by congestion in the business interface database is solved, and the business read efficiency is improved.

CN118939688APending Publication Date: 2024-11-12BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202310519966.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-09
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

With the growth of business scale, various business interfaces have difficulty in effectively optimizing the demand for cache libraries due to database congestion, resulting in poor cache hit rate and read efficiency.

Method used

By determining the candidate cache duration set for each service interface and predicting the cache hit rate based on the service request information within the target service period, the optimal cache duration is determined to optimize cache performance and improve read efficiency.

Benefits of technology

The optimal cache performance estimate and cache hit rate optimization for each service interface are realized, avoiding read bottlenecks caused by database congestion and improving service read efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939688A_ABST
    Figure CN118939688A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a cache determination method and device, equipment and a storage medium. The method comprises the following steps: for each service interface, determining a candidate cache duration set of 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 time period corresponding to each candidate cache duration in the candidate cache duration set; and according to the cache hit rate of the service interface under each candidate cache duration, determining a target cache duration of the service interface. According to the embodiment of the invention, the cache performance of each service interface after the cache is added can be accurately estimated, the cache hit rate of each service interface after the cache is added is optimized on the basis of avoiding the service reading bottleneck problem of the service interface, and the service reading efficiency of each service interface is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] 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

[0002] When the client executes a certain business, such as displaying various pages on the client, it usually needs to request the corresponding business data from the server. As the business scale grows, in order to achieve efficient processing of large-scale business data, multiple application programming interface services (Application Programming Interface Server, referred to as API Server) are usually developed on the server as the corresponding business interface.

[0003] When the client initiates a corresponding business request to the server, it calls 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 between the business interface and the DB database, each 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 the client's business request, 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.

[0004] However, since each business interface carries different business data volumes and business types, the requirements for cache libraries are also different. Therefore, in order to ensure that each business interface can achieve the optimal business reading efficiency, it is urgent to design a more effective cache determination solution. Summary of the invention

[0005] The embodiments of the present application provide a cache determination method, apparatus, device and storage medium to accurately estimate the cache performance of each business interface, optimize each business interface to increase the cache hit rate after caching, and improve the business reading efficiency of each business interface.

[0006] In a first aspect, an embodiment of the present application provides a cache determination method, the method comprising:

[0007] For each service interface, determining a set of candidate cache durations for the service interface;

[0008] 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;

[0009] 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.

[0010] In a second aspect, an embodiment of the present application provides a cache determination device, the device comprising:

[0011] A candidate duration determination module, used to determine, for each service interface, a set of candidate cache durations for the service interface;

[0012] A cache hit rate prediction module, 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;

[0013] 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.

[0014] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising:

[0015] 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.

[0016] In a fourth 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.

[0017] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program / instructions, characterized in that when the computer program / instructions are executed by a processor, the cache determination method provided in the first aspect of the present application is implemented.

[0018] The embodiment of the present application provides a cache determination method, device, equipment and storage medium. 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 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 is predicted, so as to determine the optimal cache hit rate that can be achieved by the service interface 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. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. 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 paying any creative work.

[0020] Figure 1a and Figure 1b They are schematic diagrams of the principles of the service request processing process shown in the embodiments of the present application;

[0021] Figure 2 A flowchart of a cache determination method shown in an embodiment of the present application;

[0022] Figure 3 A schematic diagram of the principle of online and offline processing of a service request shown in an embodiment of the present application;

[0023] Figure 4 A flowchart of another cache determination method shown in an embodiment of the present application;

[0024] Figure 5 A principle block diagram of a cache determination device shown in an embodiment of the present application;

[0025] Figure 6 A schematic block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only 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.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present 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 present 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 of their variations 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.

[0028] 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 scheme 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 schemes. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0029] 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. Therefore, before introducing the specific technical solution of this application, the specific service data acquisition process performed by each service interface after receiving a service request initiated by the client is first described:

[0030] Before the business scale is expanded, the client sends fewer business requests to the server. Figure 1a As shown, when the client initiates a corresponding business request to the server, it calls a business interface in the server, which directly searches the DB database for corresponding business data and sends it to the client.

[0031] As the business scale continues to grow, each business interface will receive more and more business requests, which will bring excessive pressure to the business data reading of the DB database, causing corresponding business congestion in the DB database.

[0032] At this time, in order to avoid the business bottleneck phenomenon of each business interface due to the congestion of DB database business volume, such as Figure 1bAs shown, 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 has a business reading bottleneck due to the congestion of the DB database's business volume.

[0033] However, since each business interface carries different amounts of business data and business types, the requirements for the cache library are also different. Therefore, in order to ensure that each business 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 business interface increases the cache, thereby optimizing the cache hit rate of each business interface after the cache is increased, and improving the business reading efficiency of each business interface.

[0034] Next, the technical solution of this application is described in detail:

[0035] Figure 2 A flowchart of a cache determination method shown in an embodiment of the present application. The method can be performed by a 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 folding screen mobile phones, large screen mobile phones, etc.), wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, 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.

[0036] Specifically, Figure 2 As shown, the method may include the following steps:

[0037] S210: For each service interface, determine a candidate cache duration set for the service interface.

[0038] As the client's business scale continues to expand, the number of business requests initiated by the client to the server is also increasing. Therefore, in order to ensure that the server can efficiently process business requests in parallel, multiple business interfaces are usually configured on the server, which can be recorded as API Server. Then, after the client initiates the corresponding business request to the server, it can call a business interface to perform the corresponding business read operation.

[0039] Among them, in order to ensure that each business interface accurately distinguishes and executes various types of business requests, different business interfaces can be set to process different types of business data. For example, when a business request is used to request the list data of the live broadcast room from the server, business interface 1 can be called, and business interface 1 can obtain the list data of the live broadcast room and send it to the client; when another business request is used to request the gift list of the live broadcast room from the server, business interface 2 can be called, and business interface 2 can obtain the gift data of the live broadcast room and send it to the client.

[0040] For each business interface used to process different types of business data, the amount of business data carried by each business interface is also different, so each business interface has different needs for business processing performance. Therefore, when the business scale continues to expand and it is necessary to reduce the business reading bottleneck problem that may exist in each business interface by adding cache, you can add a suitable cache library to each business interface by analyzing the cache requirements of each business interface for business data reading, so that it can achieve the optimal business cache performance after adding cache.

[0041] 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.

[0042] In the present 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 the present application, thereby forming a set of candidate cache durations for the business interface.

[0043] 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 oriented by the business interface; determining the candidate cache duration set of the business interface based on the acceptable cache upper limit of the business interface.

[0044] That is to say, by analyzing the business type that each business interface faces, we can determine the amount of business data and processing performance requirements that the business interface needs to process, and thereby analyze the cache requirements of the business interface when reading business data. Then, according to the cache requirements of each business interface when reading business data, we can determine the acceptable cache upper limit of each business interface when caching each business data. Furthermore, for each business interface, using unit time, we can enumerate multiple candidate cache durations that are less than the acceptable cache upper limit of the business interface to form a set of candidate cache durations for the business interface.

[0045] Exemplarily, assuming that the acceptable cache upper limit of a certain service interface is k seconds and the unit time is 2 seconds, then the candidate cache durations of the service interface may be {1s, 2s, 3s, . . . , ks}.

[0046] S220 , predicting a cache hit rate of a 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.

[0047] For each service interface, after determining the candidate cache durations of the service interface, different candidate cache durations will bring different cache performance to the cache added to the service interface. Therefore, this application needs to pre-evaluate the cache performance that the service interface can achieve under each candidate cache duration before adding the cache, so that a cache library that can achieve the optimal cache performance can be added to the service interface.

[0048] In this application, the cache performance of the service interface can be represented by the cache hit rate, which can be the ratio of the number of service requests that can successfully obtain corresponding service data from the increased cache library to the total number of service requests received by the service interface in a unit time.

[0049] Before adding cache to each business interface, the business interface accurately estimates the cache performance that can be achieved under each candidate cache duration. For each business request received, the business interface will directly obtain the business data corresponding to the business request from the DB database.

[0050] It can be understood that, assuming that a certain business interface has added a cache library under 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 specified in the business request received by the business interface is read for the first time within the period, it means that the business interface needs to successfully obtain the business data from the DB database. If the business data specified in the business request received by the business interface is not read for the first time within the period, that is, a business request indicating the need to read the business data has been received within 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 within the period, so that the business interface can successfully obtain the business data from the cache library.

[0051] From the above content, it can be known that for the cache performance that can be achieved by the service interface under each candidate cache duration, the present application can divide one or more target service periods for each candidate cache duration from the entire service statistical period in which the client initiates the corresponding service request to the server, with each candidate cache duration as the total duration. That is, the total duration of the target service period corresponding to each candidate cache duration is the candidate cache duration.

[0052] Then, for the target business time period corresponding to each candidate cache duration, the present application can find out the business request information within the target business time period. The business request information may include but is not limited to the interface path of each business request received by all business interfaces within the target business time period, summary information of the business request data and the request time point.

[0053] 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 signature information of a fixed length obtained by processing the service request data through a message digest algorithm. The message digest algorithm may include but is not limited to a message digest algorithm, etc.

[0054] Then, the interface path of each business request can be used to determine whether the business request is a 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 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.

[0055] Therefore, for the target business time 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 time period, the total number of business requests received by the business interface within the target business time 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 time period, it can be determined whether each business request is received by the business interface for the first time within the target business time 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 time 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 from the DB database, which means that the business request has not been cached and hit by the business interface.

[0056] Therefore, according to the number of business requests for reading business data for the first time during the target business time period corresponding to each candidate cache duration and the total number of business requests received by the business interface during the target business time period, the frequency of the business interface not being cached during the target business time 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 time 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.

[0057] In some implementations, for service request information, in the entire online service process in which the client initiates a corresponding service request to the server, each service interface receives a service request, such as Figure 3 As shown, the business data specified by the business request can be obtained from the DB database and sent to the client. Moreover, for the business request that has been processed this time, the business interface can use an information digest algorithm to perform hash processing on 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.

[0058] Moreover, in order to ensure accurate offline analysis of business requests, in the offline business process, the MQ queue will export the business request information written in it to the Hive database at regular intervals. Then, the application can read the business request information in the target business period corresponding to each candidate cache duration of the business interface from the Hive database through the cache analysis system to accurately estimate the cache performance that each business interface can achieve under each candidate cache duration.

[0059] Among them, the Hive table structure can be shown in Table 1 below:

[0060] Table 1

[0061]

[0062] S230 , determining a target cache duration of the service interface according to a 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, the present 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, according to the optimal cache performance that each business interface can achieve after adding cache, it can be judged whether the business interface is suitable for adding cache library. For example, if the optimal cache hit rate of a business interface is also very low, it means that for most business requests, the business interface still needs to obtain the corresponding business data from the DB database. After adding cache library, it will consume business reading time, which means that the business interface is not suitable for adding cache library.

[0065] Moreover, when each service interface needs to increase the cache, in order to ensure the optimal cache performance of each service interface, the present application can use the candidate cache duration corresponding to the optimal cache hit rate of each service interface as the target cache duration of the service interface. Then, when adding a corresponding cache library for each service interface, the cache duration of the service data in the cache library can be set as the target cache duration of the service interface, so that the service interface can achieve the optimal cache performance after increasing the cache.

[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 rate of each business interface under each candidate cache duration.

[0067] That is to say, for each service interface, the cache hit rates of the service interface under various candidate cache durations can be sorted to determine the highest cache hit rate of the service interface. The highest cache hit rate can represent the optimal cache performance that can be achieved by the service interface. Then, the candidate cache duration corresponding to the highest cache hit rate is used as the target cache duration of the service interface, so that the service interface can achieve the optimal cache performance after increasing the cache.

[0068] The technical solution provided by the embodiment of the present application can first determine a set of acceptable candidate cache durations for each service interface. Then, based on 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 is predicted, so as to determine the optimal cache hit rate that can be achieved by the service interface 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, and optimizing the cache hit rate of each service interface after the cache is increased on the basis of avoiding the service reading bottleneck problem of the service interface, thereby improving the service reading efficiency of each service interface.

[0069] As an optional implementation scheme in the present application, in order to ensure accurate prediction of the cache hit rate of each business interface at each candidate cache time length, the present application may provide a detailed explanation of the specific prediction process of the cache hit rate of the business interface at each candidate cache time length.

[0070] Figure 4 This is a flowchart of another cache determination method shown in 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 of 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, the present application can pre-set a business statistical period, such as the period represented by [startTime, endTime], for the entire online business process in which the client initiates the corresponding business request to the server.

[0074] Then, for each service interface, for each candidate cache duration in the candidate cache duration set of the service interface, the present application can use the candidate cache duration as the total duration of the target service period, divide one or more target service periods within the preset service statistical period, and obtain the target service period corresponding to each candidate cache duration.

[0075] In some possible implementations, the present application may divide each candidate cache duration according to the candidate cache duration, starting from a target time point within a preset business statistics period, to obtain a corresponding target business period.

[0076] That is, the present application can set one or more target time points within the 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 business period corresponding to the candidate cache duration according to a sliding time window within a preset business statistics period.

[0078] That is to say, a sliding time window can be set within the preset business statistics period, and the sliding time window uses each candidate cache duration as the window length and the unit business duration as the sliding step length. Then, starting from the starting point within the preset business statistics period, the sliding time window is controlled to slide within the preset business statistics period according to the unit business duration. Moreover, during the sliding process, the time period of the sliding time window within the preset business statistics period can be continuously divided, and the target business period corresponding to each candidate cache duration can be obtained.

[0079] S430 , predicting a cache hit rate of a service interface under a candidate cache duration according to service request information in a target service period.

[0080] For each service interface, when determining the target service time period corresponding to each candidate cache duration of the service interface, the service request information within the target service time period corresponding to each candidate cache duration can be first obtained. Then, for the target service time period corresponding to each candidate cache duration, the total number of service requests received by the service interface within the target service time period can be determined by analyzing the interface path of each service request in the service request information within the target service time period. By analyzing the summary information of the service request data corresponding to each service request in the service request information within the target service time period, it can be determined whether each service request is received by the service interface for the first time within the target service time period, and the number of service requests for which service data is read for the first time by the service interface within the target service time period can be determined. Among them, the service request for which service data is read for the first time requires the service interface to successfully read from the DB database, which means that the service request has not been cached and hit by the service interface.

[0081] Therefore, according to the number of business requests for reading business data for the first time during the target business time period corresponding to each candidate cache duration and the total number of business requests received by the business interface during the target business time period, the frequency of the business interface not being cached during the target business time 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 time 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 business requests and the number of deduplicated businesses of the business interface within the target business time period; based on the total 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 time period corresponding to each candidate cache duration of the business interface, the present application can determine the total number of business requests of the business interface within the target business time period by analyzing the interface path of each business request received within the target business time 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 to obtain the deduplicated number of business requests of the business interface during the target business period, 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 are not hit by the business interface during the target business period.

[0085] At this time, the number of deduplicated services of the business interface in 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 of the business interface in the target business period corresponding to each candidate cache duration 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, suppose that a candidate cache duration of a 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 at 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 at the candidate cache duration can be determined by the following steps in this application: according to 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 at each target service time period is determined; the initial cache hit rate of the service interface at each target service time period is averaged to obtain the cache hit rate of the service interface at the candidate cache duration.

[0088] That is to say, for each target business period corresponding to a candidate cache duration of the business interface, the present 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 the present 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 manner 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 by the embodiment of the present application can first determine a set of acceptable candidate cache durations for each service interface. Then, based on 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 is predicted, so as to determine the optimal cache hit rate that can be achieved by the service interface 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, and optimizing the cache hit rate of each service interface after the cache is increased on the basis of avoiding the service reading bottleneck problem of the service interface, thereby improving the service reading efficiency of each service interface.

[0093] Figure 5 FIG. 1 is a block diagram showing a cache determination device according to an embodiment of the present application. Figure 5 As shown, the apparatus 500 may include:

[0094] A candidate duration determination module 510, 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, configured to predict 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;

[0096] The cache determination module 530 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.

[0097] In some implementations, the cache hit rate prediction module 520 may include:

[0098] a target time period determination unit, configured to determine, for each candidate cache time period in the candidate cache time period set, a target service time period corresponding to the candidate cache time period from a preset service statistics time 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 period.

[0100] In some possible implementations, the target time period determination unit may be specifically configured to:

[0101] 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,

[0102] Determine the target service period corresponding to the candidate cache duration according to the 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 used to:

[0105] Determine the total number of service requests and the number of services to be deduplicated for 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 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.

[0107] In some implementations, if there are multiple target service time periods, the cache hit rate prediction unit may be further specifically configured to:

[0108] 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;

[0109] 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.

[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 of the service interface according to the service type oriented by the service interface;

[0113] According to the acceptable cache upper limit of the service interface, a set of candidate cache durations of the service interface is determined.

[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 interface 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 the embodiment of the present application, firstly, 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 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 is predicted, so as to determine 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, and optimizing the cache hit rate of each service interface after the cache is increased on the basis of avoiding the service reading bottleneck problem of the service interface, thereby improving the service reading efficiency of each service interface.

[0117] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, Figure 5 The device 500 shown can execute any method embodiment provided in the present 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 repeated here.

[0118] The above describes the device 500 of the embodiment of the present application from the perspective of the functional module 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 a hardware decoding processor to perform, or a combination of hardware and software modules in the decoding processor to perform. Optionally, the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a 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] Figure 6 A schematic block diagram of an electronic device according to an embodiment of the present application.

[0120] like Figure 6 As shown, the electronic device 600 may include:

[0121] The memory 610 and the processor 620, the memory 610 is used to store the computer program 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. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The 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 complete the method provided by the present application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.

[0128] like Figure 6 As shown, the electronic device may also 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, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 630 may include a transmitter and a receiver. The transceiver 630 may further include an antenna, and the number of antennas may be one or more.

[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 on which a computer program is stored, and when the computer program is executed by a computer, the computer can perform the method of the above method embodiment. In other words, the present application embodiment also provides a computer program product containing instructions, and when the instructions are executed by a computer, the computer can perform the method of the above 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 devices. 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 by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. 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 integration. 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 (digital video disc, DVD)), or a semiconductor medium (e.g., a solid state drive (solid state disk, SSD)), etc.

[0134] Those of ordinary skill 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 to be beyond the scope of this application.

[0135] In the several embodiments provided in the present 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 only schematic. For example, the division of the module is only a logical function division. There may be other division methods in actual implementation, 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] The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. For example, each functional module in each embodiment 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 one module.

[0137] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A cache determination method, characterized in that: include: 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, characterized in that 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, characterized in that 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, characterized in that: 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 total number of service requests and the number of services to be deduplicated for the service interface within the target service period according to the service request information within the target service period; 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, characterized in that 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, characterized in that: 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 claim 1, characterized in that 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 claim 1, characterized in that 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, characterized in that: include: 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, 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; 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, characterized in that: include: 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, characterized in that: Used to store 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 / instructions, characterized in that When the computer program / instruction is executed by a processor, the cache determination method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Method and device for automatically adjusting cache duration

    CN108134817A

  • Cache duration determination method and device, server and storage medium

    CN112003752A

  • Method and device for carrying out equipment anomaly analysis based on real-time acquisition of sensing data

    CN112486104A

  • Envelope feeder

    KR1020230048767A

  • Negotiated distribution of cache content

    US20050060493A1