WO2022156452A1 - Cache management method and apparatus, and device - Google Patents

Cache management method and apparatus, and device Download PDF

Info

Publication number
WO2022156452A1
WO2022156452A1 PCT/CN2021/139427 CN2021139427W WO2022156452A1 WO 2022156452 A1 WO2022156452 A1 WO 2022156452A1 CN 2021139427 W CN2021139427 W CN 2021139427W WO 2022156452 A1 WO2022156452 A1 WO 2022156452A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
write
cache
request
written
Prior art date
Application number
PCT/CN2021/139427
Other languages
French (fr)
Chinese (zh)
Inventor
胥皇
单卫华
Original Assignee
华为云计算技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为云计算技术有限公司 filed Critical 华为云计算技术有限公司
Publication of WO2022156452A1 publication Critical patent/WO2022156452A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting

Definitions

  • the present application relates to the field of cache, and in particular, to a cache management method, apparatus and device.
  • Application-level caching is a common storage component used to accelerate data access in systems such as databases, content distribution networks, and data storage.
  • the main function of the cache is to temporarily save data that will be repeatedly accessed by the system in the near future, thereby reducing the average latency of data access.
  • Cache media has fast access (read and write) speed but small storage capacity.
  • the core competitiveness of cache is high hit rate. Among them, the hit rate indicates the proportion of data accessing the cache and getting the returned data.
  • the present application provides a cache management method, which can improve the cache hit rate.
  • a first aspect of the present application provides a cache management method.
  • the cache management method is used in a cache management device, and the method includes: receiving a first data write request, where the first data write request is used to request to write data stored in a hard disk. Write the first data into the cache; train the cache to write the prediction model according to the relevant parameters of the first data; write the first data into the cache; receive a second data write request, the second data write request is used for Request to write the second data in the hard disk into the cache; according to the cache write prediction model, determine whether to write the second data into the cache.
  • the cache management method improves the write probability prediction accuracy of the data to be written and improves the cache hit rate by training the cache write prediction model online.
  • the method further includes: receiving the first batch of data write requests; and determining the first data write request and the second data write request from the first batch of data write requests according to a sampling rule input request.
  • the method further includes: obtaining an identifier of the data to be written carried by each data write request in the first batch of data write requests; determining each data write in the first batch of data write requests If the hash value of the identifier of the data to be written carried by the request can be divisible by the sampling value, it is the first data write request; determine the value of the data to be written carried by each data write request in the first batch of data write requests. It is the second data write request that the identified hash value is not divisible by the sample value.
  • the method further includes: receiving a second batch of data write requests; and determining, according to the trained cache write prediction model, whether to write the second batch of data into the to-be-written data corresponding to the second batch of data write requests At least one data is written to this cache.
  • the method further includes: at least one of an average size of data in the cache, a historical total number of write requests per cycle, a historical total number of read requests per cycle, and an average elimination cycle of data in the cache, and
  • the relevant parameters of the first data are used as the training input of the cache write prediction model; according to the request situation and the elimination situation of the first data in the average elimination period after the first data request occurs, determine the first data
  • the write probability is used as the training output of the cache to write the prediction model: according to the training input and the training output, the training cache writes the prediction model.
  • the relevant parameters of the first data include at least one of the following: the number of historically requested writes of the first data, and the number of historically requested reads of the first data.
  • the method further includes: obtaining a write threshold; obtaining a write probability of the second data according to the cache write prediction model; according to the write threshold and the write probability of the second data, Determine whether to write the second data to the cache.
  • the method further includes: at least one of the average size of the data in the cache, the average elimination period of the data in the cache, the historical total number of write requests per cycle, and the historical total number of read requests per cycle,
  • the parameter related to the second data is used as the prediction input of the cache write prediction model; the prediction input is used as the input of the trained cache write prediction model to obtain the write probability of the second data.
  • a second aspect of the present application provides a cache management device, the device includes a communication unit and a processing unit: the communication unit is configured to receive a first data write request, and the first data write request is used to request that a hard disk be stored in a The first data is written into the cache; the processing unit is used for training the cache to write the prediction model according to the relevant parameters of the first data; the first data is written into the cache; the communication unit is also used for receiving the second a data write request, the second data write request is used to request to write the second data in the hard disk into the cache; the processing unit is also used to determine whether to write the second data according to the cache write prediction model write to the cache.
  • the communication unit is configured to receive the first batch of data write requests; the processing unit is configured to determine the first data write request from the first batch of data write requests according to a division rule and the second data write request.
  • the processing unit is configured to obtain the identifier of the data to be written carried by each data write request in the first batch of data write requests; determine each data write request in the first batch of data write requests The hash value of the identifier of the data to be written carried by the incoming request can be divisible by the sampling value is the first data write request; determine the data to be written carried by each data write request in the first batch of data write requests The hash value of the identifier that is not divisible by the sample value is the second data write request.
  • the communication unit is configured to receive the second batch of data write requests; the processing unit is configured to determine whether to write the second batch of data to the request according to the trained cache write prediction model At least one piece of the corresponding data to be written is written into the cache.
  • the processing unit is used for at least one of the average size of data in the cache, the historical total number of write requests per cycle, the historical total number of read requests per cycle, and the average elimination cycle of data in the cache, and the relevant parameters of the first data as the training input of the cache write prediction model; according to the request situation and the elimination situation of the first data in the average elimination period after the first data request occurs, determine the first data
  • the write probability of is used as the training output of the cache to write the prediction model: according to the training input and the training output, the training cache writes the prediction model.
  • the relevant parameters of the first data include at least one of the following: the number of historically requested writes of the first data, and the number of historically requested reads of the first data.
  • the communication unit is configured to obtain a write threshold; the processing unit is configured to obtain a write probability of the second data according to the cache write prediction model; according to the write threshold and the first The writing probability of the second data determines whether to write the second data into the cache.
  • the processing unit is configured to at least one of the average size of data in the cache, the average elimination cycle of data in the cache, the historical total number of write requests per cycle, and the historical total number of read requests per cycle , and parameters related to the second data are used as the prediction input of the cache write prediction model; the prediction input is used as the input of the trained cache write prediction model to obtain the write probability of the second data.
  • a third aspect of the present application provides a computing device cluster, including at least one computing device, each computing device including a processor and a memory; the processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, to cause the computing device to perform the method as provided by the first aspect or any possible design of the first aspect.
  • a fourth aspect of the present application provides a computer program product comprising instructions which, when executed by a cluster of computer devices, cause the cluster of computer devices to perform a method as provided by the first aspect or any possible design of the first aspect.
  • a fifth aspect of the present application provides a computer-readable storage medium comprising computer program instructions, when the computer program instructions are executed by a cluster of computing devices, the cluster of computing devices executes the first aspect or any possible implementation of the first aspect Design provides methods.
  • FIG. 1 is a schematic diagram of a possible application scenario applicable to the embodiment of the present application.
  • FIG. 2 is a flowchart of a possible cache management method applicable to the embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of a possible cache management apparatus applicable to the embodiment of the present application.
  • FIG. 4 is a schematic structural diagram of a possible computing device suitable for an embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of a possible computing device cluster applicable to the embodiment of the present application.
  • FIG. 6 is a schematic structural diagram of a possible computing device cluster applicable to the embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of a possible computing device cluster applicable to the embodiment of the present application.
  • first and second in the embodiments of the present application are only used for the purpose of description, and cannot be understood as indicating or implying relative importance or implying the number of indicated technical features. Thus, a feature defined as “first” or “second” may expressly or implicitly include one or more of that feature.
  • Cache The middle layer between the fast storage medium and the service system, used to temporarily store recently accessed data and reduce data access latency.
  • Cache write The process of deciding whether to write data to the cache when a data write request arrives at the cache system.
  • Cache hit rate When the initial user accesses the acceleration node, if the node caches the data to be accessed, it is called a hit. If not, you need to go back to the original server to fetch, that is, there is no hit. The process of fetching data is synchronized with user access, so even if new data is fetched again, users will not feel any delay.
  • the hit rate is equal to the sum of hits over hits and no hits.
  • the cache hit rate is one of the important factors for judging the acceleration effect.
  • the access speed of the cache medium is usually faster than the access speed of the system main memory. In a typical scenario, the access speed differs by several orders of magnitude.
  • the memory is usually used as the cache medium of the hard disk and the remote network. Relative to the data scale of the application system, the available storage capacity of the cache medium is extremely small. For example, in a typical Internet service database, the database usually stores petabytes (petabytes, PB) of data, but the cache capacity is only several gigabytes (gigabyte, GB), or even less than 1GB.
  • LRU least recently used
  • FIFO first-in, first-out
  • Cache write refers to judging whether the data has the value of entering the cache system before the data enters the cache medium, and if it has no value, the data will not be put into the cache medium.
  • some systems do not allow data accessed for the first time recently to enter the cache, and data accessed more than the second time are written to the cache.
  • data accessed more than the second time are written to the cache.
  • rules-based or frequency-based writing techniques are also be used.
  • the embodiments of the present application provide a technical solution capable of adaptively adjusting a write strategy, that is, an online self-adaptive-based cache write method.
  • the data-driven algorithm automatically predicts the future hit probability of data when the system is running, and learns the writing model online to quickly adapt to changes in business data and achieve accurate and efficient writing results.
  • the application 102 will be triggered to initiate a data read request to the cache 103 .
  • the application 102 may be a web application, or a third-party application software on a smart terminal or the like.
  • the data read request initiated by the application 102 to the cache 103 will be recorded by the cache management apparatus 104 . Specifically, information such as identification information and request time of the requested data of the data read request will be recorded. At the same time, the historical requested times of the data can also be updated.
  • the cache 103 When the data exists in the cache 103 , the cache 103 will return the data to the application 102 . At the same time, the cache management device 104 will record the data request result. That is, the data read request is responded to.
  • the application 102 When the data does not exist in the cache 103 , the application 102 will initiate a data read request to the hard disk 105 . At the same time, the cache management device 104 will record the data request result. That is, the data read request is not responded to.
  • the hard disk 105 may include a solid-state hard disk, a conventional hard disk, and a hybrid hard disk.
  • the hard disk 105 When the data exists in the hard disk 105 , the hard disk 105 will return the data to the application 102 . At the same time, the cache management device 104 will decide whether to write the data into the cache 103 or not.
  • the request for writing data into the cache 103 is triggered by the user 101 clicking on the application 102 .
  • the system will return the information that the data cannot be found to the application 102.
  • the request for writing data into the cache 103 may be triggered by the application 102 .
  • it can be triggered by the refresh and warm-up of the content delivery network (CDN).
  • CDN content delivery network
  • the application 102 will actively obtain updated data from the origin site. Therefore, when the user 101 accesses the CDN, there is no need to go back to the origin site of the tenant to obtain data. Therefore, when the refresh or warm-up action is triggered, the cache management device 104 will determine whether to write this part of the data into the cache 103 .
  • URL uniform resource locator
  • the following describes a cache writing method 200 provided by the present application.
  • the cache writing method may run on the cache management device 104 .
  • the flowchart of the cache writing method 200 is shown in FIG. 2 .
  • the cache writing method includes four parts: request information record, prediction model training, write judgment and cache data elimination.
  • the request information that the cache management device 104 may receive includes a data write request and a data read request.
  • the request information recording part includes steps S201 to S204.
  • the cache management apparatus 104 receives a data read request.
  • the application 102 will initiate a data read request to the cache management apparatus 104.
  • the cache management device 104 receives the data read request.
  • the data read request indicates that the data in the cache 103 is returned to the application 102 .
  • the cache management apparatus 104 records the request information of the data to be read.
  • the cache management device 104 When a data read request comes, the cache management device 104 will record the information of the data to be read and the request time.
  • the information of the data may be an identifier (ID).
  • ID may also be information such as a universally unique identifier (universally unique identifier, UUID) of the data.
  • UUID universally unique identifier
  • the number of requested reads per cycle of each data can be calculated: the number of requested reads per cycle of each data and the historical average number of requested reads per cycle.
  • the length of the period can be set as required. For example, if the period is 1 second, the requested reads per cycle for the data indicates the number of times that data was requested to be read in 1 second, and the historical average request reads per cycle for the data indicates the data The average number of requested reads per cycle over the historical count period. Among them, the historical count period can be set as required.
  • an 8-byte data group may be maintained for each data.
  • the 8 bytes are equally divided into 32 units.
  • each unit is 2 bits (bits), and each unit number is 1, 2, " ⁇ ", 32.
  • Each unit can represent four states (00, 01, 10, 11) of the number of read requests per cycle of the data, corresponding to no read request, one, two, three and more read requests respectively.
  • the number of read requests per cycle of the data in the past 32 cycles can be recorded. According to the above storage method, it is possible to store a larger number of requested reads per cycle in a smaller storage space.
  • the total number of read requests in each cycle can also be obtained. That is, the total number of requested reads per cycle.
  • the length of the historical time can be set as required.
  • S201 and S202 are not necessary steps. As mentioned above, when the data write request is not triggered by the user 101, but is triggered by a refresh or warm-up action of the application 102, S201 and S202 are not necessary.
  • the cache management apparatus 104 receives the data writing request.
  • the cache management device 104 will receive a data write request.
  • the data write request indicates that the data requested to be written in the hard disk is written into the cache.
  • the application 102 will be triggered to initiate a data write request to the cache 103 .
  • the data write request initiated by the application 102 to the cache 103 will be recorded by the cache management apparatus 104 .
  • the cache 103 When the data requested to be written exists in the cache 103 , the cache 103 will return the data to the application 102 . At the same time, the cache management device 104 will record the data request result. That is, the data read request is responded to.
  • the application 102 When the data requested to be written does not exist in the cache 103 , the application 102 will initiate a data read request to the hard disk 105 . At the same time, the cache management device 104 will record the data request result. That is, the data read request is not responded to.
  • the hard disk 105 When the data exists in the hard disk 105 , the hard disk 105 will return the requested data to the application 102 . At the same time, the cache management device 104 will decide whether to write the requested data into the cache 103 or not. That is, the cache management device 104 receives the write request of the data requested to be written.
  • the request for writing data into the cache 103 is triggered by the user 101 clicking on the application 102 . That is, it is triggered by steps S101 and S102.
  • the request for writing data into the cache 103 may be triggered by the application 102 .
  • it can be triggered by the refresh and warm-up of the content delivery network (CDN). Therefore, the cache management device 104 will receive a write request for the data.
  • CDN content delivery network
  • the cache management apparatus 104 will receive a batch of data write requests in the process of accumulating a certain amount of training data.
  • a certain number can be the sampling threshold, and can also be set as required.
  • the first batch of data write requests indicates a set of a batch of data write requests received by the cache management apparatus 104 within a certain period of time.
  • the first data writing request and the second data writing request in the first batch of data writing requests may be determined according to the sampling rule.
  • the first data writing request or the second data writing request may include one or more data writing requests.
  • the first data mentioned below indicates the data requested to be written in the first data write request.
  • the second data indicates the data requested to be written in the second data write request.
  • the cache management apparatus 104 records the request information of the data to be written.
  • the ID and request time of each data in the first batch of data When the first batch of data writing request comes, record the ID and request time of each data in the first batch of data. Further, at least one of the following parameters can be obtained: the number of requested writes per cycle of each data, the historical average number of requested writes per cycle, and the total number of requested writes per cycle.
  • the length of the period can be set as required. For example, if the period is 1 second, the requested writes per cycle of data indicates the number of times each data is requested to be written in 1 second, and the historical average The average number of writes requested per cycle over the historical count period.
  • the total number of write requests per cycle can be obtained.
  • the indicator indicates the total number of write requests for each data received by the cache management apparatus 104 within one second.
  • the number of requested writes per cycle of each data may be selected to be retained.
  • the data base is large, and the number of writes requested per cycle for a long period of time when the aforementioned data is stored will occupy a large storage space. Therefore, in order to reduce the storage space, methods such as optimizing data storage and shortening the length of the retention time period can be adopted.
  • an 8-byte data group can be maintained for each data. Further, the 8 bytes are equally divided into 32 units. Among them, each unit is 2 bits (bits), and each unit number is 1, 2, " ⁇ ", 32. Each unit can represent four states (00, 01, 10, 11) of the number of writes requested per cycle of the data, corresponding to no write request, one, two, three and more write requests, respectively. In other words, by maintaining an 8-byte data group for each data, the number of write requests per cycle of the data in the past 32 cycles can be recorded. According to the above storage method, it is possible to store a larger number of requested writes per cycle with a smaller storage space.
  • the total number of write requests in each cycle can be obtained. That is, the total number of requested writes per cycle.
  • steps S203 and S204 the execution time of these two steps (steps S203 and S204 ) has no sequence with the execution time of the above-mentioned steps S201 and S202 .
  • steps S203 and S204 may be performed before or after steps S201 and S202.
  • steps S203 and S204 may also be performed simultaneously with steps S201 and S202.
  • the cache write prediction model After receiving the data read request and the data write request in steps S201 to S204, and recording the related information, the cache write prediction model can be trained by using part of the data and the related information. Specifically, the prediction model training part includes steps S205 to S207.
  • the cache management apparatus 104 determines whether the data to be written satisfies the sampling rule.
  • the identifiers of the data to be written obtained in step S204 it can be determined whether the data to be written satisfies the sampling rule.
  • the first data write request and the second data write request in the first batch of data write requests may be determined according to the sampling rule. That is, the first data to be written and the second data to be written in the first batch of data to be written can be determined.
  • the first data to be written indicates the data to be written that satisfies the sampling rule
  • the second data to be written indicates the data to be written that does not meet the sampling rule.
  • the data base is large, and it is difficult to use each piece of data as a training sample for the prediction model. Therefore, a part of the data needs to be sampled as training samples.
  • sampling rate There are at least two factors that affect sampling: sampling rate and sampling rules.
  • the sampling rate indicates the probability that each piece of data is sampled on average, and the value is usually between 0 and 1. The lower the sample rate, the slower the samples are collected.
  • Sampling rules can be determined based on the identity of the data in the system.
  • the sampling rule can be determined according to identifiers such as ID, URL, or UUID.
  • IDs can be strings or numbers. Therefore, after the operation result is obtained by using the ID of the data, whether to sample the data can be determined according to the operation result and the sampling value.
  • the operation method may be a method such as a neural network or a hash algorithm. The embodiment of the present application does not limit the calculation method.
  • the sampling value can be set as required. For example, the sample value can be made equal to the sample rate.
  • the sampling value is used to take the remainder of the hash operation result.
  • the data to be written is regarded as the first data to be written. That is, training data.
  • the remainder of the sampling value to the hash operation result is not 0, the data will not be sampled. That is, go to step S209.
  • the cache management apparatus 104 marks the first data to be written that satisfies the sampling rule.
  • the cache management apparatus 104 may mark the first data to be written.
  • the first data to be written may be marked according to the request situation of the first data to be written within a period of time after the judgment in S205. That is, according to the number of times that the first data to be written is requested to be written and the number of times to be read within an average cache elimination cycle, the labeling situation of the first data to be written can be determined.
  • the length of the period of time can be set as required. The following will take the average cache elimination period as an example for introduction, and how to obtain the average cache elimination period will be introduced in detail in step S213.
  • the first data to be written when the first data to be written satisfies at least one of the following conditions within an average elimination cycle: being requested to write at least once and being requested to read at least once, the first data to be written is at least one of the following conditions: A data to be written is marked as hot data.
  • the first data to be written satisfies both of the following two conditions within an average cache elimination cycle: no writing is requested and no reading is requested, the first data to be written is marked as cold data.
  • the training data may also be marked according to the elimination situation of the first data to be written in an average elimination cycle in the future.
  • the first data to be written is also directly written into the cache while the first data to be written is marked. Since the storage space of the cache is limited, the stored data needs to be eliminated according to the elimination rule.
  • the specific elimination rules will be introduced in detail in S212.
  • the first data to be written is within an average cache elimination cycle and before being eliminated by the cache, neither writing nor reading is requested. After the data is eliminated from the cache, the first data to be written is marked as cold data.
  • the marked state of the data is not modified. After completing the labeling of the data to be written, it may go to step S207 for training the prediction model.
  • the cache management device 104 trains the prediction model according to the record information and the marked first data to be written.
  • the marking information of each first data to be written in S206 according to the marking information of each first data to be written and at least one of the following parameters: the number of writes requested per cycle, the total number of writes requested per cycle, The average size of cached data, the average cache eviction period, the number of requested reads per cycle, and the total number of requested reads per cycle can be used to train the predictive model.
  • the average total requested writes per cycle can be obtained.
  • a data group with a size of several bytes is maintained, and the total number of requested writes per cycle within a certain period of time is recorded. Further, the average total requested write number per cycle can be obtained by calculating the average value of the data group.
  • the average total number of read requests per cycle can be obtained. Specifically, as mentioned above, a data group of several bytes in size is maintained in S204, and the total number of read requests per cycle within a certain period of time is recorded. Further, the average total number of read requests per cycle can be obtained by calculating the average value of the data group.
  • the average cache data size indicates the average size of the data stored in the cache medium.
  • the specific obtaining method will be described in detail in step S211.
  • the average cache eviction period indicates the average value of the time period from the entry of the cache to the eviction of each data in the cache medium.
  • the specific obtaining method will be described in detail in step S213.
  • the average size of cache data, the average cache elimination cycle, the average number of total requested writes per cycle, the number of requested writes per cycle of each data to be written, the average total number of reads per cycle, and the average number of writes per cycle of each data to be written At least one item of the requested read numbers is used as input, and the label information of each data to be written is used as output, and the prediction model can be trained.
  • the prediction model can be an artificial intelligence model such as a back propagation neural network model or a long short-term memory network. It should be noted that the embodiments of the present application do not limit the method for establishing the prediction model, and since it is the prior art, details are not described again.
  • the training of the prediction model may be started.
  • the sampling threshold can be set as required. For example, it can be set to start a round of training for the prediction model when the number of labeled training data reaches 10,000.
  • the training rounds of the prediction model can be set. Based on the number of epochs that the predictive model has been trained on and the epoch threshold, it can be determined whether further training of the model is required. When the training epoch reaches or exceeds the epoch threshold, the predictive model can no longer be trained.
  • the round threshold is set to 100
  • operations such as sampling and labeling of the data to be written can no longer be performed.
  • the predictive model is no longer trained.
  • the first data to be written stored in the prediction model may be deleted.
  • the output amount that is, the label information of each first data to be written, may be preprocessed. Specifically, the cold/hot data in the marked state can be converted into 0/1 or 1/0. In this class of possible implementations, the output of the predictive model can be controlled between 0 and 1.
  • a trained prediction model After sampling the data to be written and training the prediction model in steps S205 to S207, a trained prediction model will be obtained. For the data that does not satisfy the sampling rule in S205, its writing probability may be determined based on the prediction model.
  • the prediction model may be the model after training in step S207 or the model before training in step S207. Specifically, the model used for prediction needs to go through at least one round of training.
  • the writing judgment section includes steps S208 to S211.
  • the cache management apparatus 104 generates a prediction model and uses it to predict the writing probability of the data to be predicted.
  • a prediction model that has completed at least one round of training can be obtained to predict the writing state of the data to be predicted.
  • the to-be-predicted data indicates the second to-be-written data determined in step S209 that does not satisfy the special rule.
  • a specific method for obtaining the second data to be written that does not meet the special rules will be introduced in step S209.
  • the prediction model used to predict the writing probability of the second data to be written in this step may be different from the prediction model trained in step S207.
  • the cache write prediction model used in step S208 is the cache write prediction model before training in step S207. That is, the cache write prediction model trained by the data corresponding to the previous batch of data write requests.
  • the cache write prediction model trained by the first data to be written in the first batch of data can be used to predict part of the data in the second batch of data corresponding to the second batch of data write requests.
  • the occurrence time of the second batch of data write requests should be later than the occurrence time of the first batch of data write requests.
  • the number of requested writes per cycle of the data to be predicted and the average size of cached data, the average cache elimination cycle, the average total requested writes per cycle, the average total requested reads per cycle, and the second to-be-written data per cycle At least one of the requested read counts is used as input, and the write status of the data to be predicted can be predicted.
  • an output value between 0 and 1 can be obtained. That is, the writing probability of the data to be predicted.
  • the cache management apparatus 104 determines whether the second data to be written that does not satisfy the sampling rule satisfies the special rule.
  • the second data to be written that does not satisfy the sampling rule will be transferred to S209 for processing.
  • S209 it will be further judged whether the data satisfies the special rules.
  • Special rules include the write of partial data and the exclusion of partial data. For example, according to the requirements of the tenant, special types of files are not written, and files of special domain names are not written.
  • step S210 For the second data to be written that does not satisfy the special rule, go to step S210.
  • step S209 is an optional step in the cache writing method 200 .
  • the cache management device 104 determines the write status of the second to-be-written data that does not meet the special rules and the write probability and write threshold.
  • the write state of the data can be determined.
  • the write threshold can be set as required.
  • the writing probability of the second to-be-written data that does not satisfy the sampling rule may be obtained by using the prediction model in S208. That is, the second to-be-written data that does not satisfy the sampling rule is used as the to-be-predicted data in the prediction model. Specifically, the number of requested writes per cycle of the data and the average size of cached data, the average cache elimination cycle, the average total number of requested writes per cycle, the average total number of requested reads per cycle, and the average number of requested reads per cycle of the data At least one of the numbers is used as an input to the prediction model, which can predict the writing state of the data.
  • an output value between 0 and 1 can be obtained after using the prediction model to predict the writing state of the data. That is, the writing probability of the data.
  • the write state of the second data to be written that does not satisfy the sampling rule can be determined.
  • the write probability when the write probability is greater than or equal to the write threshold, the data will be written to the cache. When the write probability is less than the write threshold, the data will not be written to the cache.
  • the predictive model may have write thresholds built into the predictive model. That is, the prediction model can directly output the judgment result of whether to write the second data to be written into the cache.
  • the premise of using the prediction model to predict the writing probability is that at least one round of training has been performed on the prediction model in step S207.
  • the prediction model is not trained until the accumulated number of data to be written in step S206 does not reach the sampling threshold.
  • the writing state of the second to-be-written data that does not satisfy the sampling rule can be determined according to the prior art.
  • the prior art includes writing rules based on specific rules or frequency statistics, etc., which will not be repeated.
  • the cache management device 104 writes the determined to-be-written data into the cache, and counts the size of the written data.
  • step S211 it is determined that the data to be written to be written includes at least the following three types of situations:
  • the data to be written may be the data to be written that satisfies the sampling rule in step S205. That is, the ID of the data takes the remainder of the sample value to be 0 for the first data to be written.
  • the data to be written may also be the second data to be written that satisfies the special rule in step S209.
  • the second data to be written indicates the data to be written in which the remainder of the ID of the data and the sampling value is not 0.
  • the data to be written may also be the second data to be written that does not meet the special rules and whose writing probability is not less than the writing threshold in step S210 .
  • the size of each data to be written needs to be recorded, so as to calculate the average size of the data in the cache medium at the current moment. Further, the average size of the data can be used as an input in step S207 for training the prediction model.
  • the cache data elimination part includes steps S212 to S214.
  • S212 Determine whether to eliminate some data in the cache according to the elimination rule.
  • Common cache data elimination algorithms include least recently used (LRU) and first-in, first-out (FIFO) methods.
  • the cache management device 104 updates the labeling state of the eliminated data, and calculates the average cache elimination period.
  • the data to be written into the cache in step S211 includes at least three cases.
  • the data to be written may be the first data to be written that satisfies the sampling rule in step S205. That is, the first data to be written will simultaneously wait for the mark in step S206.
  • the first data to be written may be marked according to the elimination of the first data to be written in the cache. Specifically, for the eliminated data, if the data belongs to the first data to be written and the marking has not been completed in step S206, the first data to be written is marked as cold data. Further, the first to-be-written data marked in step S206 is transferred to step S207 and used as training data for the prediction model.
  • the average cache elimination cycle can be obtained.
  • the writing time of the data is the requested writing time of the data recorded in step S202.
  • the elimination period of each eliminated data can be obtained by subtracting its write time from the elimination time of each eliminated data.
  • the average cache elimination period can be determined.
  • each item of eliminated data may be all data that has been eliminated in history.
  • the eliminated data may also be eliminated data within a period of time in the past.
  • the average cache elimination period can be used as an input in step S207 for training the prediction model.
  • step S212 The data determined to be eliminated in step S212 are output.
  • steps S213 and S214 have no fixed execution order. That is, step S213 may be performed before or after step S214. Optionally, step S213 and step S214 may also be performed simultaneously.
  • the present application also provides a cache management device 104, as shown in FIG. 3, including:
  • the communication unit 302 is configured to receive a data read request in S201 and a data write request in S203.
  • the communication unit 302 is further configured to receive the set sampling threshold in S207.
  • the communication unit 302 is used to obtain the write threshold.
  • the communication unit 302 is further configured to receive the special rules set by the tenant in S209.
  • the storage unit 304 is configured to store the request information of the data to be read recorded in S202 and the request information of the data to be written recorded in S204.
  • the storage unit 304 is configured to store the relevant information of the first data to be written determined in S205.
  • the storage unit 304 is further configured to store the parameters in the prediction model trained in S207.
  • the sampling threshold received in S207 and the write threshold received in S210 will also be stored in the storage unit 304 .
  • the storage unit 304 is also used to store the special rules set by the tenant in S209.
  • the cache unit 306, in the cache management method 200 is configured to cache the first data to be written determined in S205.
  • the second to-be-written data determined to be written to the cache and the second to-be-written data whose write probability is greater than the write threshold in S210 will both be cached in the cache unit 306 .
  • the processing unit 308 is configured to perform the recording operations in S202 and S204, and store the request information of the data to be read and the data to be written into the storage unit 304.
  • the processing unit 308 is further configured to judge the current data to be written in S205, and determine the first data to be written and the second data to be written.
  • the processing unit 308 is configured to mark the first data to be written. Further, the operation of training the prediction model according to the recorded request information and annotation information in S207 is also performed by the processing unit 308 .
  • the processing unit 308 is configured to perform an operation of predicting the writing probability of the data to be predicted.
  • the processing unit 308 is further configured to determine in S209 whether the second data to be written satisfies the special rule.
  • the operation of determining whether to write the second data to be written into the cache according to the write probability and the write threshold obtained in S208 is also performed by the processing unit 308.
  • the operation of determining the to-be-written data written into the cache into the cache, and calculating the size of the data in the cache is also performed by the processing unit 308 .
  • the processing unit 308 is further configured to output the partial data in the cache according to the elimination rule in S212.
  • the labeling state of the eliminated data is updated according to the elimination situation of the data, and the operation of calculating the average elimination period is performed by the processing unit 308.
  • the processing unit 308 may include a recording unit 310 , a training unit 312 , a decision unit 314 and an elimination unit 316 .
  • the recording unit 310 is configured to perform the recording operations in S202 and S204 , and store the data to be read and the request information of the data to be written into the storage unit 304 .
  • the decision unit 314 is configured to judge the current data to be written in S205, and determine the first data to be written and the second data to be written.
  • the training unit 312 is configured to mark the first data to be written. Further, the operation of training the prediction model according to the recorded request information and annotation information in S207 is also performed by the training unit 312 .
  • the decision unit 314 is configured to perform an operation of predicting the writing probability of the data to be predicted.
  • the decision unit 314 is further configured to determine in S209 whether the second data to be written satisfies the special rule.
  • the operation of determining whether to write the second data to be written into the cache according to the write probability and the write threshold obtained in S208 is also performed by the decision unit 314 .
  • the operation of determining the to-be-written data to be written into the cache and writing the data into the cache and counting the size of the data in the cache is also performed by the decision unit 314 .
  • the elimination unit 316 is configured to output the partial data in the cache according to the elimination rule in S212.
  • the labeling state of the eliminated data is updated according to the elimination situation of the data, and the operation of calculating the average elimination period is performed by the elimination unit 316.
  • the present application also provides a computing device 400 .
  • the computing device includes a bus 402 , a processor 404 , a memory 406 and a communication interface 408 . Communication between processor 404 , memory 406 and communication interface 408 is via bus 402 .
  • Computing device 400 may be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 400 .
  • the bus 402 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus or the like.
  • PCI peripheral component interconnect
  • EISA extended industry standard architecture
  • the bus can be divided into address bus, data bus, control bus and so on. For ease of presentation, only one line is shown in FIG. 4, but it does not mean that there is only one bus or one type of bus.
  • Bus 404 may include pathways for communicating information between various components of computing device 400 (eg, memory 406, processor 404, communication interface 408).
  • the processor 404 may include processing such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP). any one or more of the devices.
  • CPU central processing unit
  • GPU graphics processing unit
  • MP microprocessor
  • DSP digital signal processor
  • Memory 406 may include volatile memory, such as random access memory (RAM).
  • the processor 404 may also include non-volatile memory (non-volatile memory), such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state hard disk (solid state) drive, SSD).
  • ROM read-only memory
  • HDD hard disk drive
  • SSD solid state hard disk
  • the memory 406 stores executable program codes, and the processor 404 executes the executable program codes to implement the aforementioned cache management method 200 .
  • the memory 406 stores instructions for the cache management apparatus 104 to execute the cache management method 200 .
  • the communication interface 403 uses a transceiver module such as, but not limited to, a network interface card, a transceiver, etc., to implement communication between the computing device 400 and other devices or a communication network.
  • a transceiver module such as, but not limited to, a network interface card, a transceiver, etc.
  • Embodiments of the present application further provide a computing device cluster.
  • the computing device cluster includes at least one computing device 400 .
  • the computing device clusters included in the computing device cluster may all be terminal devices, may all be cloud servers, or may be partly cloud servers and partly terminal devices.
  • the memory 406 in one or more computing devices 400 in the computing device cluster may store the same cache management apparatus 104 for executing the instructions of the cache management method 200 .
  • one or more computing devices 400 in the computing device cluster may also be used to execute part of the instructions of the cache management apparatus 104 for executing the cache management method 200 .
  • a combination of one or more computing devices 400 may collectively execute the instructions of the cache management apparatus 104 for executing the cache management method 200 .
  • the memories 406 in different computing devices 400 in the computing device cluster may store different instructions for executing some functions of the cache management apparatus 104 .
  • Figure 6 shows one possible implementation.
  • two computing devices 400A and 400B are connected through a communication interface 408 .
  • Instructions for performing the functions of the communication unit 302 , the storage unit 304 , the recording unit 308 , the training unit 310 , the decision unit 312 , and the elimination unit 314 are stored on memory in the computing device 400A.
  • Instructions for performing the functions of cache unit 306 are stored on memory in computing device 400B.
  • the memories 406 of the computing devices 400A and 400B collectively store the instructions for the cache management apparatus 104 to execute the cache management method 200 .
  • connection mode between the computing device clusters shown in FIG. 6 may take into account that the cache management method 200 provided by the present application needs to perform high-speed writing or reading operations on the data in the cache unit 306 . Therefore, consider offloading the caching function to computing device 400B.
  • computing device 400A shown in FIG. 6 may also be performed by multiple computing devices 400 .
  • the functions of computing device 400B may also be performed by multiple computing devices 400 .
  • one or more computing devices in a cluster of computing devices may be connected by a network.
  • the network may be a wide area network or a local area network, or the like.
  • Figure 7 shows one possible implementation. As shown in FIG. 7 , two computing devices 400C and 400D are connected through a network. Specifically, the network is connected through a communication interface in each computing device.
  • the memory 406 in the computing device 400C stores instructions for executing the communication unit 302 , the storage unit 304 , the recording unit 308 , the decision unit 312 and the elimination unit 314 . Meanwhile, the memory 406 in the computing device 400D stores instructions for executing the cache unit 306 and the training unit 310 .
  • connection mode between the computing device clusters shown in FIG. 7 may take into account that the cache management method 200 provided by the present application needs to perform high-speed write or read operations on the data in the cache unit 306, and perform a large number of calculations to To train the prediction model, it is therefore considered that the functions implemented by the caching unit 306 and the training unit 310 are performed by the computing device 400D.
  • computing device 400C shown in FIG. 7 may also be performed by multiple computing devices 400 .
  • the functions of computing device 400D may also be performed by multiple computing devices 400 .
  • Embodiments of the present application also provide a computer-readable storage medium.
  • the computer-readable storage medium may be any available medium that a computing device can store, or a data storage device such as a data center that contains one or more available media.
  • the usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVDs), or semiconductor media (eg, solid state drives), and the like.
  • the computer-readable storage medium includes instructions, the instructions instruct the computing device to execute the above-mentioned application to the cache management apparatus 104 for executing the cache management method 200 .
  • Embodiments of the present application also provide a computer program product including instructions.
  • the computer program product may be a software or program product containing instructions, capable of being executed on a computing device or stored in any available medium.
  • the computer program product runs on at least one computer device, the at least one computer device is caused to execute the above-mentioned cache management method 200 .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

