Cache mode decision method, device, electronic device, storage medium and program product

By using log database and cache operation logs in the decision-making system of distributed systems, the applicable cache mode is automatically determined and sent, and the problem of time-consuming and labor-intensive and difficult to change in the configuration of cache mode in the existing technology is solved, real-time adjustment and Preloading improves system performance.

CN118838932BActive Publication Date: 2024-11-26巽风科技(贵州)有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411311074.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-20
Publication Date
2024-11-26
Estimated Expiration
2044-09-20

AI Technical Summary

Technical Problem

In distributed systems, the existing technology depends on the experience of R&D personnel, time-consuming and difficult to change how to effectively determine the cache mode suitable for different data from multiple cache modes.

Method used

By using the log database to store the node's cache operation log in the decision system, the data type is determined based on the operation data volume and type, and the applicable cache method is determined based on the data type and the local cache space of the node, and the applicable cache method is automatically sent to the node. Ensure the cache strategy for the next decision cycle.

Benefits of technology

It realizes the automatic decision-making of applicable caching methods for each node to each operating object, saves R&D time, adjusts cache strategies in real time to deal with changes in access load, and cache preloads in advance through prediction functions to reduce access delays.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118838932B_ABST
    Figure CN118838932B_ABST
Patent Text Reader

Abstract

The present invention provides a cache mode decision method, device, electronic device, storage medium and program product. The method is applied to a decision system that is connected to each node of a distributed system in communication. First, all cache operation logs whose operation time belongs to the current decision cycle are queried from a log database; based on all the queried cache operation logs, at least one data type to which each operation object belongs in the current decision cycle is determined; based on at least one data type to which each operation object belongs, an applicable cache mode for each operation object on each node is determined; the applicable cache mode for each operation object on each node is sent to each node respectively, so that each node performs data caching according to the received applicable cache mode for each operation object in the next decision cycle. In this way, the applicable cache mode for each operation object at each node can be found for use by the node in the next decision cycle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data storage, and in particular to a cache mode decision method, device, electronic device, storage medium and program product. Background Art

[0002] In a distributed system, cache is usually used to store frequently accessed data, which greatly speeds up the reading of data and reduces response time. It also reduces frequent requests to databases and other backend services, reducing the load on these systems.

[0003] Usually, there is more than one cache method in a distributed system. For different data that are frequently accessed, how to determine the cache method suitable for each data from all the cache methods is a problem that needs to be considered. Summary of the invention

[0004] The purpose of the present invention is to provide a cache mode decision method, device, electronic device, storage medium and program product to improve the problems existing in the prior art.

[0005] The embodiments of the present invention can be implemented as follows:

[0006] In a first aspect, the present invention provides a cache mode decision method, which is applied to a decision system, wherein the decision system is communicatively connected to each node of a distributed system, and the decision system includes a log database, wherein the log database is used to store cache operation logs reported by each node, and the cache operation logs include operation time and operation object; the method includes:

[0007] Querying from the log database all cache operation logs whose operation time belongs to the current decision cycle;

[0008] Based on the operation data volume and operation type of each cache operation log queried, determine at least one data type to which each operation object in the current decision cycle belongs; the data types include hotspot type, large value type, and other types;

[0009] Determine that the applicable cache mode for each first operation object belonging only to the hotspot type on each node is local cache;

[0010] Determine, based on the total amount of operation data of all second operation objects of the large value type and the latest remaining local cache space of each node, an applicable cache mode for each second operation object on each node;

[0011] Determine that the applicable cache mode for each third operation object belonging only to the other type on each of the nodes is remote cache;

[0012] The applicable cache mode of each operation object on each node is sent to each node respectively, so that each node caches data according to the received applicable cache mode of each operation object in the next decision cycle.

[0013] Optionally, the operation objects in any two cache operation logs are the same or different; the cache operation log also includes an operation command and operation data corresponding to the operation object;

[0014] The step of determining at least one data type to which each operation object in the current decision cycle belongs based on the operation data volume and operation type of each cache operation log queried includes:

[0015] For each cache operation log queried, count the operation data volume of the operation data in the cache operation log, and determine the operation type to which the cache operation log belongs based on the operation command in the cache operation log; the operation type is a read operation or a write operation;

[0016] Classify all cache operation logs found out according to the different operation objects, and obtain at least one cache operation log corresponding to each operation object;

[0017] For each of the operation objects, based on the operation data volume of each cache operation log corresponding to the operation object, calculate the average operation data volume of the operation object;

[0018] Calculating the operation frequency of the operation object based on all cache operation logs queried, and calculating the read-write ratio of the operation object based on the operation type of each cache operation log corresponding to the operation object;

[0019] If the average value of the operation data volume is not lower than the preset operation volume threshold, it is confirmed that the data type of the operation object belongs to the large value type;

[0020] If the operation frequency is not lower than a preset operation frequency threshold and the read-write ratio is not lower than a preset read-write ratio threshold, it is confirmed that the data type of the operation object belongs to a hotspot type;

[0021] If the average value of the operation data volume is lower than the operation volume threshold, the operation frequency is lower than the operation frequency threshold, and the read-write ratio is lower than the read-write ratio threshold, it is confirmed that the data type of the operation object belongs to other types.

[0022] Optionally, the cache operation log also includes a reporting node identifier and a remaining local cache space;

[0023] The step of determining the applicable cache mode for each of the second operation objects on each of the nodes based on the total amount of operation data of all the second operation objects belonging to the large value type and the latest remaining local cache space of each node includes:

[0024] Calculate the total amount of operation data of all second operation objects based on the amount of operation data of each cache operation log corresponding to each second operation object;

