CN116069529A - Dynamic caching method and device, electronic equipment and computer readable medium - Google Patents

Dynamic caching method and device, electronic equipment and computer readable medium Download PDF

Info

Publication number
CN116069529A
CN116069529A CN202310253399.3A CN202310253399A CN116069529A CN 116069529 A CN116069529 A CN 116069529A CN 202310253399 A CN202310253399 A CN 202310253399A CN 116069529 A CN116069529 A CN 116069529A
Authority
CN
China
Prior art keywords
access
cache
stored
message queue
popularity
Prior art date
Legal status (The legal status 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 status listed.)
Granted
Application number
CN202310253399.3A
Other languages
Chinese (zh)
Other versions
CN116069529B (en
Inventor
吴文峰
黄鹄
林洁琬
颜文强
张维杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianyi Cloud Technology Co Ltd
Original Assignee
Tianyi Cloud Technology Co Ltd
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 Tianyi Cloud Technology Co Ltd filed Critical Tianyi Cloud Technology Co Ltd
Priority to CN202310253399.3A priority Critical patent/CN116069529B/en
Publication of CN116069529A publication Critical patent/CN116069529A/en
Application granted granted Critical
Publication of CN116069529B publication Critical patent/CN116069529B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Abstract

The embodiment of the invention provides a dynamic caching method, a dynamic caching device, electronic equipment and a computer readable medium. The method comprises the following steps: receiving an access request sent by a user; the access request is used for acquiring an object; determining whether the object is stored in a cache; if the object is not stored in the cache, storing access information corresponding to the object in a preset message queue; determining popularity of the object based on the access information in the message queue; acquiring the object size of the object; according to popularity of the object, the size of the object and preset access parameters, moving the object which is not stored in the cache to the cache; wherein the access parameters are dynamically adjusted with the variation of the load access mode. Therefore, the storage position of the object can be adjusted based on the size and popularity of the object, so that the whole access request can be more easily extracted from the cache to obtain the required object, and the performance of the object storage system is improved.

Description

Dynamic caching method and device, electronic equipment and computer readable medium
Technical Field
The present invention relates to the field of computer technology, and in particular, to a dynamic caching method, a dynamic caching apparatus, an electronic device, and a computer readable medium.
Background
In an object storage system, a cache replacement algorithm (e.g., LRU, LFU, SLRU, ARC, etc.) is more prone to cache hot objects, and cold objects are preferentially eliminated when cache replacement occurs, and these policies often do not relate to admission policies, and all accessed objects are cached. In a real application environment, there is a difference in size between request objects in addition to the difference in heat. If a large object is accessed at high heat, the current cache management algorithm adds the large object to the cache, which may result in more small objects being eliminated due to small RAM cache capacity and limitations. If these small objects need to be accessed again, the need to access the HDD storage nodes, and the large number of HDD random accesses generated at this time can reduce the overall bandwidth of the system, affecting the performance of the object storage system.
Disclosure of Invention
The embodiment of the invention provides a dynamic caching method, a dynamic caching device, electronic equipment and a computer readable storage medium, which are used for solving the problem of low performance of an object storage system.
The embodiment of the invention discloses a dynamic caching method, which comprises the following steps:
receiving an access request sent by a user; the access request is used for acquiring an object;
determining whether the object is stored in a cache;
if the object is not stored in the cache, storing access information corresponding to the object in a preset message queue;
determining popularity of the object based on the access information in the message queue;
acquiring the object size of the object;
according to popularity of the object, the size of the object and preset access parameters, moving the object which is not stored in the cache to the cache; wherein the access parameters are dynamically adjusted with the variation of the load access mode.
Optionally, the step of determining popularity of the object based on the access information in the message queue includes:
determining the access times of the object in a preset time window based on the access information in the message queue;
and taking the access times of the object in a preset time window as popularity of the object.
Optionally, the step of moving the object not stored in the cache into the cache according to the popularity of the object and the size of the object includes:
Acquiring access parameters;
determining a size parameter of the object according to the access parameter and the object size of the object;
and moving the objects which are not stored in the cache into the cache according to the popularity of the objects and the size parameter.
Optionally, the step of moving the object not stored in the cache to the cache according to the popularity and the size parameter includes:
comparing the popularity of the object to the size parameter;
and if the popularity is larger than the size parameter, moving the objects which are not stored in the cache into the cache.
Optionally, the method further comprises:
recording the access request;
determining at least one access parameter;
based on the access parameters, respectively generating storage simulation information corresponding to the access parameters; the storage simulation information is used for recording a simulation storage position of at least one object;
replaying the access request;
determining a cache hit rate in the case of replaying the access request based on the storage simulation information;
and determining a target access parameter from the access parameters according to the cache hit rate.
Optionally, if the object is not stored in the cache, the step of storing the access information corresponding to the object in a message queue includes:
if the object is not stored in the cache, determining whether the object has access information of the object in the message queue;
if the object has access information in the message queue, updating the access information;
if the object does not have the access information in the message queue, the access information of the object is created in the message queue.
Optionally, the access information is used for recording the access times;
the step of updating the access information if the object has access information in the message queue includes:
if the object has access times information in the message queue, updating the access information to increase the access times.
Optionally, the method further comprises:
if new access information of the object is created in the message queue and the number of the access information of the object stored in the message queue is larger than the preset number, the access information stored in the history is deleted from early to late according to the creation sequence.
Optionally, the method further comprises:
and deleting the access information corresponding to the object in the message queue after the object moves to the cache.
Optionally, the step of recording the access request includes:
mapping the object name of the object corresponding to the access request into a 64-bit identifier aiming at the access request, and converting the object size into a 64-bit unsigned integer;
generating a 16-byte tuple based on the object name of the 64-bit identification and the object size of the 64-bit unsigned integer;
the access request is recorded using a 16 byte tuple.
The embodiment of the invention also discloses a dynamic caching device, which comprises:
the request receiving module is used for receiving an access request sent by a user; the access request is used for acquiring an object;
the cache determining module is used for determining whether the object is stored in a cache;
the queue storage module is used for storing the access information corresponding to the object in a preset message queue if the object is not stored in the cache;
a popularity determination module for determining popularity of the object based on access information in the message queue;
the size acquisition module is used for acquiring the object size of the object;
The object moving module is used for moving the object which is not stored in the cache into the cache according to the popularity of the object, the size of the object and preset access parameters; wherein the access parameters are dynamically adjusted with the variation of the load access mode.
Optionally, the popularity determination module includes:
the access frequency determining submodule is used for determining the access frequency of the object in a preset time window based on the access information in the message queue;
and the popularity determination submodule is used for taking the access times of the object in a preset time window as the popularity of the object.
Optionally, the object moving module includes:
the access times acquisition sub-module is used for acquiring access parameters;
a size parameter determining sub-module, configured to determine a size parameter of the object according to the access parameter and an object size of the object;
and the object moving submodule is used for moving the objects which are not stored in the cache into the cache according to the popularity and the size parameter of the objects.
Optionally, the object movement submodule includes:
a comparison unit for comparing the popularity of the object and the size parameter;
And the object moving unit is used for moving the objects which are not stored in the cache into the cache under the condition that the popularity is larger than the size parameter.
Optionally, the apparatus further comprises:
the request recording module is used for recording the access request;
an access parameter determination module for determining at least one access parameter;
the simulation module is used for respectively generating storage simulation information corresponding to the access parameters based on the access parameters; the storage simulation information is used for recording a simulation storage position of at least one object;
a replay module for replaying the access request;
a hit rate calculation module for determining a cache hit rate in the case of replaying the access request based on the storage simulation information;
and the target access parameter determining module is used for determining target access parameters in the access parameters according to the cache hit rate.
Optionally, the queue storage module includes:
a queue determining submodule, configured to determine whether access information of the object exists in the message queue if the object is not stored in the cache;
an updating sub-module, configured to update the access information if the object already has the access information in the message queue;
And the creation sub-module is used for creating the access information of the object in the message queue if the object does not have the access information in the message queue.
Optionally, the access information is used for recording the access times;
the update sub-module includes:
and the updating unit is used for updating the access information to increase the access times if the object has the access times information in the message queue.
Optionally, the apparatus further comprises:
and the historical access information deleting module is used for deleting the historical stored access information from early to late according to the creation sequence if the new access information of the object is created in the message queue and the number of the access information of the object stored in the message queue is larger than the preset number.
Optionally, the apparatus further comprises:
and the access information deleting module is used for deleting the access information corresponding to the object in the message queue after the object moves to the cache.
Optionally, the request recording module includes:
the information conversion sub-module is used for mapping the object name of the object corresponding to the access request into a 64-bit identifier aiming at the access request, and converting the size of the object into a 64-bit unsigned integer;
A generation sub-module for generating a 16-byte tuple based on the object name of the 64-bit identification and the object size of the 64-bit unsigned integer;
and the request recording sub-module is used for recording the access request by adopting the 16-byte tuple.
The embodiment of the invention also discloses electronic equipment, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
the memory is used for storing a computer program;
the processor is configured to implement the method according to the embodiment of the present invention when executing the program stored in the memory.
Embodiments of the invention also disclose one or more computer-readable media having instructions stored thereon, which when executed by one or more processors, cause the processors to perform the methods described in the embodiments of the invention.
The embodiment of the invention has the following advantages:
by the dynamic caching method provided by the embodiment of the invention, the access request sent by the user is received; the access request is used for acquiring an object; determining whether the object is stored in a cache; if the object is not stored in the cache, storing access information corresponding to the object in a preset message queue; determining popularity of the object based on the access information in the message queue; acquiring the object size of the object; according to popularity of the object, the size of the object and preset access parameters, moving the object which is not stored in the cache to the cache; wherein the access parameters are dynamically adjusted with the variation of the load access mode. Therefore, the storage position of the object can be adjusted based on the size and popularity of the object, so that the whole access request can be more easily extracted from the cache to obtain the required object, and the performance of the object storage system is improved. Meanwhile, the access parameters are dynamically adjusted according to the change of the load access mode, so that whether an object moves to the cache can be changed according to the change of the load access mode, the dynamic cache method can adapt to different load access modes, and good cache hit rate can be obtained under different access preferences of users.
Drawings
FIG. 1 is a flow chart of steps of a dynamic caching method provided in an embodiment of the present invention;
FIG. 2 is a flowchart illustrating steps of a dynamic caching method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an object storage system according to an embodiment of the present invention
FIG. 4 is a block diagram of a dynamic caching device according to an embodiment of the present invention;
FIG. 5 is a block diagram of an electronic device provided in an embodiment of the invention;
fig. 6 is a schematic diagram of a computer readable medium provided in an embodiment of the invention.
Detailed Description
In order that the above-recited objects, features and advantages of the present invention will become more readily apparent, a more particular description of the invention will be rendered by reference to the appended drawings and appended detailed description.
Referring to fig. 1, a step flowchart of a dynamic caching method provided in an embodiment of the present invention may specifically include the following steps:
step 101, receiving an access request sent by a user; the access request is used for acquiring an object;
in the event that a user needs to extract an object from the object storage system, the user may send an access request to the object storage system. The access request may be used to request that an object be retrieved from the object storage system, which may be documented with object-related information such as object name, etc., in order for the object storage system to determine the object it is to extract.
Step 102, determining whether the object is stored in a cache;
a low-speed storage medium and a cache may be included in the object storage system, and the object may be stored in the low-speed storage medium or cache, whereby the storage location of the object needs to be determined to determine where to extract the object from. In particular implementations, a doubly cached linked list may be maintained in the object storage system. The information of the object stored in the cache may be recorded in the bidirectional cache linked list. Therefore, the object storage system can determine whether the object corresponding to the access request is stored in the cache by searching whether the information of the object is recorded in the bidirectional cache linked list.
Step 103, if the object is not stored in the cache, storing the access information corresponding to the object in a preset message queue;
if the object is not stored in the cache, the object needs to be extracted from a preset low-speed storage medium at this time, so that in order to facilitate the subsequent improvement of the access efficiency of the object, at this time, the access information corresponding to the object may be stored in a preset message queue, so as to know whether the object is frequently accessed in a period of time based on the message queue. The message queue may be used to document access information corresponding to the object. Such as the number of times an object is accessed over a period of time.
Step 104, determining popularity of the object based on the access information in the message queue;
in general, frequently accessed objects may be more prone to be stored in a cache for quick retrieval by a user. While less accessed objects may be more prone to storing in a low-speed storage medium, avoiding smaller capacity caches from being occupied. Thus, when evaluating whether an object that is not stored in the cache needs to be moved to the cache, popularity of the object may be determined to determine whether the object is frequently accessed.
Step 105, obtaining the object size of the object;
in the embodiment of the invention, after the object with larger object size moves to the cache, more objects with smaller object size may move to the low-speed storage medium, so that the hit rate of the cache is low. Thus, the object size of the object may be further considered when evaluating whether an object that is not stored in the cache needs to be moved to the cache. Thus, the object size of the object may be obtained from the object storage system for subsequent evaluation.
Step 106, moving the object which is not stored in the cache to the cache according to the popularity of the object, the size of the object and the preset access parameter; wherein the access parameters are dynamically adjusted with the variation of the load access mode.
Based on the popularity of the object, it can be known whether the object is frequently accessed. Thereafter, it may be determined whether the object needs to be moved to the cache with integrated consideration of popularity of the object, size of the object, and preset access parameters. In general, for smaller and higher-frequency-of-access objects, priority may be given to storing in the cache, while for larger and higher-frequency-of-access objects, whether storage in the cache is needed or not may be comprehensively considered based on the access parameters, considering whether the overall cache hit rate is significantly reduced. While larger and less frequently accessed objects may remain stored in the low-speed storage medium.
In particular, the user's access preferences may be different at different dates and for different periods of time. For example, a user may prefer to watch a video on weekend evenings, so that the object system may more easily receive access to large objects such as videos on weekend evenings. The user may prefer to find office documents in the morning of work so that the object system may more easily receive access to small objects such as documents in the morning of work.
Thus, the object storage system may have different load access patterns. The load access patterns may include at least a large object preference pattern and a small object preference pattern. Users in the large object preference mode tend to access large objects and users in the small object preference mode tend to access small objects.
In particular implementations, the load access pattern may be determined based on access requests received over a historical period of time. The object storage system may record a certain period of time specified by the history, such as the last 1 hour, the last 2 hours, the last 4 hours, etc., to receive the access request, and determine the current load access mode according to the object size ratio of the access request to the object. For example, from among the access requests received over a period of time in history, the access requests for the small object account for more than 60% of the overall access requests, then the current load access pattern may be determined to be the small object preference pattern. Among the access requests received over the history period, the access requests for the large object account for more than 50% of the overall access requests, and then the current load access mode can be determined to be the large object preference mode.
In the embodiment of the invention, the access requests received in a period of time for updating the history can be continuously acquired, and the load access mode can be dynamically adjusted according to the access requests for updating, so that whether the object can be moved to the cache can be accurately determined later, and the object cache system can be well adapted to the requirements of users in different periods and different environments.
In different load access modes, in order to ensure that the overall cache hit rate of the object storage system is higher, in the process of determining whether the object moves to the cache, the evaluation result can be dynamically adjusted according to the variation of the load access mode. For example, for a large object, if the large object is currently in the large object preference mode, the access parameters may be adjusted at this time, so that the large object may be more easily moved from the low-speed storage medium to the cache. If the current mode is in the small object preference mode, the access parameters can be adjusted at the moment, so that the large object is difficult to move to the cache, and the situation that a large amount of small object storage space is occupied due to the fact that the large object moves to the cache is reduced in the small object preference mode.
By the dynamic caching method provided by the embodiment of the invention, the access request sent by the user is received; the access request is used for acquiring an object; determining whether the object is stored in a cache; if the object is not stored in the cache, storing access information corresponding to the object in a preset message queue; determining popularity of the object based on the access information in the message queue; acquiring the object size of the object; according to popularity of the object, the size of the object and preset access parameters, moving the object which is not stored in the cache to the cache; wherein the access parameters are dynamically adjusted with the variation of the load access mode. Therefore, the storage position of the object can be adjusted based on the size and popularity of the object, so that the whole access request can be more easily extracted from the cache to obtain the required object, and the performance of the object storage system is improved. Meanwhile, the access parameters are dynamically adjusted according to the change of the load access mode, so that whether an object moves to the cache can be changed according to the change of the load access mode, the dynamic cache method can adapt to different load access modes, and good cache hit rate can be obtained under different access preferences of users.
Referring to fig. 2, a flowchart illustrating steps of a dynamic caching method provided in an embodiment of the present invention may specifically include the following steps:
step 201, receiving an access request sent by a user; the access request records the information of the object;
in the event that a user needs to extract an object from the object storage system, the user may send an access request to the object storage system. The access request may be used to request that an object be retrieved from the object storage system, which may be documented with object-related information such as object name, etc., in order for the object storage system to determine the object it is to extract.
Step 202, determining whether the object is stored in a cache;
the object storage system may include a low-speed storage medium and a cache, and the object may be stored in the low-speed storage medium or the cache. The object storage system can determine whether the object corresponding to the access request is stored in the cache by searching whether the information of the object is recorded in the bidirectional cache linked list.
Step 203, if the object is not stored in the cache, determining whether the object has access information in the message queue;
in the case that the object is not stored in the cache, the access information of the object that is not extracted from the cache may be recorded through the message queue at this time. Generally, each object in the message queue corresponds to an access information, and if the access information already exists in the message queue, the access information can be updated at this time without adding new information in the message queue. Thus, it is necessary to first determine whether or not the object already has access information in the message queue to determine access information that needs to be updated or information created.
Step 204, if the object has access information in the message queue, updating the access information;
if the object has access information in the message queue, the existing access information can be directly updated without creating new access information, so that the related information of the object accessed by the user in a period of time can be obtained by recording the access information in the message queue.
In one embodiment of the present invention, the step of updating the access information if the object already has access information in the message queue includes:
s11, if the object has access information in the message queue, updating the access information to increase the access times.
In a specific implementation, the access information may be used to record the number of accesses to the object. The message queue can be used for recording access information in a time window, so that the access times of the object in the time window can be known through the message queue, and the access frequency of the object in a period of time can be known. If the object has access information in the message queue, the access information can be updated for the access request at this time, and the number of access times is increased to record the access request. For example, after receiving an access request for an object, if the object is not stored in the cache, the access information corresponding to the object may be updated in the message queue, so that the number of accesses to the access information record is increased by 1.
Step 205, if the object does not have access information in the message queue, creating access information of the object in the message queue;
if the object does not have access information in the message queue, the object may be considered to be accessed for the first time and not stored in the message queue. Then in order to record the access to the object in the message queue, access information for the object may be created in the message queue and the access count may be recorded as 1.
In one embodiment of the invention, the method further comprises:
s21, if the access information of the object stored in the message queue is larger than the preset quantity, if new access information of the object is created in the message queue, the access information stored in the history is deleted from early to late according to the creation sequence.
In a specific implementation, a storage upper limit may exist in the message queue, where access information corresponding to a preset number of objects may be stored. For example, the message queue may store access information corresponding to 10 objects, access information corresponding to 100 objects, access information corresponding to 1000 objects, and the like, which is not limited in the present invention.
If the access information of the object stored in the message queue is greater than the preset number, the access information stored in the message queue in history may be deleted from early to late according to the creation order by using a first-in first-out rule at this time if new access information of the object needs to be created in the message queue at this time. For example, in the case where access information of a new object needs to be created, access information of the first object in the message queue, that is, access information of the earliest creation time, may be deleted preferentially. So that access information of the most recently accessed object can be stored in the message queue with priority. Therefore, the access information of the object in the latest time window can be stored by controlling the message queue to store the preset number of access information and deleting the access information stored in the history by adopting the first-in first-out rule, so that the access frequency of the object in the latest time window can be known through the message queue.
Step 206, determining popularity of the object based on the access information in the message queue; dynamic adjustment of popularity with load access patterns
In one embodiment of the present invention, the step of determining popularity of the object based on the access information in the message queue includes:
S31, determining the access times of the object in a preset time window based on the access information in the message queue;
s32, taking the access times of the object in a preset time window as the popularity of the object.
Specifically, the object is frequently accessed in the preset time window, and the object is considered popular, while the object is less frequently accessed in the preset time window, and the object is considered unpopular. The access information in the message queue records the access times of the object in a preset time window. Thus, the access times of the object in the preset time window can be used as the popularity of the object, and the access times are used for evaluating whether the object is popular.
Step 207, obtaining the object size of the object;
in the embodiment of the invention, after the object with larger object size moves to the cache, more objects with smaller object size may move to the low-speed storage medium, so that the hit rate of the cache is low. Thus, the object size of the object may be further considered when evaluating whether an object that is not stored in the cache needs to be moved to the cache. Thus, the object size of the object may be obtained from the object storage system for subsequent evaluation.
Step 208, moving the object not stored in the cache to the cache according to the popularity of the object, the size of the object and the preset access parameter; wherein the access parameters are dynamically adjusted with the variation of the load access mode.
Based on the popularity of the object, it can be known whether the object is frequently accessed. Thereafter, it may be determined whether the object needs to be moved to the cache with a comprehensive consideration of the size and popularity of the object. In general, for smaller and higher-frequency-of-access objects, priority may be given to storing in the cache, while for larger and higher-frequency-of-access objects, whether storage in the cache is required may be comprehensively considered in consideration of whether the overall cache hit rate is significantly reduced. While larger and less frequently accessed objects may remain stored in the low-speed storage medium.
In one embodiment of the present invention, the step of moving the object not stored in the cache to the cache according to popularity of the object and object size includes:
s41, acquiring access parameters;
specifically, to evaluate whether an object can be moved into the cache, an access parameter may be set. By adjusting the access parameters, the rules of the access cache of the object can be adjusted so as to meet the storage mode of the cache under different load access modes, and better access experience is provided for users.
S42, determining a size parameter of the object according to the access parameter and the object size of the object;
based on the access parameters and the object size of the object, size parameters for the object may be calculated. The size parameter of the object may be used to evaluate how hard the object is to move to the cache. If the size parameter of the object is larger, the difficulty of moving the object to the cache is higher. If the size parameter of the object pair is smaller, the object is easier to move to the cache. The size parameters of the object can be adjusted by adjusting the access parameters, so that the object is easier or more difficult to move to the cache. In a specific implementation, the size parameter may be an object size/access parameter.
And S43, moving the objects which are not stored in the cache into the cache according to the popularity and the size parameter of the objects.
Specifically, whether an object that is not stored in the cache can be moved to the cache may be comprehensively evaluated according to the popularity of the object and the size parameter. In case the size parameter is large, the object is required to have a high popularity at this time, so that it can be moved to the cache, whereas in case the size parameter is small, the object can have a low popularity, i.e. can be moved to the cache.
In one embodiment of the present invention, the step of moving the object not stored in the cache to the cache according to the popularity and the size parameter includes:
s51, comparing the popularity of the object with the size parameter;
and S52, moving the object which is not stored in the cache to the cache under the condition that the popularity is larger than the size parameter.
In particular, popularity of objects may be compared to size parameters, and a determination may be made as to whether the popularity is greater than the size parameters. In the case where the popularity is greater than the size parameter, i.e., the popularity K > the object size/access parameter n, then the object may be considered to have enough value to move to the cache, which may facilitate the user to more efficiently access the object, and then the object not stored in the cache may be moved to the cache. In the case where the popularity is not larger than the size parameter, i.e., the popularity K is smaller than the object size/access parameter n, the object may not be considered to have a value to be moved to the cache sufficiently at this time, and the object may be kept on the low-speed storage medium.
In a specific implementation, if the current load access mode is a large object preference mode, a larger access parameter may be set at this time, so that the popularity K is more easily larger than the object size/access parameter n, and the large object is more easily moved into the cache. If the current load access mode is the small object preference mode, a smaller access parameter can be set at this time, so that the popularity K is more difficult to be larger than the object size/access parameter n, and the large object is more difficult to be moved into the cache.
In one embodiment of the present invention, the method further comprises:
s61, recording the access request;
in the embodiment of the invention, the access habits of the users can be different under different time periods. For example, the fewer number of access requests available during the day, the more likely a user will have to access a large object. And a larger number of requests can be accessed on the network, the user is more inclined to access the small object. In order to adapt to different habits of users, the load access mode can be periodically redetermined based on the access request and the access parameters can be updated, and the load access mode and the access parameters can be dynamically adjusted so as to obtain better cache hit rate under different conditions. Thus, all access requests generated over a period of time may be recorded periodically to determine the appropriate access parameters based on the access requests.
Specifically, in order to save storage space, for an access request, mapping an object name of an object corresponding to the access request into a 64-bit identification id, and converting the object size into a 64-bit unsigned integer; generating a 16-byte tuple < id, size > based on the object name of the 64-bit identification and the object size of the 64-bit unsigned integer; the access request is recorded with a 16 byte tuple < id, size >.
S62, determining at least one access parameter;
in particular implementations, it may be determined based on the access parameters that those objects need to be moved into the cache. The access parameter may be associated with the existence of an object size. One or more access parameters may be set.
S63, playing back the access request for each access parameter;
in a specific implementation, the access request may be replayed separately for different access parameters, simulating how the object moves in the case of different access parameters.
S64, determining a cache hit rate in the case of replaying the access request based on the storage simulation information;
during replay of access requests, cache hit rates may be counted. Specifically, if the object corresponding to the access request can be found in the cache, it can be considered that the object is hit in the cache at this time, and thus, the cache hit rate corresponding to the access request can be determined according to the number of hits of the object corresponding to the access request in the cache and the number of overall access requests.
S65, determining target access parameters in the access parameters according to the cache hit rate.
Then, an access parameter having the highest cache hit rate may be determined from among the access parameters according to the cache hit rate, and the access parameter may be used as a target access parameter.
In one embodiment of the invention, the method further comprises:
and S71, deleting the access information corresponding to the object in the message queue after the storage position of the object is moved from the preset low-speed storage medium to the cache.
After the storage position of the object is moved from the preset low-speed storage medium to the cache, the access information of the object in the message queue is mainly used for storing the access information of the object which is not in the cache. Thus, the access information corresponding to the object in the message queue can be deleted, and the subsequent determination of whether the object needs to be moved into the cache can be omitted.
As a specific example of the present invention, fig. 3 is a schematic architecture diagram of an object storage system according to an embodiment of the present invention. The object storage system may include a cache module 301 and a back-end low-speed storage medium 302, among other things. The cache module 301 may include an object admission filter 3011, an object replay simulator 3012, and a request recorder 3013.
The object admission filter 3011 is configured to determine, when an access request is received, whether information of an object corresponding to the access request is stored in the bidirectional buffer chain table based on a preset bidirectional buffer chain table. If the information of the object corresponding to the access request is stored in the double-way cache linked list, the object can be extracted from the cache, and if the information of the object corresponding to the access request is not stored in the double-way cache linked list, the object can be extracted from the back-end low-speed storage medium. At the same time, the access request may be sent to the object replay simulator so that it records all access requests over a period of time.
The request recorder 3012 may maintain a message queue that may record access information that the object did not extract from the cache. The message queue can be used for recording access information in a time window, so that the access times of the object in the time window can be known through the message queue, and the access frequency of the object in a period of time can be known.
The object replay simulator 3013 may record all access requests over a period of time to replay the access requests to simulate based on access over a period of time, determining target cache parameters from among several cache parameters.
It should be noted that, for simplicity of description, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred embodiments, and that the acts are not necessarily required by the embodiments of the invention.
Referring to fig. 4, a block diagram of a dynamic buffer device provided in an embodiment of the present invention is shown, which may specifically include the following modules:
A request receiving module 401, configured to receive an access request sent by a user; the access request is used for acquiring an object;
a cache determination module 402, configured to determine whether the object is stored in a cache;
a queue storage module 403, configured to store, if the object is not stored in the cache, access information corresponding to the object in a preset message queue;
a popularity determination module 404 for determining popularity of the object based on access information in the message queue;
a size obtaining module 405, configured to obtain an object size of the object;
an object moving module 406, configured to move the object that is not stored in the cache to the cache according to popularity of the object, size of the object, and a preset access parameter; wherein the access parameters are dynamically adjusted with the variation of the load access mode.
Optionally, the popularity determination module includes:
the access frequency determining submodule is used for determining the access frequency of the object in a preset time window based on the access information in the message queue;
and the popularity determination submodule is used for taking the access times of the object in a preset time window as the popularity of the object.
Optionally, the object moving module includes:
the access times acquisition sub-module is used for acquiring access parameters;
a size parameter determining sub-module, configured to determine a size parameter of the object according to the access parameter and an object size of the object;
and the object moving submodule is used for moving the objects which are not stored in the cache into the cache according to the popularity and the size parameter of the objects.
Optionally, the object movement submodule includes:
a comparison unit for comparing the popularity of the object and the size parameter;
and the object moving unit is used for moving the objects which are not stored in the cache into the cache under the condition that the popularity is larger than the size parameter.
Optionally, the apparatus further comprises:
the request recording module is used for recording the access request;
an access parameter determination module for determining at least one access parameter;
the simulation module is used for respectively generating storage simulation information corresponding to the access parameters based on the access parameters; the storage simulation information is used for recording a simulation storage position of at least one object;
A replay module for replaying the access request;
a hit rate calculation module for determining a cache hit rate in the case of replaying the access request based on the storage simulation information;
and the target access parameter determining module is used for determining target access parameters in the access parameters according to the cache hit rate.
Optionally, the queue storage module includes:
a queue determining submodule, configured to determine whether access information of the object exists in the message queue if the object is not stored in the cache;
an updating sub-module, configured to update the access information if the object already has the access information in the message queue;
and the creation sub-module is used for creating the access information of the object in the message queue if the object does not have the access information in the message queue.
Optionally, the access information is used for recording the access times;
the update sub-module includes:
and the updating unit is used for updating the access information to increase the access times if the object has the access times information in the message queue.
Optionally, the apparatus further comprises:
And the historical access information deleting module is used for deleting the historical stored access information from early to late according to the creation sequence if the new access information of the object is created in the message queue and the number of the access information of the object stored in the message queue is larger than the preset number.
Optionally, the apparatus further comprises:
and the access information deleting module is used for deleting the access information corresponding to the object in the message queue after the object moves to the cache.
Optionally, the request recording module includes:
the information conversion sub-module is used for mapping the object name of the object corresponding to the access request into a 64-bit identifier aiming at the access request, and converting the size of the object into a 64-bit unsigned integer;
a generation sub-module for generating a 16-byte tuple based on the object name of the 64-bit identification and the object size of the 64-bit unsigned integer;
and the request recording sub-module is used for recording the access request by adopting the 16-byte tuple.
For the device embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and reference is made to the description of the method embodiments for relevant points.
In addition, the embodiment of the invention also provides an electronic device, as shown in fig. 5, which comprises a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502 and the memory 503 complete communication with each other through the communication bus 504,
a memory 503 for storing a computer program;
the processor 501 is configured to execute the program stored in the memory 503, and implement the following steps:
receiving an access request sent by a user; the access request is used for acquiring an object;
determining whether the object is stored in a cache;
if the object is not stored in the cache, storing access information corresponding to the object in a preset message queue;
determining popularity of the object based on the access information in the message queue;
acquiring the object size of the object;
according to popularity of the object, the size of the object and preset access parameters, moving the object which is not stored in the cache to the cache; wherein the access parameters are dynamically adjusted with the variation of the load access mode.
Optionally, the step of determining popularity of the object based on the access information in the message queue includes:
Determining the access times of the object in a preset time window based on the access information in the message queue;
and taking the access times of the object in a preset time window as popularity of the object.
Optionally, the step of moving the object not stored in the cache into the cache according to the popularity of the object and the size of the object includes:
acquiring access parameters;
determining a size parameter of the object according to the access parameter and the object size of the object;
and moving the objects which are not stored in the cache into the cache according to the popularity of the objects and the size parameter.
Optionally, the step of moving the object not stored in the cache to the cache according to the popularity and the size parameter includes:
comparing the popularity of the object to the size parameter;
and if the popularity is larger than the size parameter, moving the objects which are not stored in the cache into the cache.
Optionally, the method further comprises:
recording the access request;
determining at least one access parameter;
Based on the access parameters, respectively generating storage simulation information corresponding to the access parameters; the storage simulation information is used for recording a simulation storage position of at least one object;
replaying the access request;
determining a cache hit rate in the case of replaying the access request based on the storage simulation information;
and determining a target access parameter from the access parameters according to the cache hit rate.
Optionally, if the object is not stored in the cache, the step of storing the access information corresponding to the object in a message queue includes:
if the object is not stored in the cache, determining whether the object has access information of the object in the message queue;
if the object has access information in the message queue, updating the access information;
if the object does not have the access information in the message queue, the access information of the object is created in the message queue.
Optionally, the access information is used for recording the access times;
the step of updating the access information if the object has access information in the message queue includes:
If the object has access times information in the message queue, updating the access information to increase the access times.
Optionally, the method further comprises:
if new access information of the object is created in the message queue and the number of the access information of the object stored in the message queue is larger than the preset number, the access information stored in the history is deleted from early to late according to the creation sequence.
Optionally, the method further comprises:
and deleting the access information corresponding to the object in the message queue after the object moves to the cache.
Optionally, the step of recording the access request includes:
mapping the object name of the object corresponding to the access request into a 64-bit identifier aiming at the access request, and converting the object size into a 64-bit unsigned integer;
generating a 16-byte tuple based on the object name of the 64-bit identification and the object size of the 64-bit unsigned integer;
the access request is recorded using a 16 byte tuple.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (Peripheral Component Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include random access memory (Random Access Memory, RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU for short), a network processor (Network Processor, NP for short), etc.; but also digital signal processors (Digital Signal Processing, DSP for short), application specific integrated circuits (Application Specific Integrated Circuit, ASIC for short), field-programmable gate arrays (Field-Programmable Gate Array, FPGA for short) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment provided by the present invention, as shown in fig. 6, there is further provided a computer readable storage medium 601 having instructions stored therein, which when run on a computer, cause the computer to perform the dynamic caching method described in the above embodiment.
In yet another embodiment of the present invention, a computer program product containing instructions that, when run on a computer, cause the computer to perform the dynamic caching method described in the above embodiment is also provided.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (15)

1. A method of dynamic caching, the method comprising:
receiving an access request sent by a user; the access request is used for acquiring an object;
determining whether the object is stored in a cache;
if the object is not stored in the cache, storing access information corresponding to the object in a preset message queue;
determining popularity of the object based on the access information in the message queue;
acquiring the object size of the object;
according to popularity of the object, the size of the object and preset access parameters, moving the object which is not stored in the cache to the cache; wherein the access parameters are dynamically adjusted with the variation of the load access mode.
2. The method of claim 1, wherein the step of determining popularity of the object based on the access information in the message queue comprises:
Determining the access times of the object in a preset time window based on the access information in the message queue;
and taking the access times of the object in a preset time window as popularity of the object.
3. The method according to claim 1, wherein the step of moving the object not stored in the cache into the cache according to popularity of the object, object size, and a preset access parameter, comprises:
acquiring access parameters;
determining a size parameter of the object according to the access parameter and the object size of the object;
and moving the objects which are not stored in the cache into the cache according to the popularity of the objects and the size parameter.
4. The method of claim 3, wherein the step of moving objects not stored in the cache into the cache according to the popularity and the size parameter comprises:
comparing the popularity of the object to the size parameter;
and if the popularity is larger than the size parameter, moving the objects which are not stored in the cache into the cache.
5. A method according to claim 1 or 3, characterized in that the method further comprises:
recording the access request;
determining at least one access parameter;
for each access parameter, respectively replaying the access request;
determining a cache hit rate in the case of replaying the access request based on the stored simulation information;
and determining a target access parameter from the access parameters according to the cache hit rate.
6. The method of claim 1, wherein the step of storing the access information corresponding to the object in the message queue if the object is not stored in the cache comprises:
if the object is not stored in the cache, determining whether the object has access information of the object in the message queue;
if the object has access information in the message queue, updating the access information;
if the object does not have the access information in the message queue, the access information of the object is created in the message queue.
7. The method of claim 6, wherein the access information is used to record the number of accesses;
The step of updating the access information if the object has access information in the message queue includes:
if the object has access times information in the message queue, updating the access information to increase the access times.
8. The method of claim 6, wherein the method further comprises:
if new access information of the object is created in the message queue and the number of the access information of the object stored in the message queue is larger than the preset number, the access information stored in the history is deleted from early to late according to the creation sequence.
9. The method of claim 6, wherein the method further comprises:
and deleting the access information corresponding to the object in the message queue after the object moves to the cache.
10. The method of claim 5, wherein the step of recording the access request comprises:
mapping the object name of the object corresponding to the access request into a 64-bit identifier aiming at the access request, and converting the object size into a 64-bit unsigned integer;
generating a 16-byte tuple based on the object name of the 64-bit identification and the object size of the 64-bit unsigned integer;
The access request is recorded using a 16 byte tuple.
11. A dynamic caching apparatus, the apparatus comprising:
the request receiving module is used for receiving an access request sent by a user; the access request is used for acquiring an object;
the cache determining module is used for determining whether the object is stored in a cache;
the queue storage module is used for storing the access information corresponding to the object in a preset message queue if the object is not stored in the cache;
a popularity determining module, configured to determine popularity of the object based on the access information in the message queue;
the size acquisition module is used for acquiring the object size of the object;
the object moving module is used for moving the object which is not stored in the cache into the cache according to the popularity of the object, the size of the object and preset access parameters; wherein the access parameters are dynamically adjusted with the variation of the load access mode.
12. The apparatus of claim 11, wherein the popularity determination module comprises:
the access frequency determining submodule is used for determining the access frequency of the object in a preset time window based on the access information in the message queue;
And the popularity determination submodule is used for taking the access times of the object in a preset time window as the popularity of the object.
13. The apparatus of claim 11, wherein the object movement module comprises:
the access times acquisition sub-module is used for acquiring access parameters;
a size parameter determining sub-module, configured to determine a size parameter of the object according to the access parameter and an object size of the object;
and the object moving submodule is used for moving the objects which are not stored in the cache into the cache according to the popularity and the size parameter of the objects.
14. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
the memory is used for storing a computer program;
the processor being configured to implement the method of any of claims 1-10 when executing a program stored on a memory.
15. One or more computer-readable media having instructions stored thereon that, when executed by one or more processors, cause the processors to perform the method of any of claims 1-10.
CN202310253399.3A 2023-03-16 2023-03-16 Dynamic caching method and device, electronic equipment and computer readable medium Active CN116069529B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310253399.3A CN116069529B (en) 2023-03-16 2023-03-16 Dynamic caching method and device, electronic equipment and computer readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310253399.3A CN116069529B (en) 2023-03-16 2023-03-16 Dynamic caching method and device, electronic equipment and computer readable medium

Publications (2)

Publication Number Publication Date
CN116069529A true CN116069529A (en) 2023-05-05
CN116069529B CN116069529B (en) 2023-06-23

Family

ID=86170024

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310253399.3A Active CN116069529B (en) 2023-03-16 2023-03-16 Dynamic caching method and device, electronic equipment and computer readable medium

Country Status (1)

Country Link
CN (1) CN116069529B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106527988A (en) * 2016-11-04 2017-03-22 郑州云海信息技术有限公司 SSD (Solid State Drive) data migration method and device
US20180322900A1 (en) * 2017-05-08 2018-11-08 International Business Machines Corporation Selective arrangement of media in a storage system
CN110232049A (en) * 2019-06-12 2019-09-13 腾讯科技(深圳)有限公司 A kind of metadata cache management method and device
CN110716814A (en) * 2019-09-17 2020-01-21 武汉中海庭数据技术有限公司 Performance optimization method and device for interprocess large data volume communication
CN112631734A (en) * 2020-12-30 2021-04-09 北京天融信网络安全技术有限公司 Processing method, device, equipment and storage medium of virtual machine image file
CN113064738A (en) * 2021-03-29 2021-07-02 南京邮电大学 Active queue management method based on summary data
CN113918603A (en) * 2021-10-11 2022-01-11 平安国际智慧城市科技股份有限公司 Hash cache generation method and device, electronic equipment and storage medium
CN114461681A (en) * 2022-01-21 2022-05-10 西藏宁算科技集团有限公司 Cache content management method and device, electronic equipment and storage medium
CN114676361A (en) * 2022-03-29 2022-06-28 长沙朗源电子科技有限公司 Picture caching and loading method, system, equipment and storage medium
CN115202582A (en) * 2022-07-28 2022-10-18 济南浪潮数据技术有限公司 Data deleting method and device, electronic equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106527988A (en) * 2016-11-04 2017-03-22 郑州云海信息技术有限公司 SSD (Solid State Drive) data migration method and device
US20180322900A1 (en) * 2017-05-08 2018-11-08 International Business Machines Corporation Selective arrangement of media in a storage system
CN110232049A (en) * 2019-06-12 2019-09-13 腾讯科技(深圳)有限公司 A kind of metadata cache management method and device
CN110716814A (en) * 2019-09-17 2020-01-21 武汉中海庭数据技术有限公司 Performance optimization method and device for interprocess large data volume communication
CN112631734A (en) * 2020-12-30 2021-04-09 北京天融信网络安全技术有限公司 Processing method, device, equipment and storage medium of virtual machine image file
CN113064738A (en) * 2021-03-29 2021-07-02 南京邮电大学 Active queue management method based on summary data
CN113918603A (en) * 2021-10-11 2022-01-11 平安国际智慧城市科技股份有限公司 Hash cache generation method and device, electronic equipment and storage medium
CN114461681A (en) * 2022-01-21 2022-05-10 西藏宁算科技集团有限公司 Cache content management method and device, electronic equipment and storage medium
CN114676361A (en) * 2022-03-29 2022-06-28 长沙朗源电子科技有限公司 Picture caching and loading method, system, equipment and storage medium
CN115202582A (en) * 2022-07-28 2022-10-18 济南浪潮数据技术有限公司 Data deleting method and device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王婷: "Web端性能优化的研究与实现", 现代计算机, pages 24 - 29 *

Also Published As

Publication number Publication date
CN116069529B (en) 2023-06-23

Similar Documents

Publication Publication Date Title
CN104915319B (en) The system and method for cache information
US7058763B2 (en) File system for caching web proxies
CN108055302B (en) Picture caching processing method and system and server
US20040073867A1 (en) Precomputation of web documents
AU2015201273B2 (en) System and method of caching information
US9851925B2 (en) Data allocation control apparatus and data allocation control method
CN116069529B (en) Dynamic caching method and device, electronic equipment and computer readable medium
US20190114082A1 (en) Coordination Of Compaction In A Distributed Storage System
WO2022152086A1 (en) Data caching method and apparatus, and device and computer-readable storage medium
CN109582233A (en) A kind of caching method and device of data
CN112445794B (en) Caching method of big data system
CN114356230B (en) Method and system for improving read performance of column storage engine
CN116185904A (en) Cache management method, device, equipment and storage medium
CN117807040A (en) Data pre-reading method and device
McCann et al. The Kendra Cache

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: 100007 room 205-32, floor 2, building 2, No. 1 and No. 3, qinglonghutong a, Dongcheng District, Beijing

Patentee after: Tianyiyun Technology Co.,Ltd.

Address before: 100093 Floor 4, Block E, Xishan Yingfu Business Center, Haidian District, Beijing

Patentee before: Tianyiyun Technology Co.,Ltd.