A cache management method, the method being used in a cache management apparatus, and the cache management method comprising: after receiving a first data write request, training a cache write prediction model on the basis of relevant parameters of first data, and writing the first data to the cache; and then receiving a second data write request and, on the basis of the cache write prediction model, determining whether to write the second data to the cache. The present cache management method uses a data-driven algorithm for online training of the cache write protection model, effectively increasing the cache hit rate.

Description

一种缓存管理方法、装置及设备A cache management method, device and device 技术领域technical field
本申请涉及缓存领域,特别涉及一种缓存管理方法、装置及设备。The present application relates to the field of cache, and in particular, to a cache management method, apparatus and device.
背景技术Background technique
应用级缓存是数据库、内容分发网络、数据存储等系统中,用于加速数据访问的常用存储组件。缓存的主要功能是临时保存近期会被系统重复访问的数据,从而减少数据访问的平均时延。缓存介质访问(读写)速度快但存储容量小。缓存的核心竞争力是高命中率。其中,命中率指示的是数据访问缓存并获得返回数据的比例。Application-level caching is a common storage component used to accelerate data access in systems such as databases, content distribution networks, and data storage. The main function of the cache is to temporarily save data that will be repeatedly accessed by the system in the near future, thereby reducing the average latency of data access. Cache media has fast access (read and write) speed but small storage capacity. The core competitiveness of cache is high hit rate. Among them, the hit rate indicates the proportion of data accessing the cache and getting the returned data.
因此,如何提升缓存的命中率成为了业界最为关注的问题。Therefore, how to improve the cache hit rate has become the most concerned issue in the industry.
发明内容SUMMARY OF THE INVENTION
本申请提供了一种缓存管理方法,该方法可以提升缓存命中率。The present application provides a cache management method, which can improve the cache hit rate.
本申请的第一方面提供了一种缓存管理方法,该缓存管理方法用于缓存管理装置,该方法包括:接收第一数据写入请求,该第一数据写入请求用于请求将硬盘中的第一数据写入缓存;根据该第一数据的相关参数,训练缓存写入预测模型;将该第一数据写入该缓存;接收第二数据写入请求,该第二数据写入请求用于请求将该硬盘中的第二数据写入该缓存;根据该缓存写入预测模型,确定是否将该第二数据的写入该缓存。A first aspect of the present application provides a cache management method. The cache management method is used in a cache management device, and the method includes: receiving a first data write request, where the first data write request is used to request to write data stored in a hard disk. Write the first data into the cache; train the cache to write the prediction model according to the relevant parameters of the first data; write the first data into the cache; receive a second data write request, the second data write request is used for Request to write the second data in the hard disk into the cache; according to the cache write prediction model, determine whether to write the second data into the cache.
该缓存管理方法通过在线训练缓存写入预测模型,提升了对待写入数据的写入概率预测精度,提高了缓存的命中率。The cache management method improves the write probability prediction accuracy of the data to be written and improves the cache hit rate by training the cache write prediction model online.
在一些可能的设计中,该方法还包括:接收该第一批数据写入请求;根据采样规则,从该第一批数据写入请求中确定该第一数据写入请求和该第二数据写入请求。In some possible designs, the method further includes: receiving the first batch of data write requests; and determining the first data write request and the second data write request from the first batch of data write requests according to a sampling rule input request.
在一些可能的设计中,该方法还包括:获取该第一批数据写入请求中各数据写入请求携带的待写入数据的标识;确定该第一批数据写入请求中各数据写入请求携带的待写入数据的标识的哈希值可以被采样值整除的为该第一数据写入请求;确定该第一批数据写入请求中各数据写入请求携带的待写入数据的标识的哈希值不可以被采样值整除的为该第二数据写入请求。In some possible designs, the method further includes: obtaining an identifier of the data to be written carried by each data write request in the first batch of data write requests; determining each data write in the first batch of data write requests If the hash value of the identifier of the data to be written carried by the request can be divisible by the sampling value, it is the first data write request; determine the value of the data to be written carried by each data write request in the first batch of data write requests. It is the second data write request that the identified hash value is not divisible by the sample value.
在一些可能的设计中,该方法还包括:接收第二批数据写入请求;根据该训练后的缓存写入预测模型,确定是否将该第二批数据写入请求对应的待写入数据中至少一个数据写入该缓存。In some possible designs, the method further includes: receiving a second batch of data write requests; and determining, according to the trained cache write prediction model, whether to write the second batch of data into the to-be-written data corresponding to the second batch of data write requests At least one data is written to this cache.
在一些可能的设计中,该方法还包括:将该缓存中数据平均大小、历史每周期总写入请求数、历史每周期总读取请求数、该缓存中数据平均淘汰周期中至少一个,和该第一数据的相关参数作为该缓存写入预测模型的训练输入量;根据该第一数据请求发生后一个该平均淘汰周期内该第一数据的请求情况和淘汰情况,确定该第一数据的写入概率作为该缓存写入预测模型的训练输出量:根据该训练输入量和该训练输出量,训练缓存写入预测模型。In some possible designs, the method further includes: at least one of an average size of data in the cache, a historical total number of write requests per cycle, a historical total number of read requests per cycle, and an average elimination cycle of data in the cache, and The relevant parameters of the first data are used as the training input of the cache write prediction model; according to the request situation and the elimination situation of the first data in the average elimination period after the first data request occurs, determine the first data The write probability is used as the training output of the cache to write the prediction model: according to the training input and the training output, the training cache writes the prediction model.
在一些可能的设计中,该第一数据的相关参数包括下列至少一个:该第一数据的历史被请求写入数、该第一数据的历史被请求读取数。In some possible designs, the relevant parameters of the first data include at least one of the following: the number of historically requested writes of the first data, and the number of historically requested reads of the first data.
在一些可能的设计中,该方法还包括:获取写入阈值;根据该缓存写入预测模型,获得该第二数据的写入概率;根据该写入阈值和该第二数据的写入概率,确定是否将该第二数据的写入该缓存。In some possible designs, the method further includes: obtaining a write threshold; obtaining a write probability of the second data according to the cache write prediction model; according to the write threshold and the write probability of the second data, Determine whether to write the second data to the cache.
在一些可能的设计中,该方法还包括:将该缓存中数据平均大小、该缓存中数据平均淘汰周期、历史每周期总写入请求数、历史每周期总读取请求数中的至少一个,和该第二数据相关参数作为该缓存写入预测模型的预测输入量;将该预测输入量作为该训练后的缓存写入预测模型的输入,获得该第二数据的写入概率。In some possible designs, the method further includes: at least one of the average size of the data in the cache, the average elimination period of the data in the cache, the historical total number of write requests per cycle, and the historical total number of read requests per cycle, The parameter related to the second data is used as the prediction input of the cache write prediction model; the prediction input is used as the input of the trained cache write prediction model to obtain the write probability of the second data.
本申请的第二方面提供了一种缓存管理装置,该装置包括通信单元和处理单元:该通信单元,用于接收第一数据写入请求,该第一数据写入请求用于请求将硬盘中的第一数据写入缓存;该处理单元,用于根据该第一数据的相关参数,训练缓存写入预测模型;将该第一数据写入该缓存;该通信单元,还用于接收第二数据写入请求,该第二数据写入请求用于请求将该硬盘中的第二数据写入该缓存;该处理单元,还用于根据该缓存写入预测模型,确定是否将该第二数据的写入该缓存。A second aspect of the present application provides a cache management device, the device includes a communication unit and a processing unit: the communication unit is configured to receive a first data write request, and the first data write request is used to request that a hard disk be stored in a The first data is written into the cache; the processing unit is used for training the cache to write the prediction model according to the relevant parameters of the first data; the first data is written into the cache; the communication unit is also used for receiving the second a data write request, the second data write request is used to request to write the second data in the hard disk into the cache; the processing unit is also used to determine whether to write the second data according to the cache write prediction model write to the cache.
在一些可能的设计中,该通信单元,用于接收第一批数据写入请求;该处理单元,用于根据划分规则,从该第一批数据写入请求中确定该第一数据写入请求和该第二数据写入请求。In some possible designs, the communication unit is configured to receive the first batch of data write requests; the processing unit is configured to determine the first data write request from the first batch of data write requests according to a division rule and the second data write request.
在一些可能的设计中,该处理单元,用于获取该第一批数据写入请求中各数据写入请求携带的待写入数据的标识;确定该第一批数据写入请求中各数据写入请求携带的待写入数据的标识的哈希值可以被采样值整除的为该第一数据写入请求;确定该第一批数据写入请求中各数据写入请求携带的待写入数据的标识的哈希值不可以被采样值整除的为该第二数据写入请求。In some possible designs, the processing unit is configured to obtain the identifier of the data to be written carried by each data write request in the first batch of data write requests; determine each data write request in the first batch of data write requests The hash value of the identifier of the data to be written carried by the incoming request can be divisible by the sampling value is the first data write request; determine the data to be written carried by each data write request in the first batch of data write requests The hash value of the identifier that is not divisible by the sample value is the second data write request.
在一些可能的设计中,该通信单元,用于接收第二批数据写入请求;该处理单元,用于根据该训练后的缓存写入预测模型,确定是否将该第二批数据写入请求对应的待写入数据中至少一个数据写入该缓存。In some possible designs, the communication unit is configured to receive the second batch of data write requests; the processing unit is configured to determine whether to write the second batch of data to the request according to the trained cache write prediction model At least one piece of the corresponding data to be written is written into the cache.
在一些可能的设计中,该处理单元,用于将该缓存中数据平均大小、历史每周期总写入请求数、历史每周期总读取请求数、该缓存中数据平均淘汰周期中至少一个,和该第一数据的相关参数作为该缓存写入预测模型的训练输入量;根据该第一数据请求发生后一个该平均淘汰周期内该第一数据的请求情况和淘汰情况,确定该第一数据的写入概率作为该缓存写入预测模型的训练输出量:根据该训练输入量和该训练输出量,训练缓存写入预测模型。In some possible designs, the processing unit is used for at least one of the average size of data in the cache, the historical total number of write requests per cycle, the historical total number of read requests per cycle, and the average elimination cycle of data in the cache, and the relevant parameters of the first data as the training input of the cache write prediction model; according to the request situation and the elimination situation of the first data in the average elimination period after the first data request occurs, determine the first data The write probability of is used as the training output of the cache to write the prediction model: according to the training input and the training output, the training cache writes the prediction model.
在一些可能的设计中,该第一数据的相关参数包括下列至少一个:该第一数据的历史被请求写入数、该第一数据的历史被请求读取数。In some possible designs, the relevant parameters of the first data include at least one of the following: the number of historically requested writes of the first data, and the number of historically requested reads of the first data.
在一些可能的设计中,该通信单元,用于获取写入阈值;该处理单元,用于根据该缓存写入预测模型,获得该第二数据的写入概率;根据该写入阈值和该第二数据的写入概率,确定是否将该第二数据的写入该缓存。In some possible designs, the communication unit is configured to obtain a write threshold; the processing unit is configured to obtain a write probability of the second data according to the cache write prediction model; according to the write threshold and the first The writing probability of the second data determines whether to write the second data into the cache.
在一些可能的设计中,该处理单元,用于将该缓存中数据平均大小、该缓存中数据平均淘汰周期、历史每周期总写入请求数、历史每周期总读取请求数中的至少一个, 和该第二数据相关参数作为该缓存写入预测模型的预测输入量;将该预测输入量作为该训练后的缓存写入预测模型的输入,获得该第二数据的写入概率。In some possible designs, the processing unit is configured to at least one of the average size of data in the cache, the average elimination cycle of data in the cache, the historical total number of write requests per cycle, and the historical total number of read requests per cycle , and parameters related to the second data are used as the prediction input of the cache write prediction model; the prediction input is used as the input of the trained cache write prediction model to obtain the write probability of the second data.
本申请的第三方面提供了一种计算设备集群,包括至少一个计算设备,每个计算设备包括处理器和存储器;至少一个计算设备的处理器用于执行至少一个计算设备的存储器中存储的指令,以使得该计算设备执行如第一方面或第一方面的任意可能的设计提供的方法。A third aspect of the present application provides a computing device cluster, including at least one computing device, each computing device including a processor and a memory; the processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device, to cause the computing device to perform the method as provided by the first aspect or any possible design of the first aspect.
本申请的第四方面提供了一种包含指令的计算机程序产品,当该指令被计算机设备集群运行时,使得该计算机设备集群执行如第一方面或第一方面的任意可能的设计提供的方法。A fourth aspect of the present application provides a computer program product comprising instructions which, when executed by a cluster of computer devices, cause the cluster of computer devices to perform a method as provided by the first aspect or any possible design of the first aspect.
本申请的第五方面提供了一种计算机可读存储介质,包括计算机程序指令,当该计算机程序指令由计算设备集群执行时,该计算设备集群执行如第一方面或第一方面的任意可能的设计提供的方法。A fifth aspect of the present application provides a computer-readable storage medium comprising computer program instructions, when the computer program instructions are executed by a cluster of computing devices, the cluster of computing devices executes the first aspect or any possible implementation of the first aspect Design provides methods.
附图说明Description of drawings
为了更清楚地说明本申请实施例的技术方法,下面将对实施例中所需使用的附图作以简单地介绍。In order to illustrate the technical methods of the embodiments of the present application more clearly, the following briefly introduces the accompanying drawings used in the embodiments.
图1是适用于本申请实施例的一种可能的应用场景示意图。FIG. 1 is a schematic diagram of a possible application scenario applicable to the embodiment of the present application.
图2是适用于本申请实施例的一种可能的缓存管理方法流程图。FIG. 2 is a flowchart of a possible cache management method applicable to the embodiment of the present application.
图3是适用于本申请实施例的一种可能的缓存管理装置结构示意图。FIG. 3 is a schematic structural diagram of a possible cache management apparatus applicable to the embodiment of the present application.
图4是适用于本申请实施例的一种可能的计算设备结构示意图。FIG. 4 is a schematic structural diagram of a possible computing device suitable for an embodiment of the present application.
图5是适用于本申请实施例的一种可能的计算设备集群结构示意图。FIG. 5 is a schematic structural diagram of a possible computing device cluster applicable to the embodiment of the present application.
图6是适用于本申请实施例的一种可能的计算设备集群结构示意图。FIG. 6 is a schematic structural diagram of a possible computing device cluster applicable to the embodiment of the present application.
图7是适用于本申请实施例的一种可能的计算设备集群结构示意图。FIG. 7 is a schematic structural diagram of a possible computing device cluster applicable to the embodiment of the present application.
具体实施方式Detailed ways
本申请实施例中的术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。The terms "first" and "second" in the embodiments of the present application are only used for the purpose of description, and cannot be understood as indicating or implying relative importance or implying the number of indicated technical features. Thus, a feature defined as "first" or "second" may expressly or implicitly include one or more of that feature.
首先对本申请实施例中所涉及到的一些技术术语进行介绍。First, some technical terms involved in the embodiments of this application are introduced.
缓存:在快速的存储介质和服务系统之间的中间层,用于暂时存储近期被访问的数据,降低数据访问时延的组件。Cache: The middle layer between the fast storage medium and the service system, used to temporarily store recently accessed data and reduce data access latency.
缓存写入:在数据写入的请求到达缓存系统时,决策是否将数据写入缓存的过程。Cache write: The process of deciding whether to write data to the cache when a data write request arrives at the cache system.
缓存命中率:始端用户访问加速节点时,如果该节点缓存了要被访问的数据时就叫做命中。如果没有的话需要回原服务器取,就是没有命中。取数据的过程与用户访问是同步进行的,所以即使是重新取的新数据,用户也不会感觉到有延时。命中率等于命中数比上命中数和没有命中数的总和。缓存命中率是判断加速效果好坏的重要因素之一。Cache hit rate: When the initial user accesses the acceleration node, if the node caches the data to be accessed, it is called a hit. If not, you need to go back to the original server to fetch, that is, there is no hit. The process of fetching data is synchronized with user access, so even if new data is fetched again, users will not feel any delay. The hit rate is equal to the sum of hits over hits and no hits. The cache hit rate is one of the important factors for judging the acceleration effect.
缓存介质的访问速度通常比系统主存储器的访问速度快,在典型的场景中访问速度相差若干量级,应用系统中通常用内存作为硬盘和远程网络的缓存介质。相对应用 系统的数据规模,缓存介质可用的存储容量极小。例如,在典型的互联网服务数据库中,数据库通常存储拍字节(petabytes,PB)级的数据,但缓存容量只有若干吉字节(gigabyte,GB),甚至小于1GB。The access speed of the cache medium is usually faster than the access speed of the system main memory. In a typical scenario, the access speed differs by several orders of magnitude. In the application system, the memory is usually used as the cache medium of the hard disk and the remote network. Relative to the data scale of the application system, the available storage capacity of the cache medium is extremely small. For example, in a typical Internet service database, the database usually stores petabytes (petabytes, PB) of data, but the cache capacity is only several gigabytes (gigabyte, GB), or even less than 1GB.
由于缓存介质访问速度快,所以系统访问的数据在缓存中命中的比例越高,系统的性能通常越好。但是,由于缓存介质的数据储存量有限,缓存也需要不断淘汰数据,腾出存储空间缓存新写入的数据。常见的缓存数据淘汰算法包括最近最少使用(least recently used,LRU)和先进先出(first-in,first-out,FIFO)等方法。这些方法均倾向于保留新数据,淘汰旧数据。Due to the fast access speed of the cache medium, the higher the proportion of data accessed by the system hits in the cache, the better the performance of the system is generally. However, due to the limited data storage capacity of the cache medium, the cache also needs to continuously eliminate data to free up storage space to cache newly written data. Common cache data elimination algorithms include least recently used (LRU) and first-in, first-out (FIFO) methods. These methods tend to retain new data and obsolete old data.
在当前主流的云服务、互联网服务中,数据被请求的频次通常服从长尾分布,绝大部分的访问请求都集中在小部分数据上,绝大部分数据都只有一次访问。在这种数据分布下,大量新的被请求的数据不断写入内存,旧数据被不断淘汰,但新写入数据不会再有第二次访问,所以往往导致缓存命中率低下。另一方面,在互联网服务中,线性遍历数据也是常见的业务,数据被线性逐个扫描,扫描期间不会有第二次访问。此外,各种网络攻击通常会试图扫描系统全集数据。在长尾分布和线性扫描等场景下,大量数据短期内只被访问一次,采用主流缓存淘汰算法会导致缓存介质急速冲刷(也称颠簸)问题,即数据不断写入缓存,而命中率极低。In the current mainstream cloud services and Internet services, the frequency of data requests usually obeys the long-tail distribution, most of the access requests are concentrated on a small part of the data, and most of the data is accessed only once. Under this kind of data distribution, a large amount of new requested data is continuously written into the memory, and the old data is continuously eliminated, but the newly written data will not have a second access, so the cache hit rate is often low. On the other hand, in Internet services, linear traversal of data is also a common business. Data is scanned linearly one by one, and there will be no second access during the scan. In addition, various cyberattacks often attempt to scan the system's full set of data. In scenarios such as long-tail distribution and linear scan, a large amount of data is accessed only once in a short period of time. The mainstream cache elimination algorithm will lead to the problem of rapid flushing (also known as thrashing) of the cache medium, that is, the data is continuously written to the cache, and the hit rate is extremely low .
在这种情况下,引入缓存写入功能通常能降低缓存冲刷速度,提升命中率。缓存写入是指在数据进入缓存介质之前,判断数据是否有进入缓存系统的价值,如果无价值,则不将数据放入缓存介质。In this case, the introduction of the cache write function can usually reduce the cache flushing speed and improve the hit rate. Cache write refers to judging whether the data has the value of entering the cache system before the data enters the cache medium, and if it has no value, the data will not be put into the cache medium.
目前,已经有相关的用于管理缓存写入的方法。Currently, there are related methods for managing cache writes.
例如,为了应对线性扫描,部分系统不允许近期第一次被访问的数据进入缓存,而被第二次以上访问的数据才写入缓存。此外,还有一些系统,基于统计信息,如统计每条数据的近期访问次数,再设定一个阈值,访问此处超过阈值则写入缓存,否则阻挡。还有一些基于规则或者基于频次统计的写入技术。For example, in order to cope with linear scans, some systems do not allow data accessed for the first time recently to enter the cache, and data accessed more than the second time are written to the cache. In addition, there are some systems that, based on statistical information, such as counting the number of recent accesses to each piece of data, set a threshold. If the access exceeds the threshold, it will be written to the cache, otherwise it will be blocked. There are also rules-based or frequency-based writing techniques.
通常这些方法的业务适应性较差,在系统上线之前,对实际将进入系统的数据往往所知甚少。在这种情况下,提前制定规则,或者决策统计指标和阈值,产生的结果难以预估。Often these methods have poor business adaptability, and often little is known about the data that will actually enter the system until the system goes live. In this case, formulating rules in advance, or deciding on statistical indicators and thresholds, produces results that are difficult to predict.
此外,常见的应用系统中,根据业务的需求和场景变化,数据的分布会发生变化。此时,写入方案如果不能跟随数据的变化而调整,则容易出现缓存命中率下降。In addition, in common application systems, the distribution of data will change according to business needs and changes in scenarios. At this time, if the writing scheme cannot be adjusted following the change of data, the cache hit rate is likely to decrease.
有鉴于此,本申请实施例提供了一种能够自适应地调整写入策略的技术方案,即基于在线自适应的缓存写入方法。由数据驱动算法,在系统运行时自动预测数据未来的命中概率,在线学习写入模型从而快速适应业务数据变化,实现准确高效的写入结果。In view of this, the embodiments of the present application provide a technical solution capable of adaptively adjusting a write strategy, that is, an online self-adaptive-based cache write method. The data-driven algorithm automatically predicts the future hit probability of data when the system is running, and learns the writing model online to quickly adapt to changes in business data and achieve accurate and efficient writing results.
为了使得本申请的技术方案更加清楚、易于理解,下面结合图1对缓存写入方法200的的场景进行介绍。In order to make the technical solution of the present application clearer and easier to understand, the scenario of the cache writing method 200 is introduced below with reference to FIG. 1 .
在一种可能的实现方式中,在用户101点击应用102后,将触发应用102向缓存103发起数据读取请求。其中,应用102可以是网页应用,也可以是智能终端上的第三方应用软件等。In a possible implementation manner, after the user 101 clicks on the application 102 , the application 102 will be triggered to initiate a data read request to the cache 103 . Wherein, the application 102 may be a web application, or a third-party application software on a smart terminal or the like.
需要说明的是,应用102向缓存103发起的数据读取请求将被缓存管理装置104记录。具体地,将记录该数据读取请求的被请求数据的标识信息和请求时间等信息。同时,还可以对该数据的历史被请求次数进行更新。It should be noted that the data read request initiated by the application 102 to the cache 103 will be recorded by the cache management apparatus 104 . Specifically, information such as identification information and request time of the requested data of the data read request will be recorded. At the same time, the historical requested times of the data can also be updated.
当缓存103中存在该数据时,缓存103将向应用102返回该数据。同时,缓存管理装置104将记录该数据请求结果。也即,该数据读取请求得到了响应。When the data exists in the cache 103 , the cache 103 will return the data to the application 102 . At the same time, the cache management device 104 will record the data request result. That is, the data read request is responded to.
当缓存103中不存在该数据时,应用102将向硬盘105发起数据读取请求。同时,缓存管理装置104将记录该数据请求结果。也即,该数据读取请求未得到响应。其中,硬盘105可以包括固态硬盘、传统硬盘和混合硬盘。When the data does not exist in the cache 103 , the application 102 will initiate a data read request to the hard disk 105 . At the same time, the cache management device 104 will record the data request result. That is, the data read request is not responded to. Wherein, the hard disk 105 may include a solid-state hard disk, a conventional hard disk, and a hybrid hard disk.
当硬盘105中存在该数据时,硬盘105将向应用102返回该数据。同时,缓存管理装置104将决定是否将该数据写入缓存103。When the data exists in the hard disk 105 , the hard disk 105 will return the data to the application 102 . At the same time, the cache management device 104 will decide whether to write the data into the cache 103 or not.
在这一类可能的实现方式中,数据写入缓存103的请求是由用户101点击应用102所触发的。In this type of possible implementations, the request for writing data into the cache 103 is triggered by the user 101 clicking on the application 102 .
当硬盘105中不存在该数据时,系统将向应用102返回找不到该数据的信息。When the data does not exist in the hard disk 105, the system will return the information that the data cannot be found to the application 102.
在一种可能的实现方式中,数据写入缓存103的请求可以是由应用102所触发的。例如,可以是由内容分发网络(content delivery network,CDN)的刷新与预热触发。In a possible implementation manner, the request for writing data into the cache 103 may be triggered by the application 102 . For example, it can be triggered by the refresh and warm-up of the content delivery network (CDN).
具体地,对于应用102中租户指定需要刷新或预热的统一资源定位符(uniform resource locator,URL),应用102会主动从源站获取更新的数据。从而让用户101访问该CDN时不用回到租户的源站去获取数据。因此,当刷新或预热的动作触发以后,缓存管理装置104将判断是否将这部分数据写入缓存103。Specifically, for a uniform resource locator (URL) specified by the tenant to be refreshed or warmed up in the application 102, the application 102 will actively obtain updated data from the origin site. Therefore, when the user 101 accesses the CDN, there is no need to go back to the origin site of the tenant to obtain data. Therefore, when the refresh or warm-up action is triggered, the cache management device 104 will determine whether to write this part of the data into the cache 103 .
下面对本申请提供的一种缓存写入方法200进行介绍。该缓存写入方法可以运行在缓存管理装置104上。The following describes a cache writing method 200 provided by the present application. The cache writing method may run on the cache management device 104 .
缓存写入方法200的流程图如图2所示。该缓存写入方法包括请求信息记录,预测模型训练,写入判断和缓存数据淘汰四个部分。The flowchart of the cache writing method 200 is shown in FIG. 2 . The cache writing method includes four parts: request information record, prediction model training, write judgment and cache data elimination.
首先,缓存管理装置104可能接收到的请求信息包括数据写入请求和数据读取请求。通过记录请求信息的请求时间和请求次数等参数,可以为预测模型训练提供数据。具体地,请求信息记录部分包括步骤S201至步骤S204。First, the request information that the cache management device 104 may receive includes a data write request and a data read request. By recording parameters such as the request time and the number of requests for request information, data can be provided for the training of the predictive model. Specifically, the request information recording part includes steps S201 to S204.
S201:缓存管理装置104接收数据读取请求。S201: The cache management apparatus 104 receives a data read request.
如前所述,在用户101点击应用102后,应用102将向缓存管理装置104发起数据读取请求。换言之,当数据读取请求来临时,由缓存管理装置104接收该数据读取请求。其中,数据读取请求指示的是将缓存103中的数据返回应用102。As mentioned above, after the user 101 clicks on the application 102, the application 102 will initiate a data read request to the cache management apparatus 104. In other words, when a data read request comes, the cache management device 104 receives the data read request. The data read request indicates that the data in the cache 103 is returned to the application 102 .
S202:缓存管理装置104记录待读取数据的请求信息。S202: The cache management apparatus 104 records the request information of the data to be read.
当数据读取请求来临时,缓存管理装置104将记录待读取数据的信息和请求时间。其中,数据的信息可以是标识(identifier,ID)。可选的,还可以是该数据的通用唯一识别码(universally unique identifier,UUID)等信息。下文将以ID为例进行介绍。When a data read request comes, the cache management device 104 will record the information of the data to be read and the request time. The information of the data may be an identifier (ID). Optionally, it may also be information such as a universally unique identifier (universally unique identifier, UUID) of the data. The following will take ID as an example to introduce.
根据记录的各数据读取请求的时间,可以计算下述参数中的至少一项:各数据的每周期请求读取数和历史每周期平均请求读取数。其中,周期的长度可以根据需要进行设置。例如,如果周期为1秒,则数据的每周期请求读取数指示的是该数据在1秒内被请求读取的次数,而该数据的历史每周期平均请求读取数指示的是该数据在历史 计数周期内每周期请求读取数的平均值。其中,历史计数周期可以根据需要进行设置。According to the recorded time of each data read request, at least one of the following parameters can be calculated: the number of requested reads per cycle of each data and the historical average number of requested reads per cycle. The length of the period can be set as required. For example, if the period is 1 second, the requested reads per cycle for the data indicates the number of times that data was requested to be read in 1 second, and the historical average request reads per cycle for the data indicates the data The average number of requested reads per cycle over the historical count period. Among them, the historical count period can be set as required.
可选的,为了对各数据在一定时间内的每周期请求读取数进行记录,可以对各数据维护一个8字节大小的数据组。进一步地,将8个字节平均分割为32个单元。其中,每个单元为2位(bits),各单元编号为1、2、〃〃〃、32。其中每一个单元可以表示该数据每周期请求读取数的四种状态(00、01、10、11),分别对应无读取请求、有一次、二次、三次及以上读取请求。换言之,可以通过对各数据维护一个8字节大小的数据组,以记录该数据在过去的32个周期中的每周期请求读取数。按照上述的存储方法,可以实现以较小的存储空间存储较多的每周期请求读取数。Optionally, in order to record the number of read requests per cycle of each data within a certain period of time, an 8-byte data group may be maintained for each data. Further, the 8 bytes are equally divided into 32 units. Among them, each unit is 2 bits (bits), and each unit number is 1, 2, "〃", 32. Each unit can represent four states (00, 01, 10, 11) of the number of read requests per cycle of the data, corresponding to no read request, one, two, three and more read requests respectively. In other words, by maintaining an 8-byte data group for each data, the number of read requests per cycle of the data in the past 32 cycles can be recorded. According to the above storage method, it is possible to store a larger number of requested reads per cycle in a smaller storage space.
可选的,根据记录的各数据读取请求的请求时间,还可以获得在各周期内的总请求读取数。也即,每周期总请求读取数。同样的,在对各每周期内的总请求读取数进行记录后,可以选择保留一定历史时间内的每周期总请求读取数。其中,历史时间的长度可以根据需要进行设置。进一步的,也可以通过维护一个若干字节大小的数据组,记录一定时间内的每周期总请求读取数。具体的方法,可以参考上述维护每周期请求读取数对应数据组的方法。Optionally, according to the recorded request time of each data read request, the total number of read requests in each cycle can also be obtained. That is, the total number of requested reads per cycle. Similarly, after recording the total number of requested readings in each cycle, you can choose to keep the total number of requested readings per cycle within a certain historical period. The length of the historical time can be set as required. Further, it is also possible to record the total number of read requests per cycle within a certain period of time by maintaining a data group with a size of several bytes. For a specific method, refer to the above-mentioned method for maintaining the data group corresponding to the number of reads requested per cycle.
需要说明的是,S201和S202不是必须的步骤。如前所述,当数据写入请求不是由用户101触发,而是由应用102的刷新或预热动作触发时,S201和S202不是必须的。It should be noted that S201 and S202 are not necessary steps. As mentioned above, when the data write request is not triggered by the user 101, but is triggered by a refresh or warm-up action of the application 102, S201 and S202 are not necessary.
S203:缓存管理装置104接收数据写入请求。S203: The cache management apparatus 104 receives the data writing request.
如前所述,数据写入请求存在两种情形:由用户101触发和由应用102触发。在这两种情形中,缓存管理装置104都将接收到数据写入请求。其中,数据写入请求指示的是将硬盘中的被请求写入的数据写入缓存。As mentioned above, there are two situations for the data write request: triggered by the user 101 and triggered by the application 102 . In both cases, the cache management device 104 will receive a data write request. The data write request indicates that the data requested to be written in the hard disk is written into the cache.
在一种可能的实现方式中,在用户101点击应用102后,将触发应用102向缓存103发起数据写入请求。同时,应用102向缓存103发起的数据写入请求将被缓存管理装置104记录。In a possible implementation manner, after the user 101 clicks on the application 102 , the application 102 will be triggered to initiate a data write request to the cache 103 . At the same time, the data write request initiated by the application 102 to the cache 103 will be recorded by the cache management apparatus 104 .
当缓存103中存在被请求写入的数据时,缓存103将向应用102返回该数据。同时,缓存管理装置104将记录该数据请求结果。也即,该数据读取请求得到了响应。When the data requested to be written exists in the cache 103 , the cache 103 will return the data to the application 102 . At the same time, the cache management device 104 will record the data request result. That is, the data read request is responded to.
当缓存103中不存在被请求写入的数据时,应用102将向硬盘105发起数据读取请求。同时,缓存管理装置104将记录数据请求结果。也即,数据读取请求未得到响应。When the data requested to be written does not exist in the cache 103 , the application 102 will initiate a data read request to the hard disk 105 . At the same time, the cache management device 104 will record the data request result. That is, the data read request is not responded to.
而当硬盘105中存在该数据时,硬盘105将向应用102返回该被请求写入的数据。同时,缓存管理装置104将决定是否将该被请求写入的数据写入缓存103。也即,缓存管理装置104接收到该被请求写入的数据的写入请求。When the data exists in the hard disk 105 , the hard disk 105 will return the requested data to the application 102 . At the same time, the cache management device 104 will decide whether to write the requested data into the cache 103 or not. That is, the cache management device 104 receives the write request of the data requested to be written.
在这一类可能的实现方式中,数据写入缓存103的请求是由用户101点击应用102所触发的。也即,由步骤S101和S102触发。In this type of possible implementations, the request for writing data into the cache 103 is triggered by the user 101 clicking on the application 102 . That is, it is triggered by steps S101 and S102.
在一种可能的实现方式中,数据写入缓存103的请求可以是由应用102所触发的。例如,可以是由内容分发网络(content delivery network,CDN)的刷新与预热触发。因此,缓存管理装置104将接收到该数据的写入请求。In a possible implementation manner, the request for writing data into the cache 103 may be triggered by the application 102 . For example, it can be triggered by the refresh and warm-up of the content delivery network (CDN). Therefore, the cache management device 104 will receive a write request for the data.
在一些可能的实现方式中,缓存管理装置104在积累一定数量的训练数据的过程中,将接收到一批数据写入请求。其中,一定数量可以是采样阈值,也可以根据需要 进行设置。In some possible implementations, the cache management apparatus 104 will receive a batch of data write requests in the process of accumulating a certain amount of training data. Among them, a certain number can be the sampling threshold, and can also be set as required.
例如,第一批数据写入请求指示的是在一定时间段内,缓存管理装置104接收到的一批数据写入请求的集合。在步骤S205中,根据采样规则可以确定第一批数据写入请求中的第一数据写入请求和第二数据写入请求。其中,第一数据写入请求或第二数据写入请求可以包含一个或多个数据写入请求。同时,下文所提及的第一数据指示的是第一数据写入请求中被请求写入的数据。同理,第二数据指示的是第二数据写入请求中被请求写入的数据。For example, the first batch of data write requests indicates a set of a batch of data write requests received by the cache management apparatus 104 within a certain period of time. In step S205, the first data writing request and the second data writing request in the first batch of data writing requests may be determined according to the sampling rule. Wherein, the first data writing request or the second data writing request may include one or more data writing requests. Meanwhile, the first data mentioned below indicates the data requested to be written in the first data write request. Similarly, the second data indicates the data requested to be written in the second data write request.
下文将以第一批数据写入请求为例进行介绍。The following will take the first batch of data write requests as an example for introduction.
S204:缓存管理装置104记录待写入数据的请求信息。S204: The cache management apparatus 104 records the request information of the data to be written.
当第一批数据写入请求来临时,记录第一批数据中各数据的ID和请求时间。进一步地,至少可以获得下述参数中的一项:各数据的每周期请求写入数、历史每周期平均请求写入数和每周期总请求写入数。其中,周期的长度可以根据需要进行设置。例如,如果周期为1秒,则数据的每周期请求写入数指示的是各数据在1秒内被请求写入的次数,而各数据的历史每周期平均请求写入数指示的是各数据在历史计数周期内每周期请求写入数的平均值。When the first batch of data writing request comes, record the ID and request time of each data in the first batch of data. Further, at least one of the following parameters can be obtained: the number of requested writes per cycle of each data, the historical average number of requested writes per cycle, and the total number of requested writes per cycle. The length of the period can be set as required. For example, if the period is 1 second, the requested writes per cycle of data indicates the number of times each data is requested to be written in 1 second, and the historical average The average number of writes requested per cycle over the historical count period.
根据记录的各数据写入请求的请求时间,可以获得每周期总请求写入数。该指标指示的是该缓存管理装置104在1秒内接收到的各数据总的写入请求数量。According to the recorded request time of each data write request, the total number of write requests per cycle can be obtained. The indicator indicates the total number of write requests for each data received by the cache management apparatus 104 within one second.
进一步地,在对各数据的每周期请求写入数进行记录后,可以选择保留一定时间内的每周期请求写入数。大规模数据系统中数据基数大,保存前述各数据的长时间内的每周期请求写入数会占据较大的存储空间。因此,为了减少存储空间,可以采用优化数据存储和缩短保留的时间周期的长度等方法。Further, after the number of requested writes per cycle of each data is recorded, the number of requested writes per cycle within a certain period of time may be selected to be retained. In a large-scale data system, the data base is large, and the number of writes requested per cycle for a long period of time when the aforementioned data is stored will occupy a large storage space. Therefore, in order to reduce the storage space, methods such as optimizing data storage and shortening the length of the retention time period can be adopted.
以优化数据存储为例,可以对各数据维护一个8字节大小的数据组。进一步地,将8个字节平均分割为32个单元。其中,每个单元为2位(bits),各单元编号为1、2、〃〃〃、32。其中每一个单元可以表示该数据每周期请求写入数的四种状态(00、01、10、11),分别对应无写入请求、有一次、二次、三次及以上写入请求。换言之,可以通过对各数据维护一个8字节大小的数据组,以记录该数据在过去的32个周期中的每周期请求写入数。按照上述的存储方法,可以实现以较小的存储空间存储较多的每周期请求写入数。Taking optimizing data storage as an example, an 8-byte data group can be maintained for each data. Further, the 8 bytes are equally divided into 32 units. Among them, each unit is 2 bits (bits), and each unit number is 1, 2, "〃", 32. Each unit can represent four states (00, 01, 10, 11) of the number of writes requested per cycle of the data, corresponding to no write request, one, two, three and more write requests, respectively. In other words, by maintaining an 8-byte data group for each data, the number of write requests per cycle of the data in the past 32 cycles can be recorded. According to the above storage method, it is possible to store a larger number of requested writes per cycle with a smaller storage space.
根据记录的各数据写入请求的请求时间,可以获得在各周期内的总请求写入数。也即,每周期总请求写入数。同样的,在对各每周期内的总请求写入数进行记录后,可以选择保留一定时间内的每周期总请求写入数。进一步的,也可以通过维护一个若干字节大小的数据组,记录一定时间内的每周期总请求写入数。具体的维护数据组的方法,可以参考上述维护每周期请求写入数对应数据组的方法。According to the recorded request time of each data write request, the total number of write requests in each cycle can be obtained. That is, the total number of requested writes per cycle. Similarly, after recording the total number of write requests per cycle, you can choose to keep the total number of write requests per cycle within a certain period of time. Further, it is also possible to record the total number of requested writes per cycle within a certain period of time by maintaining a data group with a size of several bytes. For a specific method for maintaining a data group, refer to the above-mentioned method for maintaining a data group corresponding to the number of writes requested per cycle.
需要说明的是,缓存管理装置104接收读取请求和写入请求可以相互独立。因此,这两个步骤(步骤S203和S204)的执行时间与上述的步骤S201和S202的执行时间无先后顺序。换言之,步骤S203和S204可以先于或后于步骤S201和S202被执行。可选的,步骤S203和S204也可以与步骤S201和S202同时被执行。It should be noted that the read request and the write request received by the cache management apparatus 104 may be independent of each other. Therefore, the execution time of these two steps (steps S203 and S204 ) has no sequence with the execution time of the above-mentioned steps S201 and S202 . In other words, steps S203 and S204 may be performed before or after steps S201 and S202. Optionally, steps S203 and S204 may also be performed simultaneously with steps S201 and S202.
在步骤S201至步骤S204中接收到数据读取请求和数据写入请求,并记录相关的信息后,可以利用其中的部分数据及相关信息对缓存写入预测模型进行训练。具体地, 预测模型训练部分包括步骤S205至S207。After receiving the data read request and the data write request in steps S201 to S204, and recording the related information, the cache write prediction model can be trained by using part of the data and the related information. Specifically, the prediction model training part includes steps S205 to S207.
S205:缓存管理装置104判断待写入数据是否满足采样规则。S205: The cache management apparatus 104 determines whether the data to be written satisfies the sampling rule.
根据在步骤S204中获取的各待写入数据的标识,可以判断各待写入数据是否满足采样规则。具体地,可以根据采样规则确定第一批数据写入请求中的第一数据写入请求和第二数据写入请求。也即,可以确定第一批待写入数据中的第一待写入数据和第二待写入数据。According to the identifiers of the data to be written obtained in step S204, it can be determined whether the data to be written satisfies the sampling rule. Specifically, the first data write request and the second data write request in the first batch of data write requests may be determined according to the sampling rule. That is, the first data to be written and the second data to be written in the first batch of data to be written can be determined.
其中,第一待写入数据指示的是满足采样规则的待写入数据,第二待写入数据指示的是不满足采样规则的待写入数据。在将第一待写入数据写入缓存的同时,还要将该数据用于训练写入预测模型。对于第二待写入数据,转至步骤S209进行处理。The first data to be written indicates the data to be written that satisfies the sampling rule, and the second data to be written indicates the data to be written that does not meet the sampling rule. When the first data to be written is written into the cache, the data is also used for training the writing prediction model. For the second data to be written, go to step S209 for processing.
可选的,大规模数据系统中数据基数大,难以将每条数据都作为预测模型的训练样本。因此,需要采样其中一部分数据作为训练样本。影响采样的因素至少包括两个:采样率和采样规则。Optionally, in a large-scale data system, the data base is large, and it is difficult to use each piece of data as a training sample for the prediction model. Therefore, a part of the data needs to be sampled as training samples. There are at least two factors that affect sampling: sampling rate and sampling rules.
其中,采样率指示的是平均每条数据被采样的概率,取值通常在0到1之间。采样率越低,样本的采集速度越慢。Among them, the sampling rate indicates the probability that each piece of data is sampled on average, and the value is usually between 0 and 1. The lower the sample rate, the slower the samples are collected.
采样规则可以根据系统中数据的标识来确定。例如,可以根据ID、URL或UUID等标识确定采样规则。本申请以ID为例建立采样规则。通常来说,ID可以是字符串或数字。因此,在利用数据的ID获得运算结果后,根据运算结果和采样值,可以确定是否对该数据进行采样。其中,运算方法可以是神经网络或哈希算法等方法。本申请实施例不对运算方法进行限制。而采样值可以根据需要进行设置。例如,可以令采样值等于采样率。Sampling rules can be determined based on the identity of the data in the system. For example, the sampling rule can be determined according to identifiers such as ID, URL, or UUID. This application uses ID as an example to establish a sampling rule. Generally speaking, IDs can be strings or numbers. Therefore, after the operation result is obtained by using the ID of the data, whether to sample the data can be determined according to the operation result and the sampling value. Wherein, the operation method may be a method such as a neural network or a hash algorithm. The embodiment of the present application does not limit the calculation method. The sampling value can be set as required. For example, the sample value can be made equal to the sample rate.
具体的,利用采样值对哈希运算结果取余。对于余数为0的数据ID,将该待写入数据作为第一待写入数据。也即,训练数据。反之,若采样值对哈希运算结果取余不为0,则不对该数据进行采样。也即,转至步骤S209。Specifically, the sampling value is used to take the remainder of the hash operation result. For the data ID whose remainder is 0, the data to be written is regarded as the first data to be written. That is, training data. Conversely, if the remainder of the sampling value to the hash operation result is not 0, the data will not be sampled. That is, go to step S209.
S206:缓存管理装置104对满足采样规则的第一待写入数据进行标注。S206: The cache management apparatus 104 marks the first data to be written that satisfies the sampling rule.
根据第一待写入数据的访问情况和淘汰情况,缓存管理装置104可以对第一待写入数据进行标注。According to the access situation and the elimination situation of the first data to be written, the cache management apparatus 104 may mark the first data to be written.
在一种可能实现方式中,根据第一待写入数据在经过S205的判断之后的一段时间内的被请求情况,可以对第一待写入数据进行标注。也即,根据第一待写入数据在一个缓存平均淘汰周期内被请求写入的次数和读取的次数,可以确定第一待写入数据的标注情况。In a possible implementation manner, the first data to be written may be marked according to the request situation of the first data to be written within a period of time after the judgment in S205. That is, according to the number of times that the first data to be written is requested to be written and the number of times to be read within an average cache elimination cycle, the labeling situation of the first data to be written can be determined.
其中,所述一段时间的长度可以根据需要进行设置。下文将以缓存平均淘汰周期为例进行介绍,具体的如何获得缓存平均淘汰周期将在步骤S213中将进行详细的介绍。The length of the period of time can be set as required. The following will take the average cache elimination period as an example for introduction, and how to obtain the average cache elimination period will be introduced in detail in step S213.
在这一类可能的实现方式中,当第一待写入数据在一个平均淘汰周期内满足下列情况中的至少一种时:被请求写入至少一次和被请求读取至少一次,将该第一待写入数据标注为热数据。In this type of possible implementations, when the first data to be written satisfies at least one of the following conditions within an average elimination cycle: being requested to write at least once and being requested to read at least once, the first data to be written is at least one of the following conditions: A data to be written is marked as hot data.
反之,当第一待写入数据在一个缓存平均淘汰周期内同时满足下列两种情况时:未被请求写入和未被请求读取,将该第一待写入数据标注为冷数据。On the contrary, when the first data to be written satisfies both of the following two conditions within an average cache elimination cycle: no writing is requested and no reading is requested, the first data to be written is marked as cold data.
在一种可能实现方式中,还可以根据第一待写入数据在未来一个平均淘汰周期内的淘汰情况,对训练数据进行标注。In a possible implementation manner, the training data may also be marked according to the elimination situation of the first data to be written in an average elimination cycle in the future.
如前所述,在S205中若待写入数据满足采样规则,在对第一待写入数据进行标注的同时,还将该第一待写入数据直接写入缓存中。由于缓存的存储空间有限,因此需要根据淘汰规则对存储的数据进行淘汰。具体的淘汰规则将在S212中详细介绍。As described above, if the data to be written meets the sampling rule in S205, the first data to be written is also directly written into the cache while the first data to be written is marked. Since the storage space of the cache is limited, the stored data needs to be eliminated according to the elimination rule. The specific elimination rules will be introduced in detail in S212.
当第一待写入数据在一个缓存平均淘汰周期内且在被缓存淘汰之前,既未被请求写入,也未被请求读取。在缓存将该数据淘汰后,将该第一待写入数据标注为冷数据。When the first data to be written is within an average cache elimination cycle and before being eliminated by the cache, neither writing nor reading is requested. After the data is eliminated from the cache, the first data to be written is marked as cold data.
需要说明的是,在对第一待写入数据进行标注后,则不再修改该数据的标注状态。在完成对待写入数据的标注后,可以转至步骤S207用于训练预测模型。It should be noted that after the first data to be written is marked, the marked state of the data is not modified. After completing the labeling of the data to be written, it may go to step S207 for training the prediction model.
S207:缓存管理装置104根据记录信息和标注过的第一待写入数据,对预测模型进行训练。S207: The cache management device 104 trains the prediction model according to the record information and the marked first data to be written.
在S206中对第一待写入数据进行标注后,根据各第一待写入数据的标注信息和下述参数中的至少一项:每周期请求写入数、每周期总请求写入数、缓存数据平均大小、缓存平均淘汰周期、每周期请求读取数和每周期总请求读取数,可以对预测模型进行训练。After marking the first data to be written in S206, according to the marking information of each first data to be written and at least one of the following parameters: the number of writes requested per cycle, the total number of writes requested per cycle, The average size of cached data, the average cache eviction period, the number of requested reads per cycle, and the total number of requested reads per cycle can be used to train the predictive model.
具体地,根据S202中获得的每周期总请求写入数,可以获得平均每周期总请求写入数。如前所述,在S202中维护了一个若干字节大小的数据组,记录了一定时间内的每周期总请求写入数。进一步地,可以通过求取该数据组平均值的方法获得平均每周期总请求写入数。Specifically, according to the total requested writes per cycle obtained in S202, the average total requested writes per cycle can be obtained. As mentioned above, in S202, a data group with a size of several bytes is maintained, and the total number of requested writes per cycle within a certain period of time is recorded. Further, the average total requested write number per cycle can be obtained by calculating the average value of the data group.
可选的,对于S204中获得的每周期总请求读取数,可以获得平均每周期总请求读取数。具体的,如前所述,在S204中维护了一个若干字节大小的数据组,记录了一定时间内的每周期总请求读取数。进一步地,可以通过求取该数据组平均值的方法获得平均每周期总请求读取数。Optionally, for the total number of read requests per cycle obtained in S204, the average total number of read requests per cycle can be obtained. Specifically, as mentioned above, a data group of several bytes in size is maintained in S204, and the total number of read requests per cycle within a certain period of time is recorded. Further, the average total number of read requests per cycle can be obtained by calculating the average value of the data group.
缓存数据平均大小指示的是缓存介质中存储的数据大小的平均值。具体的获得方法将在步骤S211中进行详细的介绍。The average cache data size indicates the average size of the data stored in the cache medium. The specific obtaining method will be described in detail in step S211.
缓存平均淘汰周期指示的是缓存介质中各数据从进入缓存到被淘汰的时长的平均值。具体的获得方法将在步骤S213中进行详细的介绍。The average cache eviction period indicates the average value of the time period from the entry of the cache to the eviction of each data in the cache medium. The specific obtaining method will be described in detail in step S213.
将缓存数据平均大小、缓存平均淘汰周期、平均每周期总请求写入数、各待写入数据的每周期请求写入数、平均每周期总请求读取数和各待写入数据的每周期请求读取数中的至少一项作为输入,各待写入数据的标注信息作为输出,可以对预测模型进行训练。The average size of cache data, the average cache elimination cycle, the average number of total requested writes per cycle, the number of requested writes per cycle of each data to be written, the average total number of reads per cycle, and the average number of writes per cycle of each data to be written At least one item of the requested read numbers is used as input, and the label information of each data to be written is used as output, and the prediction model can be trained.
其中,预测模型可以是反向传播神经网络模型(back propagation neural network)或长短期记忆网络(long short-term memory)等人工智能模型。需要说明的是,本申请实施例不对预测模型的建立方法进行限制,并且因为是现有技术,不再赘述。Among them, the prediction model can be an artificial intelligence model such as a back propagation neural network model or a long short-term memory network. It should be noted that the embodiments of the present application do not limit the method for establishing the prediction model, and since it is the prior art, details are not described again.
在一些可能的实现方式中,当在S206中已完成标注且尚未用于训练的数据数量达到或超过采样阈值时,可以启动对预测模型的训练。其中,采样阈值可以根据需要进行设置。例如,可以设置为当完成标注的训练数据数量达到10000条时,启动对预测模型的一轮训练。In some possible implementations, when the amount of data that has been labelled and has not been used for training reaches or exceeds the sampling threshold in S206, the training of the prediction model may be started. The sampling threshold can be set as required. For example, it can be set to start a round of training for the prediction model when the number of labeled training data reaches 10,000.
在一些可能的实现方式中,可以对预测模型的训练轮次进行设置。根据预测模型已经进行训练的轮次和轮次阈值,可以确定是否需要对模型进行进一步的训练。当训练轮次达到或超过轮次阈值时,可以不再对预测模型进行训练。In some possible implementations, the training rounds of the prediction model can be set. Based on the number of epochs that the predictive model has been trained on and the epoch threshold, it can be determined whether further training of the model is required. When the training epoch reaches or exceeds the epoch threshold, the predictive model can no longer be trained.
例如,当轮次阈值设置为100时,在对预测模型进行100轮训练后,可以不再对待写入数据进行采样和标注等操作。进一步地,不再对预测模型进行训练。For example, when the round threshold is set to 100, after 100 rounds of training on the prediction model, operations such as sampling and labeling of the data to be written can no longer be performed. Further, the predictive model is no longer trained.
在一些可能的实现方式中,在利用第一待写入数据对预测模型进行训练之后,可以删除预测模型中存储的第一待写入数据。In some possible implementations, after the prediction model is trained by using the first data to be written, the first data to be written stored in the prediction model may be deleted.
在一些可能的实现方式中,可以对输出量,也即各第一待写入数据的标注信息进行预处理。具体的,可以将标注状态中的冷/热数据转换成0/1或1/0。在这一类可能的实现方式中,预测模型的输出量可以控制在0到1之间。In some possible implementations, the output amount, that is, the label information of each first data to be written, may be preprocessed. Specifically, the cold/hot data in the marked state can be converted into 0/1 or 1/0. In this class of possible implementations, the output of the predictive model can be controlled between 0 and 1.
在步骤S205至S207中对待写入数据进行采样并对预测模型进行训练后,将获得一个训练后的预测模型。对于在S205中不满足采样规则的数据,可以基于预测模型确定其写入概率。其中,预测模型可以是步骤S207中训练后的模型,也可以是步骤S207中训练前的模型。具体地,用于预测的模型需要经过至少一轮的训练。After sampling the data to be written and training the prediction model in steps S205 to S207, a trained prediction model will be obtained. For the data that does not satisfy the sampling rule in S205, its writing probability may be determined based on the prediction model. The prediction model may be the model after training in step S207 or the model before training in step S207. Specifically, the model used for prediction needs to go through at least one round of training.
写入判断部分包括步骤S208至步骤S211。The writing judgment section includes steps S208 to S211.
S208:缓存管理装置104生成预测模型,并用于预测待预测数据的写入概率。S208: The cache management apparatus 104 generates a prediction model and uses it to predict the writing probability of the data to be predicted.
在S207中对预测模型进行训练后,可以获得一个至少完成一轮训练的预测模型,用于预测待预测数据的写入状态。其中,该待预测数据指示的是在步骤S209中确定的不满足特殊规则的第二待写入数据。具体的不满足特殊规则的第二待写入数据的获得方法将在步骤S209中进行介绍。After the prediction model is trained in S207, a prediction model that has completed at least one round of training can be obtained to predict the writing state of the data to be predicted. Wherein, the to-be-predicted data indicates the second to-be-written data determined in step S209 that does not satisfy the special rule. A specific method for obtaining the second data to be written that does not meet the special rules will be introduced in step S209.
需要说明的是,在本步骤中用于预测第二待写入数据的写入概率的预测模型可能不同于步骤S207中训练后的预测模型。在一些可能的实现方式中,步骤S208中使用的缓存写入预测模型是步骤S207中训练前的缓存写入预测模型。也即,由上一批数据写入请求对应的数据训练后的缓存写入预测模型。换言之,由第一批数据中的第一待写入数据训练的缓存写入预测模型,可以用于预测第二批数据写入请求对应的第二批数据中的部分数据。其中,第二批数据写入请求的发生时间应晚于第一批数据写入请求的发生时间。It should be noted that the prediction model used to predict the writing probability of the second data to be written in this step may be different from the prediction model trained in step S207. In some possible implementations, the cache write prediction model used in step S208 is the cache write prediction model before training in step S207. That is, the cache write prediction model trained by the data corresponding to the previous batch of data write requests. In other words, the cache write prediction model trained by the first data to be written in the first batch of data can be used to predict part of the data in the second batch of data corresponding to the second batch of data write requests. Wherein, the occurrence time of the second batch of data write requests should be later than the occurrence time of the first batch of data write requests.
将待预测数据的每周期请求写入数和缓存数据平均大小、缓存平均淘汰周期、平均每周期总请求写入数、平均每周期总请求读取数和该第二待写入数据的每周期请求读取数中的至少一项作为输入,可以对该待预测数据的写入状态进行预测。The number of requested writes per cycle of the data to be predicted and the average size of cached data, the average cache elimination cycle, the average total requested writes per cycle, the average total requested reads per cycle, and the second to-be-written data per cycle At least one of the requested read counts is used as input, and the write status of the data to be predicted can be predicted.
在利用预测模型对该待预测数据的写入状态进行预测后,可以获得一个0到1之间的输出值。也即,该待预测数据的写入概率。After using the prediction model to predict the writing state of the data to be predicted, an output value between 0 and 1 can be obtained. That is, the writing probability of the data to be predicted.
S209:缓存管理装置104判断不满足采样规则的第二待写入数据是否满足特殊规则。S209: The cache management apparatus 104 determines whether the second data to be written that does not satisfy the sampling rule satisfies the special rule.
在S205中经过判断,不满足采样规则的第二待写入数据会转至S209进行处理。在S209中将进一步地判断该数据是否满足特殊规则。After judgment in S205, the second data to be written that does not satisfy the sampling rule will be transferred to S209 for processing. In S209, it will be further judged whether the data satisfies the special rules.
特殊规则包括对部分数据的写入和对部分数据的禁入。例如,按照租户的要求,特殊类型的文件不写入,特殊域名的文件不写入等。Special rules include the write of partial data and the exclusion of partial data. For example, according to the requirements of the tenant, special types of files are not written, and files of special domain names are not written.
对于满足特殊规则的第二待写入数据,将其写入缓存。也即,转至步骤S211。For the second to-be-written data that satisfies the special rule, write it into the cache. That is, go to step S211.
对于不满足特殊规则的第二待写入数据,则转至步骤S210。For the second data to be written that does not satisfy the special rule, go to step S210.
需要说明的是,步骤S209是缓存写入方法200中可选的步骤。It should be noted that step S209 is an optional step in the cache writing method 200 .
S210:缓存管理装置104根据不满足特殊规则的第二待写入数据的写入概率和写 入阈值,确定其写入状态。S210: The cache management device 104 determines the write status of the second to-be-written data that does not meet the special rules and the write probability and write threshold.
根据写入阈值和该不满足采样规则的第二待写入数据的写入概率,可以确定该数据的写入状态。其中,写入阈值可以根据需要进行设置。According to the write threshold and the write probability of the second data to be written that does not satisfy the sampling rule, the write state of the data can be determined. The write threshold can be set as required.
不满足采样规则的第二待写入数据的写入概率可以利用S208中的预测模型获得。也即,将该不满足采样规则的第二待写入数据作为预测模型中的待预测数据。具体的,将该数据的每周期请求写入数和缓存数据平均大小、缓存平均淘汰周期、平均每周期总请求写入数、平均每周期总请求读取数和该数据的每周期请求读取数中的至少一项作为预测模型的输入,可以对该数据的写入状态进行预测。The writing probability of the second to-be-written data that does not satisfy the sampling rule may be obtained by using the prediction model in S208. That is, the second to-be-written data that does not satisfy the sampling rule is used as the to-be-predicted data in the prediction model. Specifically, the number of requested writes per cycle of the data and the average size of cached data, the average cache elimination cycle, the average total number of requested writes per cycle, the average total number of requested reads per cycle, and the average number of requested reads per cycle of the data At least one of the numbers is used as an input to the prediction model, which can predict the writing state of the data.
在一些可能的实现方式中,在利用预测模型对该数据的写入状态进行预测后,可以获得一个0到1之间的输出值。也即,该数据的写入概率。In some possible implementations, an output value between 0 and 1 can be obtained after using the prediction model to predict the writing state of the data. That is, the writing probability of the data.
进一步地,根据写入概率和写入阈值,可以确定该不满足采样规则的第二待写入数据的写入状态。Further, according to the write probability and the write threshold, the write state of the second data to be written that does not satisfy the sampling rule can be determined.
具体地,当写入概率大于或等于写入阈值时,该数据将被写入缓存。当写入概率小于写入阈值时,该数据将不会被写入缓存。Specifically, when the write probability is greater than or equal to the write threshold, the data will be written to the cache. When the write probability is less than the write threshold, the data will not be written to the cache.
在一些可能的实现方式中,该预测模型可以将写入阈值内置于预测模型内。也即,预测模型可以直接输出是否将第二待写入数据写入缓存的判断结果。In some possible implementations, the predictive model may have write thresholds built into the predictive model. That is, the prediction model can directly output the judgment result of whether to write the second data to be written into the cache.
需要说明的是,上述利用预测模型对写入概率进行预测的前提,是步骤S207中对预测模型进行了至少一轮的训练了。换言之,在步骤S206中待写入数据的累积数量未达到采样阈值之前,不对预测模型进行训练。进一步地,可以依照现有技术对不满足采样规则的第二待写入数据的写入状态进行判断。其中,现有技术包括基于特定规则或者基于频次统计的写入规则等,不再赘述。It should be noted that the premise of using the prediction model to predict the writing probability is that at least one round of training has been performed on the prediction model in step S207. In other words, the prediction model is not trained until the accumulated number of data to be written in step S206 does not reach the sampling threshold. Further, the writing state of the second to-be-written data that does not satisfy the sampling rule can be determined according to the prior art. Among them, the prior art includes writing rules based on specific rules or frequency statistics, etc., which will not be repeated.
S211:缓存管理装置104将确定写入的待写入数据写入缓存,并统计写入数据的大小。S211: The cache management device 104 writes the determined to-be-written data into the cache, and counts the size of the written data.
在步骤S211中确定写入的待写入数据至少包括下述三类情况:In step S211, it is determined that the data to be written to be written includes at least the following three types of situations:
在一些可能的实现方式中,确定写入的数据可以是在步骤S205中满足采样规则的待写入数据。也即,数据的ID对采样值取余为0的第一待写入数据。In some possible implementations, it is determined that the data to be written may be the data to be written that satisfies the sampling rule in step S205. That is, the ID of the data takes the remainder of the sample value to be 0 for the first data to be written.
在一些可能的实现方式中,确定写入的数据也可以是在步骤S209中满足特殊规则的第二待写入数据。其中,第二待写入数据指示的是数据的ID对采样值取余不为0的待写入数据。In some possible implementations, it is determined that the data to be written may also be the second data to be written that satisfies the special rule in step S209. Wherein, the second data to be written indicates the data to be written in which the remainder of the ID of the data and the sampling value is not 0.
在一些可能的实现方式中,确定写入的数据还可以是在步骤S210中写入概率不小于写入阈值的不满足特殊规则的第二待写入数据。In some possible implementations, it is determined that the data to be written may also be the second data to be written that does not meet the special rules and whose writing probability is not less than the writing threshold in step S210 .
可选的,在将上述待写入数据写入缓存的同时,需要记录写入的各数据的大小,从而计算当前时刻缓存介质中的数据平均大小。进一步地,该数据平均大小可以在步骤S207中作为输入量,用于训练预测模型。Optionally, when the data to be written is written into the cache, the size of each data to be written needs to be recorded, so as to calculate the average size of the data in the cache medium at the current moment. Further, the average size of the data can be used as an input in step S207 for training the prediction model.
在对第二待写入数据进行写入判断后,部分第二待写入数据将被写入缓存。因为缓存的存储空间有限,因此需要定期淘汰部分数据。具体地,缓存数据淘汰部分包括步骤S212至步骤S214。After writing judgment on the second data to be written, part of the second data to be written will be written into the cache. Because the storage space of the cache is limited, some data needs to be retired periodically. Specifically, the cache data elimination part includes steps S212 to S214.
S212:根据淘汰规则确定是否淘汰缓存中的部分数据。S212: Determine whether to eliminate some data in the cache according to the elimination rule.
由于缓存介质的数据储存量有限,因此需要不断淘汰数据,腾出存储空间缓存新 写入的数据。当写入的数据量超过容量时,可以选择一部分数据淘汰。具体的淘汰规则属于现有技术,不再赘述。常见的缓存数据淘汰算法包括最近最少使用(least recently used,LRU)和先进先出(first-in,first-out,FIFO)等方法。Since the data storage capacity of the cache medium is limited, it is necessary to continuously eliminate data to free up storage space to cache newly written data. When the amount of data written exceeds the capacity, a part of the data can be selected to be eliminated. The specific elimination rules belong to the prior art and will not be repeated here. Common cache data elimination algorithms include least recently used (LRU) and first-in, first-out (FIFO) methods.
对于确定不被淘汰的写入数据,不对其进行操作。对于确定被淘汰的写入数据,将该数据移出缓存。Do not operate on write data that is determined not to be eliminated. For write data that is determined to be eliminated, move the data out of the cache.
S213:缓存管理装置104更新被淘汰数据的标注状态,计算缓存平均淘汰周期。S213: The cache management device 104 updates the labeling state of the eliminated data, and calculates the average cache elimination period.
如前所述,在步骤S211中写入缓存的待写入数据至少包括三种情况。其中,在一些可能的实现方式中,所述待写入数据可以是在步骤S205中满足采样规则的第一待写入数据。也即,第一待写入数据将同时在步骤S206中等待标记。As mentioned above, the data to be written into the cache in step S211 includes at least three cases. Wherein, in some possible implementation manners, the data to be written may be the first data to be written that satisfies the sampling rule in step S205. That is, the first data to be written will simultaneously wait for the mark in step S206.
根据第一待写入数据在缓存中的被淘汰情况,可以对第一待写入数据进行标注。具体的,对于被淘汰的数据,若该数据属于第一待写入数据且在步骤S206中尚未完成标记,则将该第一待写入数据标记为冷数据。进一步地,将在步骤S206中完成标记的该第一待写入数据转至步骤S207用作预测模型的训练数据。The first data to be written may be marked according to the elimination of the first data to be written in the cache. Specifically, for the eliminated data, if the data belongs to the first data to be written and the marking has not been completed in step S206, the first data to be written is marked as cold data. Further, the first to-be-written data marked in step S206 is transferred to step S207 and used as training data for the prediction model.
此外,根据各被淘汰数据的淘汰时间和数据的写入时间,可以获得缓存平均淘汰周期。其中,数据的写入时间即步骤S202中记录的该数据的请求写入时间。具体的,将各被淘汰数据的淘汰时间减去其写入时间,可以获得各被淘汰数据的淘汰周期。进一步的,通过计算各被淘汰数据的淘汰周期的平均值,可以确定缓存平均淘汰周期。其中,所述各被淘汰数据可以是历史被淘汰的所有数据。可选的,所述各被淘汰数据也可以是过去一段时间内的被淘汰数据。进一步地,该缓存平均淘汰周期可以在步骤S207中作为输入量,用于对预测模型进行训练。In addition, according to the elimination time of each eliminated data and the writing time of the data, the average cache elimination cycle can be obtained. The writing time of the data is the requested writing time of the data recorded in step S202. Specifically, the elimination period of each eliminated data can be obtained by subtracting its write time from the elimination time of each eliminated data. Further, by calculating the average value of the elimination period of each eliminated data, the average cache elimination period can be determined. Wherein, each item of eliminated data may be all data that has been eliminated in history. Optionally, the eliminated data may also be eliminated data within a period of time in the past. Further, the average cache elimination period can be used as an input in step S207 for training the prediction model.
S214:缓存管理装置104输出被淘汰数据。S214: The cache management apparatus 104 outputs the eliminated data.
将步骤S212中确定需要淘汰的数据输出。The data determined to be eliminated in step S212 are output.
需要说明的是,步骤S213和步骤S214没有固定的执行顺序。也即,步骤S213可以先于或后于步骤S214被执行。可选的,步骤S213也可以和步骤S214同时被执行。It should be noted that, steps S213 and S214 have no fixed execution order. That is, step S213 may be performed before or after step S214. Optionally, step S213 and step S214 may also be performed simultaneously.
本申请还提供一种缓存管理装置104,如图3所示,包括:The present application also provides a cache management device 104, as shown in FIG. 3, including:
通信单元302,用于在S201接收数据读取请求和在S203中接收数据写入请求。通信单元302还用于在S207中接收设置的采样阈值。在S210中,通信单元302用于获取写入阈值。通信单元302还用于接收S209中租户设置的特殊规则。The communication unit 302 is configured to receive a data read request in S201 and a data write request in S203. The communication unit 302 is further configured to receive the set sampling threshold in S207. In S210, the communication unit 302 is used to obtain the write threshold. The communication unit 302 is further configured to receive the special rules set by the tenant in S209.
存储单元304,用于存储在S202中记录的待读取数据的请求信息和在S204中记录的待写入数据的请求信息。在缓存管理方法200中,存储单元304用于存储S205中确定的第一待写入数据的相关信息。存储单元304还用于存储S207中训练后的预测模型中的参数。S207中接收的采样阈值和S210中接收的写入阈值也将被存储在存储单元304中。存储单元304还用于存储S209中租户设置的特殊规则。The storage unit 304 is configured to store the request information of the data to be read recorded in S202 and the request information of the data to be written recorded in S204. In the cache management method 200, the storage unit 304 is configured to store the relevant information of the first data to be written determined in S205. The storage unit 304 is further configured to store the parameters in the prediction model trained in S207. The sampling threshold received in S207 and the write threshold received in S210 will also be stored in the storage unit 304 . The storage unit 304 is also used to store the special rules set by the tenant in S209.
缓存单元306,在缓存管理方法200中,用于缓存S205中确定的第一待写入数据。在S209中满足特殊规则确定被写入缓存的第二待写入数据,和S210中写入概率大于写入阈值的第二待写入数据均将被缓存至缓存单元306中。The cache unit 306, in the cache management method 200, is configured to cache the first data to be written determined in S205. In S209 , the second to-be-written data determined to be written to the cache and the second to-be-written data whose write probability is greater than the write threshold in S210 will both be cached in the cache unit 306 .
处理单元308,用于执行S202和S204中的记录操作,并将待读取数据和待写入 数据的请求信息存入存储单元304中。处理单元308还用于在S205中对当前待写入数据进行判断,确定第一待写入数据和第二待写入数据。在缓存管理方法200中,处理单元308用于对第一待写入数据进行标注。进一步地,S207中根据记录的请求信息和标注信息对预测模型进行训练的操作也是由处理单元308执行的。在S208中,处理单元308用于执行预测待预测数据的写入概率的操作。处理单元308还用于在S209中判断第二待写入数据是否满足特殊规则。在S210中,根据S208中获得的写入概率和写入阈值确定是否将第二待写入数据写入缓存的操作也是由处理单元308执行的。S211中将确定写入缓存的待写入数据写入缓存,并统计缓存内数据大小的操作也是由处理单元308执行。处理单元308还用于在S212中根据淘汰规则输出缓存中的部分数据。在S213中,根据数据的淘汰情况更新被淘汰数据的标注状态,计算平均淘汰周期的操作由处理单元308执行。The processing unit 308 is configured to perform the recording operations in S202 and S204, and store the request information of the data to be read and the data to be written into the storage unit 304. The processing unit 308 is further configured to judge the current data to be written in S205, and determine the first data to be written and the second data to be written. In the cache management method 200, the processing unit 308 is configured to mark the first data to be written. Further, the operation of training the prediction model according to the recorded request information and annotation information in S207 is also performed by the processing unit 308 . In S208, the processing unit 308 is configured to perform an operation of predicting the writing probability of the data to be predicted. The processing unit 308 is further configured to determine in S209 whether the second data to be written satisfies the special rule. In S210, the operation of determining whether to write the second data to be written into the cache according to the write probability and the write threshold obtained in S208 is also performed by the processing unit 308. In S211 , the operation of determining the to-be-written data written into the cache into the cache, and calculating the size of the data in the cache is also performed by the processing unit 308 . The processing unit 308 is further configured to output the partial data in the cache according to the elimination rule in S212. In S213, the labeling state of the eliminated data is updated according to the elimination situation of the data, and the operation of calculating the average elimination period is performed by the processing unit 308.
具体地,处理单元308可以包括记录单元310、训练单元312、决策单元314和淘汰单元316。Specifically, the processing unit 308 may include a recording unit 310 , a training unit 312 , a decision unit 314 and an elimination unit 316 .
记录单元310,用于执行S202和S204中的记录操作,并将待读取数据和待写入数据的请求信息存入存储单元304中。决策单元314,用于在S205中对当前待写入数据进行判断,确定第一待写入数据和第二待写入数据。在缓存管理方法200中,在确定第一待写入数据后,训练单元312用于对第一待写入数据进行标注。进一步地,S207中根据记录的请求信息和标注信息对预测模型进行训练的操作也是由训练单元312执行的。The recording unit 310 is configured to perform the recording operations in S202 and S204 , and store the data to be read and the request information of the data to be written into the storage unit 304 . The decision unit 314 is configured to judge the current data to be written in S205, and determine the first data to be written and the second data to be written. In the cache management method 200, after determining the first data to be written, the training unit 312 is configured to mark the first data to be written. Further, the operation of training the prediction model according to the recorded request information and annotation information in S207 is also performed by the training unit 312 .
在S208中,决策单元314用于执行预测待预测数据的写入概率的操作。决策单元314还用于在S209中判断第二待写入数据是否满足特殊规则。在S210中,根据S208中获得的写入概率和写入阈值确定是否将第二待写入数据写入缓存的操作也是由决策单元314执行的。S211中将确定写入缓存的待写入数据写入缓存,并统计缓存内数据大小的操作也是由决策单元314执行。淘汰单元316用于在S212中根据淘汰规则输出缓存中的部分数据。在S213中,根据数据的淘汰情况更新被淘汰数据的标注状态,计算平均淘汰周期的操作由淘汰单元316执行。In S208, the decision unit 314 is configured to perform an operation of predicting the writing probability of the data to be predicted. The decision unit 314 is further configured to determine in S209 whether the second data to be written satisfies the special rule. In S210 , the operation of determining whether to write the second data to be written into the cache according to the write probability and the write threshold obtained in S208 is also performed by the decision unit 314 . In S211 , the operation of determining the to-be-written data to be written into the cache and writing the data into the cache and counting the size of the data in the cache is also performed by the decision unit 314 . The elimination unit 316 is configured to output the partial data in the cache according to the elimination rule in S212. In S213, the labeling state of the eliminated data is updated according to the elimination situation of the data, and the operation of calculating the average elimination period is performed by the elimination unit 316.
本申请还提供一种计算设备400。如图4所示,计算设备包括:总线402、处理器404、存储器406和通信接口408。处理器404、存储器406和通信接口408之间通过总线402通信。计算设备400可以是服务器或终端设备。应理解,本申请不限定计算设备400中的处理器、存储器的个数。The present application also provides a computing device 400 . As shown in FIG. 4 , the computing device includes a bus 402 , a processor 404 , a memory 406 and a communication interface 408 . Communication between processor 404 , memory 406 and communication interface 408 is via bus 402 . Computing device 400 may be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 400 .
总线402可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。总线可以分为地址总线、数据总线、控制总线等。为便于表示,图4中仅用一条线表示,但并不表示仅有一根总线或一种类型的总线。总线404可包括在计算设备400各个部件(例如,存储器406、处理器404、通信接口408)之间传送信息的通路。The bus 402 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus or the like. The bus can be divided into address bus, data bus, control bus and so on. For ease of presentation, only one line is shown in FIG. 4, but it does not mean that there is only one bus or one type of bus. Bus 404 may include pathways for communicating information between various components of computing device 400 (eg, memory 406, processor 404, communication interface 408).
处理器404可以包括中央处理器(central processing unit,CPU)、图形处理器(graphics processing unit,GPU)、微处理器(micro processor,MP)或者数字信号处理器(digital signal processor,DSP)等处理器中的任意一种或多种。The processor 404 may include processing such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP). any one or more of the devices.
存储器406可以包括易失性存储器(volatile memory),例如随机存取存储器(random access memory,RAM)。处理器404还可以包括非易失性存储器(non-volatile memory),例如只读存储器(read-only memory,ROM),快闪存储器,机械硬盘(hard disk drive,HDD)或固态硬盘(solid state drive,SSD)。存储器406中存储有可执行的程序代码,处理器404执行该可执行的程序代码以实现前述缓存管理方法200。具体的,存储器406上存有缓存管理装置104用于执行缓存管理方法200的指令。Memory 406 may include volatile memory, such as random access memory (RAM). The processor 404 may also include non-volatile memory (non-volatile memory), such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state hard disk (solid state) drive, SSD). The memory 406 stores executable program codes, and the processor 404 executes the executable program codes to implement the aforementioned cache management method 200 . Specifically, the memory 406 stores instructions for the cache management apparatus 104 to execute the cache management method 200 .
通信接口403使用例如但不限于网络接口卡、收发器一类的收发模块,来实现计算设备400与其他设备或通信网络之间的通信。The communication interface 403 uses a transceiver module such as, but not limited to, a network interface card, a transceiver, etc., to implement communication between the computing device 400 and other devices or a communication network.
本申请实施例还提供了一种计算设备集群。如图5所示,所述计算设备集群包括至少一个计算设备400。该计算设备集群中包括的计算设备集群可以全部是终端设备,也可以全部是云服务器,还可以部分是云服务器部分是终端设备。Embodiments of the present application further provide a computing device cluster. As shown in FIG. 5 , the computing device cluster includes at least one computing device 400 . The computing device clusters included in the computing device cluster may all be terminal devices, may all be cloud servers, or may be partly cloud servers and partly terminal devices.
在上述的三种关于计算设备集群的部署方式下,计算设备集群中的一个或多个计算设备400中的存储器406中可以存有相同的缓存管理装置104用于执行缓存管理方法200的指令。In the above-mentioned three deployment manners about the computing device cluster, the memory 406 in one or more computing devices 400 in the computing device cluster may store the same cache management apparatus 104 for executing the instructions of the cache management method 200 .
在一些可能的实现方式中,该计算设备集群中的一个或多个计算设备400也可以用于执行缓存管理装置104用于执行缓存管理方法200的部分指令。换言之,一个或多个计算设备400的组合可以共同执行缓存管理装置104用于执行缓存管理方法200的指令。In some possible implementations, one or more computing devices 400 in the computing device cluster may also be used to execute part of the instructions of the cache management apparatus 104 for executing the cache management method 200 . In other words, a combination of one or more computing devices 400 may collectively execute the instructions of the cache management apparatus 104 for executing the cache management method 200 .
需要说明的是,计算设备集群中的不同的计算设备400中的存储器406可以存储不同的指令,用于执行缓存管理装置104的部分功能。It should be noted that, the memories 406 in different computing devices 400 in the computing device cluster may store different instructions for executing some functions of the cache management apparatus 104 .
图6示出了一种可能的实现方式。如图6所示,两个计算设备400A和400B通过通信接口408实现连接。计算设备400A中的存储器上存有用于执行通信单元302、存储单元304、记录单元308、训练单元310、决策单元312和淘汰单元314的功能的指令。计算设备400B中的存储器上存有用于执行缓存单元306的功能的指令。换言之,计算设备400A和400B的存储器406共同存储了缓存管理装置104用于执行缓存管理方法200的指令。Figure 6 shows one possible implementation. As shown in FIG. 6 , two computing devices 400A and 400B are connected through a communication interface 408 . Instructions for performing the functions of the communication unit 302 , the storage unit 304 , the recording unit 308 , the training unit 310 , the decision unit 312 , and the elimination unit 314 are stored on memory in the computing device 400A. Instructions for performing the functions of cache unit 306 are stored on memory in computing device 400B. In other words, the memories 406 of the computing devices 400A and 400B collectively store the instructions for the cache management apparatus 104 to execute the cache management method 200 .
图6所示的计算设备集群之间的连接方式可以是考虑到本申请提供的缓存管理方法200需要对缓存单元306中的数据进行高速的写入或读取的操作。因此,考虑将缓存功能交由计算设备400B执行。The connection mode between the computing device clusters shown in FIG. 6 may take into account that the cache management method 200 provided by the present application needs to perform high-speed writing or reading operations on the data in the cache unit 306 . Therefore, consider offloading the caching function to computing device 400B.
应理解,图6中示出的计算设备400A的功能也可以由多个计算设备400完成。同样,计算设备400B的功能也可以由多个计算设备400完成。It should be understood that the functions of the computing device 400A shown in FIG. 6 may also be performed by multiple computing devices 400 . Likewise, the functions of computing device 400B may also be performed by multiple computing devices 400 .
在一些可能的实现方式中,计算设备集群中的一个或多个计算设备可以通过网络连接。其中,所述网络可以是广域网或局域网等等。图7示出了一种可能的实现方式。如图7所示,两个计算设备400C和400D之间通过网络进行连接。具体地,通过各个计算设备中的通信接口与所述网络进行连接。在这一类可能的实现方式中,计算设备400C中的存储器406中存有执行通信单元302、存储单元304、记录单元308、决策单元312和淘汰单元314的指令。同时,计算设备400D中的存储器406中存有执行缓存单元306和训练单元310的指令。In some possible implementations, one or more computing devices in a cluster of computing devices may be connected by a network. Wherein, the network may be a wide area network or a local area network, or the like. Figure 7 shows one possible implementation. As shown in FIG. 7 , two computing devices 400C and 400D are connected through a network. Specifically, the network is connected through a communication interface in each computing device. In this type of possible implementation, the memory 406 in the computing device 400C stores instructions for executing the communication unit 302 , the storage unit 304 , the recording unit 308 , the decision unit 312 and the elimination unit 314 . Meanwhile, the memory 406 in the computing device 400D stores instructions for executing the cache unit 306 and the training unit 310 .
图7所示的计算设备集群之间的连接方式可以是考虑到本申请提供的缓存管理方法200需要对缓存单元306中的数据进行高速的写入或读取的操作,和执行大量的计算以训练预测模型,因此考虑将缓存单元306和训练单元310实现的功能交由计算设备400D执行。The connection mode between the computing device clusters shown in FIG. 7 may take into account that the cache management method 200 provided by the present application needs to perform high-speed write or read operations on the data in the cache unit 306, and perform a large number of calculations to To train the prediction model, it is therefore considered that the functions implemented by the caching unit 306 and the training unit 310 are performed by the computing device 400D.
应理解,图7中示出的计算设备400C的功能也可以由多个计算设备400完成。同样,计算设备400D的功能也可以由多个计算设备400完成。It should be understood that the functions of the computing device 400C shown in FIG. 7 may also be performed by multiple computing devices 400 . Likewise, the functions of computing device 400D may also be performed by multiple computing devices 400 .
本申请实施例还提供了一种计算机可读存储介质。所述计算机可读存储介质可以是计算设备能够存储的任何可用介质或者是包含一个或多个可用介质的数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘)等。该计算机可读存储介质包括指令,所述指令指示计算设备执行上述应用于缓存管理装置104用于执行缓存管理方法200。Embodiments of the present application also provide a computer-readable storage medium. The computer-readable storage medium may be any available medium that a computing device can store, or a data storage device such as a data center that contains one or more available media. The usable media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, DVDs), or semiconductor media (eg, solid state drives), and the like. The computer-readable storage medium includes instructions, the instructions instruct the computing device to execute the above-mentioned application to the cache management apparatus 104 for executing the cache management method 200 .
本申请实施例还提供了一种包含指令的计算机程序产品。所述计算机程序产品可以是包含指令的,能够运行在计算设备上或被储存在任何可用介质中的软件或程序产品。当所述计算机程序产品在至少一个计算机设备上运行时,使得至少一个计算机设备执行上述缓存管理方法200。Embodiments of the present application also provide a computer program product including instructions. The computer program product may be a software or program product containing instructions, capable of being executed on a computing device or stored in any available medium. When the computer program product runs on at least one computer device, the at least one computer device is caused to execute the above-mentioned cache management method 200 .
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的保护范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still be Modifications are made to the technical solutions described in the foregoing embodiments, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions depart from the protection scope of the technical solutions of the embodiments of the present invention.