[0025] For each node of the distributed system, obtain a target cache operation log belonging to the node and having the latest operation time from all the cache operation logs queried, and obtain the latest local cache remaining space of the node from the target cache operation log;

[0026] If the total amount of the operation data is greater than the latest remaining space of the local cache of the node, confirming that the applicable cache mode of each of the second operation objects on the node is remote cache;

[0027] If the total amount of the operation data is equal to or less than the latest remaining space of the local cache of the node, it is confirmed that the applicable cache mode for each of the second operation objects on the node is local cache.

[0028] Optionally, the decision system further includes a decision database, the decision database includes a decision list of several historical decision cycles, the decision list includes data types of multiple operation objects and applicable cache methods; the method further includes:

[0029] Obtaining from the decision database a decision list of each reference historical decision cycle corresponding to the decision cycle to be predicted within N consecutive historical time periods; the duration of the historical time period is equal to the sum of the durations of the several historical decision cycles;

[0030] Generate a decision change sequence vector based on the decision list of each reference historical decision cycle;

[0031] Inputting the decision change sequence vector into a pre-trained prediction model to obtain a prediction decision list of the decision cycle to be predicted; the prediction decision list includes data types and optimal caching methods of multiple operation objects;

[0032] The prediction decision list is sent to each of the nodes, so that each of the nodes preloads each of the operation objects in advance according to the optimal cache mode before the decision cycle to be predicted.

[0033] Optionally, the step of generating a decision change sequence vector based on the decision list of each reference historical decision cycle includes:

[0034] For each operation object in all reference historical decision cycles, based on the decision lists of all reference historical decision cycles, statistics are collected on the occurrence frequency, data type changes, and cache mode changes of the operation object;

[0035] Based on the occurrence frequency, data type change and cache mode change of each operation object, respectively generate a change sequence sub-vector for each operation object;

[0036] The change sequence sub-vectors of all the operation objects are combined to obtain the decision change sequence vector.

[0037] Optionally, before the step of querying from the log database all cache operation logs whose operation time belongs to the current decision cycle, the method further includes:

[0038] Displaying the task configuration interface of the distributed system; the task configuration interface includes a plurality of configuration input boxes and a create button;

[0039] In response to a user clicking operation on the create button, acquiring decision configuration data input by the user in the plurality of configuration input boxes; the decision configuration data includes reporting sampling rate, cache mode information, threshold configuration data and decision cycle;

[0040] Sending the reporting sampling rate to each node of the distributed system, so that each of the nodes reports the cache operation log according to the reporting sampling rate;

[0041] Based on the cache mode information, the threshold configuration data and the decision cycle, a decision task of the distributed system is generated, so as to perform a cache mode decision on the distributed system according to the decision task.

[0042] In a second aspect, the present invention provides a cache mode decision device, which is applied to a decision system, wherein the decision system is communicatively connected to each node of a distributed system, and the decision system includes a log database, wherein the log database is used to store cache operation logs reported by each node, and the cache operation logs include operation time and operation object; the device includes:

[0043] A period query module, used to query all cache operation logs whose operation time belongs to the current decision period from the log database;

[0044] A type determination module, used to determine at least one data type to which each operation object in the current decision cycle belongs based on the operation data volume and operation type of each cache operation log queried; the data types include hotspot type, large value type and other types;

[0045] Cache decision module for:

[0046] Determine that the applicable cache mode for each first operation object belonging only to the hotspot type on each node is local cache;

[0047] Determine, based on the total amount of operation data of all second operation objects of the large value type and the latest remaining local cache space of each node, an applicable cache mode for each second operation object on each node;

[0048] Determine that the applicable cache mode for each third operation object belonging only to the other type on each of the nodes is remote cache;

[0049] The policy delivery module is used to send the applicable cache mode of each operation object on each node to each node, so that each node caches data according to the applicable cache mode of each operation object received in the next decision cycle.

[0050] In a third aspect, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory stores a software program, and when the electronic device is running, the processor executes the software program to implement the cache mode decision method as described in the first aspect above.

[0051] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the cache mode decision method as described in the first aspect is implemented.

[0052] In a fifth aspect, the present invention provides a program product, which, when executed by a processor, implements the cache mode decision method as described in the first aspect.

[0053] Compared with the prior art, the embodiment of the present invention provides a cache mode decision method, device, electronic device, storage medium and program product. The method is applied to a decision system that is connected to each node of a distributed system. The decision system includes a log database, and the log database includes cache operation logs reported by each node. The cache operation log includes operation time and operation object. Among them, firstly, all cache operation logs whose operation time belongs to the current decision cycle are queried from the log database; based on all the queried cache operation logs, at least one data type to which each operation object belongs in the current decision cycle is determined; based on at least one data type to which each operation object belongs, the applicable cache mode for each operation object on each node is determined; the applicable cache mode for each operation object on each node is sent to each node respectively, so that each node performs data caching according to the applicable cache mode for each operation object received in the next decision cycle. In this way, the applicable cache mode for each operation object at each node can be found for use by the node in the next decision cycle. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.

[0055] Figure 1 The present invention is a schematic diagram of writing data to the local cache in the prior art.

[0056] Figure 2 A schematic diagram of an application scenario provided by an embodiment of the present invention.

[0057] Figure 3 A schematic diagram of a flow chart of a cache mode decision method provided in an embodiment of the present invention.

[0058] Figure 4 A schematic diagram of a task configuration interface provided by an embodiment of the present invention.

[0059] Figure 5 A schematic diagram of the time relationship provided by an embodiment of the present invention.

[0060] Figure 6 A schematic diagram of the structure of a cache mode decision device provided in an embodiment of the present invention.

[0061] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0062] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.

[0063] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0064] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.

[0065] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.

[0066] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.

[0067] In a distributed system, cache is usually used to store frequently accessed data, which greatly speeds up the reading of data and reduces response time. It also reduces frequent requests to databases and other backend services, reducing the load on these systems.

[0068] Usually, there is more than one caching method in a distributed system. The following two methods are compared: local caching (such as in-process caching) and independently deployed remote caching systems (such as Redis caching system and Memcached caching system):

[0069] (1) Local caching: This method does not require additional deployment and configuration, and the access speed is very fast. However, it is limited by the application memory size, and in order to ensure that all nodes in the distributed system can access the same data, a node must synchronize the cache to other nodes after writing it. See Figure 1 If the client uploads data to node 1 of the distributed system x, and node 1 writes the data to the local cache area, node 1 will synchronize the written data to each other node through the nacos service to ensure the consistency of the cache data of each node.

[0070] (2) Remote caching system: This method requires additional deployment, but has strong availability, can dynamically expand capacity, and supports data persistence. Compared with local caching, the access speed of remote caching system is slower.

[0071] Therefore, in a distributed system, for different frequently accessed data, how to determine the cache method suitable for each data from all the cache methods is a problem that needs to be considered. In the prior art, R&D personnel usually rely on their own experience and cache knowledge reserves to predetermine the cache method for different data, which is not only time-consuming and laborious, but also has to determine the cache method, which is difficult to change later.

[0072] Based on the discovery of the above technical problems, the inventors have proposed the following technical solutions to solve or improve the above problems through creative work. It should be noted that the defects in the solutions in the above prior art are the results obtained by the inventors after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed in the embodiments of the present application for the above problems below should all be the contributions made by the inventors to the present application in the process of invention and creation, and should not be understood as technical contents known to those skilled in the art.

[0073] The embodiment of the present invention provides a cache mode decision method, which can be applied to a decision system, the decision system can be connected to each node of multiple distributed systems, and the decision system is used to make cache mode decisions for each distributed system. The following takes a distributed system as an example to introduce in detail the process of the decision system making cache mode decisions for the distributed system.

[0074] See also Figure 2 , Figure 2 The following is a schematic diagram of an application scenario of an embodiment of the present invention. The decision system is in communication connection with each node of the distributed system, and the distributed system is deployed with an independent remote cache system, which may be, but is not limited to, a Redis cache system, a Memcached cache system, a Couchbase cache system, etc. At the same time, each node of the distributed system has a local cache area.

[0075] In this embodiment, the decision system may be independently deployed in a server. The decision system may include a log database, and the log database is used to store cache operation logs reported by each node in the distributed system.

[0076] The cache operation log includes the reporting node ID, operation time, operation command, operation object and its corresponding operation data. Since the data in the cache is mostly stored in the form of key-value pairs, the operation object is the key in the key-value pair, and the operation data is the value in the key-value pair.

[0077] Optionally, the decision system may make a cache mode decision for the distributed system every other decision cycle. The following takes the current decision cycle as an example to introduce the process of a cache mode decision.

[0078] Please refer to Figure 3 , Figure 3 A schematic flow chart of a cache mode decision method provided in an embodiment of the present invention, the method comprises the following steps S201-S204.

[0079] S201. Query all cache operation logs whose operation time belongs to the current decision cycle from the log database.

[0080] S202: Determine at least one data type to which each operation object in the current decision cycle belongs based on the operation data volume and operation type of each cache operation log queried.

[0081] Optionally, the data type may include hotspot type, large value type and other types, and an operation object may belong to only one data type or two data types at the same time. For example, an operation object belongs to both hotspot type and large value type, or an operation object belongs to both large value type and other types.

[0082] S203: Determine an applicable cache mode for each operation object on each node based on at least one data type to which each operation object belongs.

[0083] In this embodiment, for each operation object involved in the current decision cycle, the applicable cache modes on different nodes may be the same or different.

[0084] S204: Send the applicable cache mode of each operation object on each node to each node respectively, so that each node caches data according to the received applicable cache mode of each operation object in the next decision cycle.

[0085] Under normal circumstances, the data type of an operation object will not change suddenly at a certain moment, but will change over time. Therefore, the applicable caching method for each operation object on each node determined by using all cache operation logs of the current decision cycle can be used by each node in the next decision cycle.

[0086] The cache mode decision method provided by the embodiment of the present invention first queries all cache operation logs whose operation time belongs to the current decision cycle from the log database; based on all the cache operation logs queried, determines at least one data type to which each operation object belongs in the current decision cycle; based on at least one data type to which each operation object belongs, determines the applicable cache mode for each operation object on each node; and sends the applicable cache mode for each operation object on each node to each node respectively, so that each node performs data cache according to the received applicable cache mode for each operation object in the next decision cycle. In this way, the applicable cache mode for each operation object at each node can be found for use by the node in the next decision cycle.

[0087] In an optional implementation, the decision system needs engineering personnel to perform task configuration for making cache mode decisions for the distributed system. Correspondingly, before the above step S201, the method may further include the following steps S101 to S104.

[0088] S101. Display a task configuration interface of a distributed system.

[0089] Optionally, the engineer can open a setting interface for the distributed system, which can display a system list. The system list can include each distributed system managed by the decision system. Clicking one of the distributed systems can enter the task configuration interface of the distributed system.

[0090] In this embodiment, the task configuration interface may include multiple configuration input boxes and a create button.

[0091] S102: In response to a user clicking operation on a create button, obtaining decision configuration data input by the user in a plurality of configuration input boxes.