Claims (19)

  1. 一种缓存管理方法,其特征在于,所述缓存管理方法用于缓存管理装置,所述方法包括:A cache management method, characterized in that the cache management method is used in a cache management device, and the method includes:
    接收第一数据写入请求,所述第一数据写入请求用于请求将硬盘中的第一数据写入缓存;receiving a first data write request, where the first data write request is used to request to write the first data in the hard disk into the cache;
    根据所述第一数据的相关参数,训练缓存写入预测模型;According to the relevant parameters of the first data, the training cache writes the prediction model;
    将所述第一数据写入所述缓存;writing the first data into the cache;
    接收第二数据写入请求,所述第二数据写入请求用于请求将所述硬盘中的第二数据写入所述缓存;receiving a second data write request, where the second data write request is used to request to write the second data in the hard disk into the cache;
    根据所述缓存写入预测模型,确定是否将所述第二数据写入所述缓存。According to the cache write prediction model, it is determined whether to write the second data into the cache.
  2. 如权利要求1所述的方法,其特征在于,所述第一数据写入请求和所述第二数据写入请求属于第一批数据写入请求,所述方法还包括:The method of claim 1, wherein the first data write request and the second data write request belong to a first batch of data write requests, the method further comprising:
    接收所述第一批数据写入请求;receiving the first batch of data write requests;
    根据采样规则,从所述第一批数据写入请求中确定所述第一数据写入请求和所述第二数据写入请求。According to a sampling rule, the first data write request and the second data write request are determined from the first batch of data write requests.
  3. 如权利要求2所述的方法,其特征在于,根据采样规则,从所述第一批数据写入请求中确定所述第一数据写入请求和所述第二数据写入请求,包括:The method of claim 2, wherein determining the first data write request and the second data write request from the first batch of data write requests according to a sampling rule, comprising:
    获取所述第一批数据写入请求中各数据写入请求携带的待写入数据的标识;Obtain the identifier of the data to be written carried by each data write request in the first batch of data write requests;
    确定所述第一批数据写入请求中各数据写入请求携带的待写入数据的标识的哈希值可以被采样值整除的为所述第一数据写入请求;It is determined that the hash value of the identifier of the data to be written carried by each data write request in the first batch of data write requests can be divisible by the sampling value to be the first data write request;
    确定所述第一批数据写入请求中各数据写入请求携带的待写入数据的标识的哈希值不可以被采样值整除的为所述第二数据写入请求。It is determined that the hash value of the identifier of the data to be written carried by each data write request in the first batch of data write requests cannot be divisible by the sampling value, which is the second data write request.
  4. 如权利要求1至3中任一所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1 to 3, wherein the method further comprises:
    接收第二批数据写入请求;Receive the second batch of data write requests;
    根据所述训练后的缓存写入预测模型,确定是否将所述第二批数据写入请求对应的待写入数据中至少一个数据写入所述缓存。According to the trained cache write prediction model, it is determined whether to write at least one data in the data to be written corresponding to the second batch of data write requests into the cache.
  5. 如权利要求1至4中任一所述的方法,其特征在于,所述根据所述第一数据的相关参数,训练缓存写入预测模型包括:The method according to any one of claims 1 to 4, wherein the training of the cache write prediction model according to the relevant parameters of the first data comprises:
    将所述缓存中数据平均大小、历史每周期总写入请求数、历史每周期总读取请求数、所述缓存中数据平均淘汰周期中至少一个,和所述第一数据的相关参数作为所述缓存写入预测模型的训练输入量;Take at least one of the average size of data in the cache, the total number of write requests per cycle in history, the total number of read requests per cycle in history, the average elimination cycle of data in the cache, and the relevant parameters of the first data. Describe the amount of training input that the cache writes to the prediction model;
    根据所述第一数据请求发生后一个所述平均淘汰周期内所述第一数据的请求情况和淘汰情况,确定所述第一数据的写入概率作为所述缓存写入预测模型的训练输出量:Determine the write probability of the first data as the training output of the cache write prediction model according to the request situation and the elimination situation of the first data in the average elimination period after the first data request occurs :
    根据所述训练输入量和所述训练输出量,训练缓存写入预测模型。According to the training input amount and the training output amount, the training cache is written to the prediction model.
  6. 如权利要求1至5中任一所述的方法,其特征在于,所述第一数据的相关参数包括下列至少一个:The method according to any one of claims 1 to 5, wherein the relevant parameters of the first data include at least one of the following:
    所述第一数据的历史被请求写入数、所述第一数据的历史被请求读取数。The number of historically requested writes of the first data and the number of historically requested reads of the first data.
  7. 如权利要求1至6中任一所述的方法,其特征在于,所述根据所述缓存写入预测模型,确定是否将所述第二数据写入所述缓存,包括:The method according to any one of claims 1 to 6, wherein the determining whether to write the second data into the cache according to the cache write prediction model comprises:
    获取写入阈值;Get the write threshold;
    根据所述缓存写入预测模型,获得所述第二数据的写入概率;obtaining a write probability of the second data according to the cache write prediction model;
    根据所述写入阈值和所述第二数据的写入概率,确定是否将所述第二数据的写入所述缓存。Whether to write the second data into the cache is determined according to the write threshold and the write probability of the second data.
  8. 如权利要求7中所述的方法,其特征在于,所述根据所述训练后的缓存写入预测模型,获得所述第二数据的写入概率包括:The method of claim 7, wherein the obtaining the write probability of the second data according to the trained cache write prediction model comprises:
    将所述缓存中数据平均大小、所述缓存中数据平均淘汰周期、历史每周期总写入请求数、历史每周期总读取请求数中的至少一个,和所述第二数据相关参数作为所述缓存写入预测模型的预测输入量;Take at least one of the average size of the data in the cache, the average elimination period of the data in the cache, the total number of write requests per cycle in history, the total number of read requests per cycle in history, and the second data-related parameters as all parameters. Describe the amount of prediction input that the cache writes to the prediction model;
    将所述预测输入量作为所述训练后的缓存写入预测模型的输入,获得所述第二数据的写入概率。The predicted input amount is used as the input of the trained cache write prediction model, and the write probability of the second data is obtained.
  9. 一种缓存管理装置,其特征在于,所述装置包括通信单元和处理单元:A cache management device, characterized in that the device includes a communication unit and a processing unit:
    所述通信单元,用于接收第一数据写入请求,所述第一数据写入请求用于请求将硬盘中的第一数据写入缓存;the communication unit, configured to receive a first data write request, where the first data write request is used to request to write the first data in the hard disk into the cache;
    所述处理单元,用于根据所述第一数据的相关参数,训练缓存写入预测模型;将所述第一数据写入所述缓存;the processing unit, configured to train a cache write prediction model according to the relevant parameters of the first data; write the first data into the cache;
    所述通信单元,还用于接收第二数据写入请求,所述第二数据写入请求用于请求将所述硬盘中的第二数据写入所述缓存;The communication unit is further configured to receive a second data write request, where the second data write request is used to request to write the second data in the hard disk into the cache;
    所述处理单元,还用于根据所述缓存写入预测模型,确定是否将所述第二数据写入所述缓存。The processing unit is further configured to determine whether to write the second data into the cache according to the cache write prediction model.
  10. 如权利要求9所述的装置,其特征在于,所述通信单元,用于接收第一批数据写入请求;所述处理单元,用于根据划分规则,从所述第一批数据写入请求中确定所述第一数据写入请求和所述第二数据写入请求。The apparatus according to claim 9, wherein the communication unit is configured to receive a first batch of data write requests; the processing unit is configured to write requests from the first batch of data according to a division rule The first data write request and the second data write request are determined in .
  11. 如权利要求10所述的装置,其特征在于,所述处理单元,用于获取所述第一批数据写入请求中各数据写入请求携带的待写入数据的标识;确定所述第一批数据写入请求中各数据写入请求携带的待写入数据的标识的哈希值可以被采样值整除的为所述第一数据写入请求;确定所述第一批数据写入请求中各数据写入请求携带的待写入数据的标识的哈希值不可以被采样值整除的为所述第二数据写入请求。The apparatus according to claim 10, wherein the processing unit is configured to obtain the identifier of the data to be written carried by each data write request in the first batch of data write requests; In the batch data write request, the hash value of the identifier of the data to be written carried by each data write request can be divisible by the sampling value is the first data write request; it is determined that the first batch of data write requests contains It is the second data write request that the hash value of the identifier of the data to be written carried by each data write request cannot be divisible by the sampling value.
  12. 如权利要求8至11中任一所述的装置,其特征在于,所述处理单元,用于接收第二批数据写入请求;根据所述训练后的缓存写入预测模型,确定是否将所述第二批数据写入请求对应的待写入数据中至少一个数据写入所述缓存。The apparatus according to any one of claims 8 to 11, wherein the processing unit is configured to receive a second batch of data write requests; and determine whether to write the data according to the trained cache write prediction model At least one data in the data to be written corresponding to the second batch of data write requests is written into the cache.
  13. 如权利要求8至12中任一所述的装置,其特征在于,所述处理单元,用于将所述缓存中数据平均大小、历史每周期总写入请求数、历史每周期总读取请求数、所述缓存中数据平均淘汰周期中至少一个,和所述第一数据的相关参数作为所述缓存写入预测模型的训练输入量;根据所述第一数据请求发生后一个所述平均淘汰周期内所述第一数据的请求情况和淘汰情况,确定所述第一数据的写入概率作为所述缓存写入预测模型的训练输出量:根据所述训练输入量和所述训练输出量,训练缓存写入预测模型。The apparatus according to any one of claims 8 to 12, wherein the processing unit is configured to compare the average size of data in the cache, the historical total number of write requests per cycle, and the historical total read requests per cycle number, at least one of the average elimination cycle of data in the cache, and the relevant parameters of the first data as the training input of the cache write prediction model; according to the first data request after the occurrence of the average elimination The request situation and elimination situation of the first data in the cycle, determine the write probability of the first data as the training output of the cache write prediction model: according to the training input and the training output, The training cache writes to the predictive model.
  14. 如权利要求8至13中任一所述的装置,其特征在于,所述第一数据的相关参 数包括下列至少一个:所述第一数据的历史被请求写入数、所述第一数据的历史被请求读取数。The apparatus according to any one of claims 8 to 13, wherein the relevant parameters of the first data include at least one of the following: the historical requested writing number of the first data, the The number of historical reads requested.
  15. 如权利要求8至14中任一所述的装置,其特征在于,所述通信单元,用于获取写入阈值;所述处理单元,用于根据所述缓存写入预测模型,获得所述第二数据的写入概率;根据所述写入阈值和所述第二数据的写入概率,确定是否将所述第二数据写入所述缓存。The apparatus according to any one of claims 8 to 14, wherein the communication unit is configured to obtain a write threshold; the processing unit is configured to obtain the first write threshold according to the cache write prediction model. Write probability of the second data; determine whether to write the second data into the cache according to the write threshold and the write probability of the second data.
  16. 如权利要求15所述的装置,其特征在于,所述处理单元,用于将所述缓存中数据平均大小、所述缓存中数据平均淘汰周期、历史每周期总写入请求数、历史每周期总读取请求数中的至少一个,和所述第二数据相关参数作为所述缓存写入预测模型的预测输入量;将所述预测输入量作为所述训练后的缓存写入预测模型的输入,获得所述第二数据的写入概率。The apparatus according to claim 15, wherein the processing unit is configured to calculate the average size of the data in the cache, the average elimination cycle of the data in the cache, the total number of historical write requests per cycle, and the historical per cycle At least one of the total number of read requests and the second data-related parameter are used as the predicted input of the cache write prediction model; the predicted input is used as the input of the trained cache write prediction model , to obtain the write probability of the second data.
  17. 一种计算设备集群,其特征在于,包括至少一个计算设备,每个计算设备包括处理器和存储器;A computing device cluster, comprising at least one computing device, each computing device including a processor and a memory;
    所述至少一个计算设备的处理器用于执行所述至少一个计算设备的存储器中存储的指令,以使得所述计算设备集群执行如权利要求1至8中任一所述的方法。The processor of the at least one computing device is adapted to execute instructions stored in the memory of the at least one computing device to cause the cluster of computing devices to perform the method of any one of claims 1-8.
  18. 一种包含指令的计算机程序产品,其特征在于,当所述指令被计算机设备集群运行时,使得所述计算机设备集群执行如权利要求的1至8中任一所述的方法。A computer program product comprising instructions, wherein the instructions, when executed by a cluster of computer devices, cause the cluster of computer devices to perform the method according to any one of claims 1 to 8.
  19. 一种计算机可读存储介质,其特征在于,包括计算机程序指令,当所述计算机程序指令由计算设备集群执行时,所述计算设备集群执行如权利要求1至8中任一所述的方法。A computer-readable storage medium, comprising computer program instructions, when the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 1 to 8.