[0092] In this embodiment, the engineer can enter various configuration data in each configuration input box and then click the Create button. Among them, the decision configuration data may include reporting sampling rate, cache mode information, threshold configuration data and decision cycle. The cache mode information includes a default cache mode and multiple optional cache modes, and the threshold configuration data may include an operation volume threshold, an operation frequency threshold, and a read-write ratio threshold.

[0093] S103: Send the reporting sampling rate to each node of the distributed system, so that each node reports the cache operation log according to the reporting sampling rate.

[0094] In this embodiment, the decision system will send the reporting sampling rate and the default caching method to each node of the distributed system, so that each node can cache data according to the default caching method in the initial stage, and immediately start the asynchronous reporting thread, which is responsible for reporting the cache operation log according to the reporting sampling rate.

[0095] S104: Generate a decision task for the distributed system based on the cache mode information, the threshold configuration data, and the decision cycle, so as to make a cache mode decision for the distributed system according to the decision task.

[0096] In this embodiment, the decision system generates a decision task for the distributed system based on the cache mode information, the threshold configuration data, and the decision cycle, so as to make a cache mode decision for the distributed system according to the decision task.

[0097] For an optional example, see Figure 4 , Figure 4 A schematic diagram of a task configuration interface provided in an embodiment of the present invention. In the task configuration interface of the distributed system S, engineers can enter the reporting sampling rate, operation volume threshold, operation frequency threshold, and read-write ratio threshold, click the drop-down list to check the cache mode list and the default cache mode, and finally click the Create button to complete the creation of the decision task. This example is only an example and is not limited here.

[0098] After the decision-making task is configured for the distributed system, each node of the distributed system will report its own cache operation log according to the reporting sampling rate. Since the cache data that can be operated on different nodes is consistent, in the log database, in any two cache operation logs, the operation objects are the same or different, and the reporting node identifiers are also the same or different.

[0099] In an optional implementation, the data type to which the operation object belongs needs to be further determined based on statistics of relevant data in the cache operation log. Correspondingly, the process of determining at least one data type to which each operation object in the current decision cycle belongs based on all the cache operation logs queried in the above step S202 may include the following sub-steps S2021 to S2027.

[0100] S2021. For each cache operation log found out, count the amount of operation data in the cache operation log, and determine the operation type to which the cache operation log belongs based on the operation command in the cache operation log.

[0101] In this embodiment, the operation type is a read operation or a write operation. In a cache operation log, the operation data volume of the operation data is the data size of the value in the key-value pair, and the operation command can be classified as a read operation or a write operation.

[0102] S2022: Classify all cache operation logs found out according to different operation objects, and obtain at least one cache operation log corresponding to each operation object.

[0103] S2023. For each operation object, based on the operation data volume of each cache operation log corresponding to the operation object, calculate the average operation data volume of the operation object.

[0104] S2024: Calculate the operation frequency of the operation object based on all the cache operation logs found out, and calculate the read-write ratio of the operation object based on the operation type of each cache operation log corresponding to the operation object.

[0105] In this embodiment, the operation frequency of an operation object = the number of cache operation logs corresponding to the operation object / the number of all cache operation logs queried. And the read-write ratio of an operation object = the number of read operations in all cache operation logs corresponding to the operation object / the number of write operations in all cache operation logs corresponding to the operation object.

[0106] S2025. If the average value of the operation data volume is not lower than the preset operation volume threshold, it is confirmed that the data type of the operation object is a large value type.

[0107] S2026: If the operation frequency is not lower than a preset operation frequency threshold and the read-write ratio is not lower than a preset read-write ratio threshold, it is determined that the data type of the operation object is a hotspot type.

[0108] S2027. If the average value of the operation data volume is lower than the operation volume threshold, the operation frequency is lower than the operation frequency threshold, and the read-write ratio is lower than the read-write ratio threshold, it is confirmed that the data type of the operation object belongs to other types.

[0109] Therefore, after executing step S2022, steps S2023 to S2027 are executed for each operation object to determine at least one data type to which each operation object belongs.

[0110] In an optional implementation, all operation objects may be classified according to the data types to which they belong, so as to obtain each first operation object whose data type belongs only to the hotspot type, each second operation object whose data type belongs to the large value type, and each third operation object whose data type belongs only to other types. Therefore, step S203 may include the following three parallel or serial sub-steps S2031 to S2033:

[0111] S2031. Determine that the applicable cache mode for each first operation object that is only of the hotspot type on each node is local cache.

[0112] In this embodiment, for the first operation object (referred to as hot key) whose data type is only a hotspot type, it is directly confirmed that the applicable cache mode on each node is local cache, because the access frequency of hotspot operation objects is very high. When a hot key is frequently accessed, it may become a performance bottleneck of the system, especially in high-concurrency scenarios, which may cause cache avalanche, so hot key local cache helps to improve the response efficiency of access.

[0113] S2032: Determine an applicable cache mode for each second operation object on each node based on the total amount of operation data of all second operation objects of large value type and the latest remaining local cache space of each node.

[0114] In this embodiment, each second operation object (referred to as a big key) whose data type includes a large value type represents a key with a large amount of stored valua data. When a big key is used for operations (such as deletion and update), it may take a long time to perform operations, affecting performance, so it is preferred to consider whether it can be cached locally. However, a big key may occupy more space in the memory, and in the case of insufficient memory, it can only be cached in a remote cache system.

[0115] S2033. Determine that the applicable cache mode for each third operation object that belongs only to other types on each node is remote cache.

[0116] In this embodiment, for the third operation object whose data type only belongs to other types, it is directly confirmed that the applicable cache method on each node is remote cache. Because the access volume of other types is not high and the operation data volume is not large, and the response efficiency requirement for access is not high, it can be directly stored in the remote cache system.

[0117] In an optional implementation, the cache operation log may also include the remaining space of the local cache. For a second operation object whose data type includes a large value type, the second operation object may only belong to the large value type, or the second operation object may also belong to the hotspot type or other types while belonging to the large value type. Since the amount of operation data of each second operation object belonging to the large value type is large, from the perspective of the response efficiency of data access, it is better to cache the second operation object locally. However, the local cache space of the node is limited, and the remaining space of the local cache of the node needs to be considered to determine whether the applicable cache method is local cache or remote cache. Correspondingly, the above step S2032 may include the following sub-steps S20321~S20324.

[0118] S20321. Calculate the total amount of operation data of all second operation objects based on the amount of operation data of each cache operation log corresponding to each second operation object.

[0119] S20322. For each node in the distributed system, obtain the target cache operation log belonging to the node and having the latest operation time from all the cache operation logs queried, and obtain the latest local cache remaining space of the node from the target cache operation log.

[0120] In this embodiment, for each node in the distributed system, a target cache operation log with the latest operation time can be found from all cache operation logs belonging to the node, and the latest local cache remaining space of the node can be obtained from the target cache operation log.

[0121] S20323. If the total amount of operation data is greater than the latest remaining space of the local cache of the node, confirm that the applicable cache mode for each second operation object on the node is remote cache.

[0122] In this embodiment, for each node of the distributed system, if the total amount of operation data of all second operation objects is greater than the latest remaining space in the local cache of the node, it means that the local cache of the node is not sufficient to accommodate all the second operation objects. Therefore, the applicable caching method for each second operation object on the node can only be remote caching.

[0123] S20324: If the total amount of operation data is equal to or less than the latest remaining space of the local cache of the node, confirm that the applicable cache mode for each second operation object on the node is local cache.

[0124] In this embodiment, for each node of the distributed system, if the total amount of operation data of all second operation objects is equal to or less than the latest remaining space of the local cache of the node, it means that the local cache of the node is sufficient to accommodate all the second operation objects, so the applicable caching method for each second operation object on the node can be local caching.

[0125] In an optional implementation, the decision system may also include a decision database. After determining the applicable caching method for each operation object on each node in the current decision cycle, the decision system may also form a decision list of the applicable caching method for each operation object on each node in the current decision cycle and store it in the decision database.

[0126] Therefore, the decision database includes decision lists of several historical decision cycles, and each decision list includes data types and applicable cache methods of multiple operation objects. By using the data in the decision database, the data types and optimal cache methods of each operation object in a certain period in the future can be predicted in advance. Correspondingly, the cache method decision method can also include the following steps S301~S304.

[0127] S301. Obtain from a decision database a decision list of each reference historical decision cycle corresponding to the decision cycle to be predicted within N consecutive historical time periods.

[0128] In this embodiment, the duration of the historical period is equal to the sum of the durations of several historical decision cycles. The N consecutive historical periods can be consecutive natural days, or every Monday, Tuesday, or Wednesday for consecutive weeks.

[0129] In the optional example, assuming that the decision cycle T = 1 hour, then a day includes 24 decision cycles (T1~T24). If the decision cycle to be predicted is the first decision cycle of the second day of the current moment (i.e. T1), then please combine Figure 5 , the N consecutive historical periods can be the 7 consecutive days before the current moment, then what is obtained from the decision database is the decision list of the first decision cycle T1 of each day in the 7 days before the current moment, thereby obtaining 7 decision lists. This example is only an example, and the embodiment of the present invention does not limit the length of the decision cycle, the specific time of the decision cycle to be predicted, the continuous relationship of the N historical periods, and the length of the historical periods.

[0130] S302: Generate a decision change sequence vector based on the decision list of each reference historical decision cycle.

[0131] In this embodiment, the decision change sequence vector may reflect the occurrence frequency of the operation object, the change of the data type and the change of the cache mode. Optionally, the sub-step of S302 may include:

[0132] S3021. For each operation object in all reference historical decision cycles, based on the decision lists of all reference historical decision cycles, count the occurrence frequency, data type change, and cache mode change of the operation object;

[0133] S3022, based on the occurrence frequency, data type change and cache mode change of each operation object, respectively generate a change sequence sub-vector for each operation object;

[0134] S3023. Combine the change sequence sub-vectors of all operation objects to obtain a decision change sequence vector.

[0135] In this embodiment, feature extraction is first performed on each operation object in all reference historical decision cycles to obtain the occurrence frequency, data type change and cache mode change of each operation object, and then a change sequence sub-vector of each operation object can be generated respectively. Finally, the change sequence sub-vectors of all operation objects are combined to obtain a decision change sequence vector.

[0136] S303: Input the decision change sequence vector into a pre-trained prediction model to obtain a prediction decision list of the decision cycle to be predicted.

[0137] In this embodiment, the prediction decision list obtained includes data types and optimal cache modes of multiple operation objects. Optionally, the prediction model may adopt a long short-term memory (LSTM) network model.

[0138] S304: Send the prediction decision list to each node, so that each node can preload each operation object in advance according to the optimal cache method before the prediction decision cycle.

[0139] In this embodiment, the prediction decision list is sent to each node, so that each node can preload each operation object in advance according to the optimal cache method before the prediction decision cycle to reduce access delay.

[0140] Optionally, engineers can modify the configuration of the decision tasks of the distributed system on the decision system based on the cache usage of the distributed system.

[0141] It should be noted that the execution order of each step in the above method embodiment is not limited to that shown in the drawings, and the execution order of each step shall be based on the actual application situation.