PCT/CN2021/139427 2021-01-21 2021-12-18 Cache management method and apparatus, and device WO2022156452A1 (en)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN202110078600 2021-01-21
CN202110078600.X 2021-01-21
CN202110410912.6 2021-04-16
CN202110410912.6A CN114817319A (en) 2021-01-21 2021-04-16 Cache management method, device and equipment

Publications (1)

Publication Number Publication Date
WO2022156452A1 true WO2022156452A1 (en) 2022-07-28

Family

ID=82526439

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/139427 WO2022156452A1 (en) 2021-01-21 2021-12-18 Cache management method and apparatus, and device

Country Status (2)

Country Link
CN (1) CN114817319A (en)
WO (1) WO2022156452A1 (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105683930A (en) * 2013-10-29 2016-06-15 上海宝存信息科技有限公司 Dynamic caching method and system for data storage system
US20160239420A1 (en) * 2015-02-16 2016-08-18 Dell Products L.P. System and method for managing a cache pool
CN106708444A (en) * 2017-01-17 2017-05-24 北京联想核芯科技有限公司 Data storage method and hard disc controller
US20200133857A1 (en) * 2018-10-30 2020-04-30 EMC IP Holding Company LLC Increasing performance of write throughput using machine learning
CN111104066A (en) * 2019-12-17 2020-05-05 华中科技大学 Data writing method, data writing device, storage server and computer readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105683930A (en) * 2013-10-29 2016-06-15 上海宝存信息科技有限公司 Dynamic caching method and system for data storage system
US20160239420A1 (en) * 2015-02-16 2016-08-18 Dell Products L.P. System and method for managing a cache pool
CN106708444A (en) * 2017-01-17 2017-05-24 北京联想核芯科技有限公司 Data storage method and hard disc controller
US20200133857A1 (en) * 2018-10-30 2020-04-30 EMC IP Holding Company LLC Increasing performance of write throughput using machine learning
CN111104066A (en) * 2019-12-17 2020-05-05 华中科技大学 Data writing method, data writing device, storage server and computer readable storage medium

Also Published As

Publication number Publication date
CN114817319A (en) 2022-07-29

Similar Documents

Publication Publication Date Title
US8112585B2 (en) Method and apparatus for dynamically switching cache policies
US9122607B1 (en) Hotspot detection and caching for storage devices
US8943272B2 (en) Variable cache line size management
US7757045B2 (en) Synchronizing recency information in an inclusive cache hierarchy
US8601217B2 (en) Method and system for inserting cache blocks
US9779027B2 (en) Apparatus, system and method for managing a level-two cache of a storage appliance
EP3089039B1 (en) Cache management method and device
US20110276623A1 (en) File bundling for cache servers of content delivery networks
WO2011144175A1 (en) Data prefetching method, node and system for distributed hash table dht memory system
CN106528451B (en) The cloud storage frame and construction method prefetched for the L2 cache of small documents
US11030115B2 (en) Dataless cache entry
US11693570B2 (en) Machine learning to improve caching efficiency in a storage system
CN117235088B (en) Cache updating method, device, equipment, medium and platform of storage system
KR101940382B1 (en) Prefetching method and apparatus for pages
CN115080459A (en) Cache management method and device and computer readable storage medium
WO2023165543A1 (en) Shared cache management method and apparatus, and storage medium
WO2022156452A1 (en) Cache management method and apparatus, and device
Hendrantoro et al. Early result from adaptive combination of LRU, LFU and FIFO to improve cache server performance in telecommunication network
US9129033B1 (en) Caching efficiency using a metadata cache
CN112650694B (en) Data reading method and device, cache proxy server and storage medium
CN114461681A (en) Cache content management method and device, electronic equipment and storage medium
CN116069752A (en) Mixed prefetching method for distributed file system
KR101976320B1 (en) Last level cache memory and data management method thereof
CN112445794A (en) Caching method of big data system
WO2022213871A1 (en) Caching apparatus, method and system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21920826

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21920826

Country of ref document: EP

Kind code of ref document: A1