[0142] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0143] The present invention utilizes all cache operation logs of the current decision cycle to first determine at least one data type to which each operation object belongs, and then determines the applicable cache mode of each operation object on each node, so that the applicable cache mode of each operation object on each node can be sent to each node respectively, so that each node can cache data according to the received applicable cache mode of each operation object in the next decision cycle, so that the applicable cache mode of each node of the distributed system for each operation object in the next decision cycle is automatically determined without relying on the configuration of R&D personnel based on experience, saving R&D time, and in different decision cycles, the applicable cache mode of the determined operation object is changed in real time based on the cache operation situation of the previous decision cycle, that is: the applicable cache mode of each operation object can be adjusted based on the real-time access load of the distributed system;

[0144] The present invention also provides a prediction function for future decision cycles to be predicted. Based on the decision list of each reference historical decision cycle corresponding to the decision cycle to be predicted in N consecutive historical time periods, a decision change sequence vector can be generated. The decision change sequence vector is input into the prediction model to obtain a predicted decision list for the decision cycle to be predicted. The predicted decision list includes data types and optimal caching methods for multiple operation objects. In this way, each node in the distributed system can pre-load the cache of each operation object in advance according to the optimal caching method before the decision cycle to be predicted, so as to reduce the access delay of the distributed system.

[0145] In order to execute the corresponding steps in the above method embodiment and various possible implementation modes, an implementation method of a cache mode decision device is given below.

[0146] See also Figure 6 , Figure 6 The schematic diagram of the structure of the cache mode decision device provided by the embodiment of the present invention is shown. The cache mode decision device 200 is applied to the decision system, and the decision system is in communication connection with each node of the distributed system. The decision system includes a log database, and the log database is used to store the cache operation log reported by each node. The cache operation log includes the operation time and the operation object. The cache mode decision device 200 includes: a periodic query module 210, a type determination module 220, a cache decision module 230 and a policy delivery module 240.

[0147] The period query module 210 is used to query all cache operation logs whose operation time belongs to the current decision period from the log database;

[0148] The type determination module 220 is used to determine at least one data type of each operation object in the current decision cycle based on the operation data volume and operation type of each cache operation log queried; the data types include hotspot type, large value type and other types;

[0149] A cache decision module 230, configured to determine an applicable cache mode for each operation object on each node based on at least one data type to which each operation object belongs;

[0150] The policy delivery module 240 is used to send the applicable cache mode of each operation object on each node to each node, so that each node performs data cache according to the received applicable cache mode of each operation object in the next decision cycle.

[0151] Optionally, the operation objects in any two cache operation logs are the same or different; the cache operation log also includes the operation command and the operation data corresponding to the operation object. The type determination module 220 can be specifically used for: for each cache operation log queried, counting the operation data volume of the operation data in the cache operation log, and determining the operation type to which the cache operation log belongs based on the operation command in the cache operation log; the operation type is a read operation or a write operation; classifying all the cache operation logs queried according to the different operation objects, and obtaining at least one cache operation log corresponding to each operation object; for each operation object, calculating the average operation data volume of the operation object based on the operation data volume of each cache operation log corresponding to the operation object; calculating the operation frequency of the operation object based on all the cache operation logs queried, and calculating the read-write ratio of the operation object based on the operation type of each cache operation log corresponding to the operation object; if the average operation data volume is not lower than the preset operation volume threshold, confirming that the data type of the operation object belongs to the large value type; if the operation frequency is not lower than the preset operation frequency threshold and the read-write ratio is not lower than the preset read-write ratio threshold, confirming that the data type of the operation object belongs to the hotspot type; if the average operation data volume is lower than the operation volume threshold, the operation frequency is lower than the operation frequency threshold, and the read-write ratio is lower than the read-write ratio threshold, confirming that the data type of the operation object belongs to other types.

[0152] Optionally, the cache decision module 230 can be specifically used to classify all operation objects according to the data types they belong to, to obtain each first operation object whose data type only belongs to the hotspot type, each second operation object whose data type belongs to the large value type, and each third operation object whose data type only belongs to other types; to determine that the applicable cache mode on each node for each first operation object that only belongs to the hotspot type is local cache; to determine the applicable cache mode on each node for each second operation object based on the total amount of operation data of all second operation objects that belong to the large value type and the latest local cache remaining space of each node; and to determine that the applicable cache mode on each node for each third operation object that only belongs to other types is remote cache.

[0153] Optionally, the cache operation log also includes the reporting node identifier and the local cache remaining space. The cache decision module 230 can be specifically used to: calculate the total amount of operation data of all second operation objects based on the amount of operation data of each cache operation log corresponding to each second operation object; for each node of the distributed system, obtain the target cache operation log belonging to the node and with the latest operation time from all the queried cache operation logs, and obtain the latest local cache remaining space of the node from the target cache operation log; if the total amount of operation data is greater than the latest local cache remaining space of the node, confirm that the applicable cache mode for each second operation object on the node is remote cache; if the total amount of operation data is equal to or less than the latest local cache remaining space of the node, confirm that the applicable cache mode for each second operation object on the node is local cache.

[0154] Optionally, the decision system also includes a decision database, which includes a decision list of several historical decision cycles, and the decision list includes data types of multiple operation objects and applicable cache methods. The cache method decision device 200 can also include a prediction module 250, which can be used to: obtain a decision list of each reference historical decision cycle corresponding to the decision cycle to be predicted in N consecutive historical time periods from the decision database; the length of the historical time period is equal to the sum of the lengths of several historical decision cycles; based on the decision list of each reference historical decision cycle, generate a decision change sequence vector; input the decision change sequence vector into a pre-trained prediction model to obtain a predicted decision list for the decision cycle to be predicted; the predicted decision list includes data types of multiple operation objects and the best cache method; send the predicted decision list to each node, so that each node preloads each operation object in advance according to the best cache method before the decision cycle to be predicted.

[0155] Optionally, the prediction module 250 can be specifically used to: for each operation object in all reference historical decision cycles, based on the decision lists of all reference historical decision cycles, count the occurrence frequency, data type changes and cache method changes of the operation object; based on the occurrence frequency, data type changes and cache method changes of each operation object, generate a change sequence sub-vector for each operation object; combine the change sequence sub-vectors of all operation objects to obtain a decision change sequence vector.

[0156] Optionally, the cache mode decision device 200 may also include a configuration module 260, which can be used to: display a task configuration interface of the distributed system; the task configuration interface includes multiple configuration input boxes and a create button; in response to a user clicking the create button, obtain decision configuration data entered by the user in the multiple configuration input boxes; the decision configuration data includes a reporting sampling rate, cache mode information, threshold configuration data and a decision cycle; send the reporting sampling rate to each node of the distributed system, so that each node reports the cache operation log according to the reporting sampling rate; based on the cache mode information, threshold configuration data and decision cycle, generate a decision task for the distributed system to execute a cache mode decision for the distributed system according to the decision task.

[0157] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the cache mode decision device 200 described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0158] See also Figure 7 , Figure 7 The electronic device 300 includes a processor 310 , a memory 320 , and a bus 330 , wherein the processor 310 is connected to the memory 320 via the bus 330 .

[0159] The memory 320 may be used to store software programs, for example, software programs corresponding to the cache mode decision device 200 provided in the embodiment of the present invention. The processor 310 executes various functional applications and data processing to implement the cache mode decision method provided in the embodiment of the present invention by running the software programs stored in the memory 320.

[0160] Among them, the memory 320 can be but is not limited to: RAM (Random Access Memory), ROM (Read Only Memory), FLASH (Flash Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.

[0161] The processor 310 may be an integrated circuit chip with signal processing capability. The processor 310 may be a general-purpose processor, including: CPU (Central Processing Unit), NP (Network Processor), etc.; it may also be: DSP (Digital Signal Processing), ASIC (Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0162] It can be understood that the electronic device 300 can be a server. Figure 7 The structure shown is for illustration only. The electronic device 300 may also include Figure 7 More or fewer components as shown, or with Figure 7 Different configurations are shown. Figure 7 Each component shown in the figure can be implemented by hardware, software or a combination thereof.

[0163] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the cache mode decision method disclosed in the above embodiment is implemented. The computer-readable storage medium can be, but is not limited to, various media that can store program codes, such as a USB flash drive, a mobile hard disk, a ROM, a RAM, a PROM, an EPROM, an EEPROM, a FLASH disk, or an optical disk.

[0164] An embodiment of the present invention further provides a program product, which, when executed by a processor, implements the cache mode decision method disclosed in the above embodiment.

[0165] In summary, the embodiments of the present invention provide a cache mode decision method, device, electronic device, storage medium and program product. The method is applied to a decision system that is communicatively connected to each node of a distributed system. The decision system includes a log database, and the log database includes cache operation logs reported by each node. The cache operation log includes operation time and operation object. Among them, firstly, all cache operation logs whose operation time belongs to the current decision cycle are queried from the log database; based on all the queried cache operation logs, at least one data type to which each operation object belongs in the current decision cycle is determined; based on at least one data type to which each operation object belongs, the applicable cache mode for each operation object on each node is determined; the applicable cache mode for each operation object on each node is sent to each node respectively, so that each node performs data caching according to the applicable cache mode for each operation object received in the next decision cycle. In this way, the applicable cache mode for each operation object at each node can be found for use by the node in the next decision cycle.

[0166] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A cache mode decision method, characterized in that: Applied to a decision-making system, the decision-making system is in communication connection with each node of a distributed system, the decision-making system includes a log database, the log database is used to store cache operation logs reported by each node, the cache operation logs include operation time, operation object, reporting node identifier and local cache remaining space; the method includes: Querying from the log database all cache operation logs whose operation time belongs to the current decision cycle; Based on the operation data volume and operation type of each cache operation log queried, determine at least one data type to which each operation object in the current decision cycle belongs; the data types include hotspot type, large value type, and other types; Determine that the applicable cache mode for each first operation object belonging only to the hotspot type on each node is local cache; Determine, based on the total amount of operation data of all second operation objects of the large value type and the latest remaining local cache space of each node, an applicable cache mode for each second operation object on each node; Determine that the applicable cache mode for each third operation object belonging only to the other type on each of the nodes is remote cache; Sending the applicable cache mode of each operation object on each node to each node respectively, so that each node caches data according to the received applicable cache mode of each operation object in the next decision cycle; The step of determining the applicable cache mode for each of the second operation objects on each of the nodes based on the total amount of operation data of all the second operation objects of the large value type and the latest remaining local cache space of each node includes: Based on the amount of operation data of each cache operation log corresponding to each second operation object, the total amount of operation data of all second operation objects is calculated; for each node of the distributed system, the target cache operation log belonging to the node and with the latest operation time is obtained from all the queried cache operation logs, and the latest local cache remaining space of the node is obtained from the target cache operation log; if the total amount of operation data is greater than the latest local cache remaining space of the node, it is confirmed that the applicable cache mode for each second operation object on the node is remote cache; if the total amount of operation data is equal to or less than the latest local cache remaining space of the node, it is confirmed that the applicable cache mode for each second operation object on the node is local cache.

2. The method according to claim 1, characterized in that The operation objects in any two cache operation logs are the same or different; the cache operation log also includes an operation command and operation data corresponding to the operation object; The step of determining at least one data type to which each operation object in the current decision cycle belongs based on the operation data volume and operation type of each cache operation log queried includes: For each cache operation log queried, count the operation data volume of the operation data in the cache operation log, and determine the operation type to which the cache operation log belongs based on the operation command in the cache operation log; the operation type is a read operation or a write operation; Classify all cache operation logs found out according to the different operation objects, and obtain at least one cache operation log corresponding to each operation object; For each of the operation objects, based on the operation data volume of each cache operation log corresponding to the operation object, calculate the average operation data volume of the operation object; Calculating the operation frequency of the operation object based on all cache operation logs queried, and calculating the read-write ratio of the operation object based on the operation type of each cache operation log corresponding to the operation object; If the average value of the operation data volume is not lower than the preset operation volume threshold, it is confirmed that the data type of the operation object belongs to the large value type; If the operation frequency is not lower than a preset operation frequency threshold and the read-write ratio is not lower than a preset read-write ratio threshold, it is confirmed that the data type of the operation object belongs to a hotspot type; If the average value of the operation data volume is lower than the operation volume threshold, the operation frequency is lower than the operation frequency threshold, and the read-write ratio is lower than the read-write ratio threshold, it is confirmed that the data type of the operation object belongs to other types.

3. The method according to claim 1, characterized in that The decision system further includes a decision database, the decision database includes a decision list of several historical decision cycles, the decision list includes data types of multiple operation objects and applicable cache methods; the method further includes: Obtaining from the decision database a decision list of each reference historical decision cycle corresponding to the decision cycle to be predicted within N consecutive historical time periods; the duration of the historical time period is equal to the sum of the durations of the several historical decision cycles; Generate a decision change sequence vector based on the decision list of each reference historical decision cycle; Inputting the decision change sequence vector into a pre-trained prediction model to obtain a prediction decision list of the decision cycle to be predicted; the prediction decision list includes data types and optimal caching methods of multiple operation objects; The prediction decision list is sent to each of the nodes, so that each of the nodes preloads each of the operation objects in advance according to the optimal cache mode before the decision cycle to be predicted.

4. The method according to claim 3, characterized in that The step of generating a decision change sequence vector based on the decision list of each reference historical decision cycle comprises: For each operation object in all reference historical decision cycles, based on the decision lists of all reference historical decision cycles, statistics are collected on the occurrence frequency, data type changes, and cache mode changes of the operation object; Based on the occurrence frequency, data type change and cache mode change of each operation object, respectively generate a change sequence sub-vector for each operation object; The change sequence sub-vectors of all the operation objects are combined to obtain the decision change sequence vector.

5. The method according to claim 1, characterized in that Before the step of querying from the log database all cache operation logs whose operation time belongs to the current decision cycle, the method further includes: Displaying the task configuration interface of the distributed system; the task configuration interface includes a plurality of configuration input boxes and a create button; In response to a user clicking operation on the create button, acquiring decision configuration data input by the user in the plurality of configuration input boxes; the decision configuration data includes reporting sampling rate, cache mode information, threshold configuration data and decision cycle; Sending the reporting sampling rate to each node of the distributed system, so that each of the nodes reports the cache operation log according to the reporting sampling rate; Based on the cache mode information, the threshold configuration data and the decision cycle, a decision task of the distributed system is generated, so as to perform a cache mode decision on the distributed system according to the decision task.

6. A cache mode decision device, characterized in that: Applied to a decision-making system, the decision-making system is in communication connection with each node of a distributed system, the decision-making system includes a log database, the log database is used to store cache operation logs reported by each node, the cache operation logs include operation time, operation object, reporting node identifier and local cache remaining space; the device includes: A period query module, used to query all cache operation logs whose operation time belongs to the current decision period from the log database; A type determination module, used to determine at least one data type to which each operation object in the current decision cycle belongs based on the operation data volume and operation type of each cache operation log queried; the data types include hotspot type, large value type and other types; Cache decision module for: Determine that the applicable cache mode for each first operation object belonging only to the hotspot type on each node is local cache; Determine, based on the total amount of operation data of all second operation objects of the large value type and the latest remaining local cache space of each node, an applicable cache mode for each second operation object on each node; Determine that the applicable cache mode for each third operation object belonging only to the other type on each of the nodes is remote cache; A policy delivery module, used for sending the applicable cache mode of each operation object on each node to each node, so that each node performs data cache according to the applicable cache mode of each operation object received in the next decision cycle; The cache decision module is used to determine the applicable cache mode of each second operation object on each node based on the total amount of operation data of all second operation objects belonging to the large value type and the latest local cache remaining space of each node, specifically for: Based on the amount of operation data of each cache operation log corresponding to each second operation object, the total amount of operation data of all second operation objects is calculated; for each node of the distributed system, the target cache operation log belonging to the node and with the latest operation time is obtained from all the queried cache operation logs, and the latest local cache remaining space of the node is obtained from the target cache operation log; if the total amount of operation data is greater than the latest local cache remaining space of the node, it is confirmed that the applicable cache mode for each second operation object on the node is remote cache; if the total amount of operation data is equal to or less than the latest local cache remaining space of the node, it is confirmed that the applicable cache mode for each second operation object on the node is local cache.

7. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a software program, and when the electronic device is running, the processor executes the software program to implement the cache mode decision method as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the cache mode decision method according to any one of claims 1 to 5 is implemented.

9. A program product, characterized in that When the program product is executed by a processor, the cache mode decision method according to any one of claims 1 to 5 is implemented.