Dynamic caching method and apparatus, and electronic device and computer-readable medium
Through the dynamic caching method, according to the popularity and size of the object, combined with the load access mode, the cache position of the object in the object storage system is dynamically adjusted, which solves the problem in the existing technology that large objects occupy the cache and causes small objects to be eliminated, and improves the efficiency Performance and cache hit ratio of object storage systems.
Patent Information
- Application Number
- PCT/CN2023/139959
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-03-16
- Filing Date
- 2023-12-19
- Publication Date
- 2024-09-19
AI Technical Summary
During cache replacement in existing object storage systems, the RAM cache capacity is insufficient due to the high access heat of large objects, causing small objects to be frequently eliminated, which in turn increases HDD random access and reduces system performance.
Adopt a dynamic caching method to determine whether the object is in the cache by receiving access requests. If not, store its access information in the message queue, and dynamically adjust the popularity of the object based on the access information and object size in the message queue. and size parameters to determine whether the object is moved to the cache, and the access parameters are dynamically adjusted according to the load access pattern to optimize the cache hit rate.
The performance of the object storage system is improved. Through dynamic adjustment based on object size and popularity, the cache location is optimized, adapted to different load access modes, and the cache hit rate is improved.
Smart Images

Figure CN2023139959_19092024_PF_FP_ABST
Abstract
Description
Dynamic caching method, device, electronic device and computer-readable medium
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on March 16, 2023, with application number 202310253399.3, and application name “A dynamic caching method, device, electronic device and computer-readable medium”, all contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computer technology, and in particular to a dynamic caching method, a dynamic caching device, an electronic device, and a computer-readable medium. Background Art
[0003] In object storage systems, cache replacement algorithms (such as LRU, LFU, SLRU, ARC, etc.) tend to cache hot objects and prioritize eliminating cold objects when cache replacement occurs. These strategies often do not involve access policies and cache all accessed objects. In real-world application environments, in addition to different popularity, there are also differences in the sizes of requested objects. If a large object is accessed very frequently, the current cache management algorithm will add the large object to the cache. Since the RAM cache capacity is small and limited, this may cause more small objects to be eliminated. If these small objects need to be accessed again, the HDD storage node needs to be accessed. The large amount of random HDD access generated at this time will reduce the overall bandwidth of the system and affect the performance of the object storage system.
[0004] Summary of the Invention
[0005] The embodiments of the present application provide a dynamic caching method, apparatus, electronic device, and computer-readable storage medium to solve the problem of low performance of object storage systems.
[0006] The present application discloses a dynamic caching method, which includes:
[0007] Receive access requests sent by users; access requests are used to obtain objects;
[0008] Determine if the object is stored in the cache;
[0009] If the object is not stored in the cache, the access information corresponding to the object is stored in a preset message queue;
[0010] Determine the popularity of the object based on the access information in the message queue;
[0011] Get the object size of the object;
[0012] Objects not stored in the cache are moved to the cache based on their popularity, size, and preset access parameters, which are dynamically adjusted as the load access pattern changes.
[0013] Optionally, the step of determining the popularity of the object based on the access information in the message queue includes:
[0014] Based on the access information in the message queue, determine the number of times the object has been accessed within a preset time window;
[0015] The number of visits to an object within a preset time window is used as the popularity of the object.
[0016] Optionally, the step of moving objects not stored in the cache to the cache based on the popularity and size of the objects includes:
[0017] Get access parameters;
[0018] Determine the size parameter of the object according to the access parameter and the object size of the object;
[0019] Objects not stored in the cache are moved to the cache based on the object's popularity and size parameters.
[0020] Optionally, the step of moving objects not stored in the cache to the cache based on popularity and size parameters includes:
[0021] Compare the popularity and size parameters of the objects;
[0022] In case the popularity is greater than the size parameter, objects not stored in the cache are moved to the cache.
[0023] Optionally, the method further comprises:
[0024] Log access requests;
[0025] determining at least one access parameter;
[0026] Based on the access parameters, storage simulation information corresponding to the access parameters is generated respectively; the storage simulation information is used to record the simulated storage location of at least one object;
[0027] Replay access requests;
[0028] determining a cache hit rate in a case of replaying the access request based on the storage simulation information;
[0029] According to the cache hit ratio, target access parameters are determined among the access parameters.
[0030] Optionally, if the object is not stored in the cache, the step of storing the access information corresponding to the object in the message queue includes:
[0031] If the object is not stored in the cache, determine whether access information for the object already exists in the message queue;
[0032] If the object already has access information in the message queue, update the access information;
[0033] If the object does not have access information in the message queue, create the object's access information in the message queue.
[0034] Optionally, the access information is used to record the number of accesses;
[0035] If the object already has access information in the message queue, the steps for updating the access information include:
[0036] If the object already has access count information in the message queue, update the access information to increase the access count.
[0037] Optionally, the method further comprises:
[0038] If access information of a new object is created in the message queue, and the amount of access information of the object stored in the message queue is greater than a preset amount, the historically stored access information is deleted from earliest to latest in the order of creation.
[0039] Optionally, the method further comprises:
[0040] After the object is moved to the cache, the access information corresponding to the object in the message queue is deleted.
[0041] Optionally, the step of recording the access request includes:
[0042] For an access request, mapping the object name of the object corresponding to the access request into a 64-bit identifier, and converting the object size into a 64-bit unsigned integer;
[0043] Generates a 16-byte tuple based on the object name of the 64-bit identifier and the object size of the 64-bit unsigned integer;
[0044] A 16-byte tuple is used to record access requests.
[0045] The present application also discloses a dynamic cache device, comprising:
[0046] The request receiving module is used to receive access requests sent by users; access requests are used to obtain objects;
[0047] a cache determination module, configured to determine whether the object is stored in the cache;
[0048] A queue storage module, configured to store access information corresponding to the object in a preset message queue if the object is not stored in the cache;
[0049] A popularity determination module, configured to determine the popularity of an object based on access information in a message queue;
[0050] A size acquisition module is used to obtain the object size of an object;
[0051] The object movement module is used to move objects not stored in the cache to the cache based on the object's popularity, object size and preset access parameters; wherein the access parameters are dynamically adjusted as the load access pattern changes.
[0052] Optionally, the popularity determination module includes:
[0053] The access count determination submodule is used to determine the access count of an object within a preset time window based on the access information in the message queue;
[0054] The popularity determination submodule is used to take the number of visits to an object within a preset time window as the popularity of the object.
[0055] Optionally, the object movement module includes:
[0056] The access count acquisition submodule is used to obtain access parameters;
[0057] A size parameter determination submodule, for determining a size parameter of an object according to an access parameter and an object size of the object;
[0058] The object moving submodule is used to move objects that are not stored in the cache to the cache according to the popularity and size parameters of the objects.
[0059] Optionally, the object movement submodule includes:
[0060] A comparison unit, used to compare the popularity and size parameters of objects;
[0061] The object moving unit is configured to move an object not stored in the cache to the cache if the popularity is greater than a size parameter.
[0062] Optionally, the device further comprises:
[0063] Request recording module, used to record access requests;
[0064] an access parameter determination module, configured to determine at least one access parameter;
[0065] A simulation module is used to generate storage simulation information corresponding to the access parameters based on the access parameters; the storage simulation information is used to record the simulation storage location of at least one object;
[0066] A replay module, used to replay the access request;
[0067] a hit rate calculation module, configured to determine a cache hit rate in a case of replaying an access request based on the storage simulation information;
[0068] The target access parameter determination module is used to determine the target access parameter in the access parameters according to the cache hit rate.
[0069] Optionally, the queue storage module includes:
[0070] a queue determination submodule, for determining whether access information of the object already exists in the message queue if the object is not stored in the cache;
[0071] The update submodule is used to update the access information if the object already has access information in the message queue;
[0072] A creation submodule is used to create access information of the object in the message queue if there is no access information of the object in the message queue.
[0073] Optionally, the access information is used to record the number of accesses;
[0074] Update submodules include:
[0075] The updating unit is used to update the access information to increase the access count if the access count information of the object already exists in the message queue.
[0076] Optionally, the device further comprises:
[0077] The historical access information deletion module is used to delete the historically stored access information from earliest to latest in the creation order if new object access information is created in the message queue and the amount of object access information stored in the message queue is greater than a preset amount.
[0078] Optionally, the device further comprises:
[0079] The access information deletion module is used to delete the access information corresponding to the object in the message queue after the object is moved to the cache.
[0080] Optionally, the request recording module includes:
[0081] An information conversion submodule, for mapping an object name of an object corresponding to an access request into a 64-bit identifier and converting the object size into a 64-bit unsigned integer;
[0082] Generate a submodule for generating a 16-byte tuple based on a 64-bit identified object name and a 64-bit unsigned integer object size;
[0083] The request recording submodule is used to record access requests using 16-byte tuples.
[0084] The embodiment of the present application further discloses 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;
[0085] Memory for storing computer programs;
[0086] The processor is used to implement the method of the embodiment of the present application when executing the program stored in the memory.
[0087] The embodiments of the present application also disclose one or more computer-readable media having instructions stored thereon, which, when executed by one or more processors, enable the processors to perform the method of the embodiments of the present application.
[0088] The embodiments of the present application include the following advantages:
[0089] The dynamic caching method provided by the embodiment of the present application receives an access request sent by a user; the access request is used to obtain an object; it is determined whether the object is stored in the cache; if the object is not stored in the cache, the access information corresponding to the object is stored in a preset message queue; based on the access information in the message queue, the popularity of the object is determined; the object size of the object is obtained; according to the popularity of the object, the object size and the preset access parameters, the object not stored in the cache is moved to the cache; wherein the access parameters are dynamically adjusted as the load access pattern changes. Thus, the storage location of the object can be adjusted based on the object size and popularity, so that the access request as a whole can more easily extract the required object from the cache, thereby improving the performance of the object storage system. At the same time, the access parameters are dynamically adjusted according to the changes in the load access pattern, so that whether the object is moved to the cache can change according to the changes in the load access pattern, so that the dynamic caching method of the present application can adapt to different load access patterns and obtain a better cache hit rate under different user access preferences. BRIEF DESCRIPTION OF THE DRAWINGS
[0090] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0091] FIG1 is a flowchart of a dynamic caching method provided in an embodiment of the present application;
[0092] FIG2 is a flowchart of the steps of a dynamic caching method provided in an embodiment of the present application;
[0093] FIG3 is a schematic diagram of the architecture of an object storage system provided in an embodiment of the present application
[0094] FIG4 is a structural block diagram of a dynamic cache device provided in an embodiment of the present application;
[0095] FIG5 is a block diagram of an electronic device provided in an embodiment of the present application;
[0096] FIG6 is a schematic diagram of a computer-readable medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0097] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0098] 1 , a flowchart of a dynamic caching method provided in an embodiment of the present application is shown, which may specifically include the following steps:
[0099] Step 101: Receive an access request sent by a user; the access request is used to obtain an object;
[0100] When a user needs to retrieve an object from an object storage system, the user can send an access request to the object storage system. The access request can be used to request the object to be retrieved from the object storage system. The access request can record object-related information such as the object name, so that the object storage system can determine the object to be retrieved.
[0101] Step 102, determining whether the object is stored in the cache;
[0102] An object storage system may include low-speed storage media and a cache. Objects may be stored in the low-speed storage media or the cache. Therefore, it is necessary to determine the storage location of the object in order to determine where to retrieve the object. In a specific implementation, the object storage system may maintain a bidirectional cache linked list. The bidirectional cache linked list may contain information about objects stored in the cache. Thus, the object storage system can determine whether the object corresponding to an access request is stored in the cache by checking whether the bidirectional cache linked list contains information about the object.
[0103] Step 103: If the object is not stored in the cache, the access information corresponding to the object is stored in a preset message queue;
[0104] If the object is not stored in the cache, it must be retrieved from a pre-set low-speed storage medium. To improve access efficiency, the object's corresponding access information can be stored in a pre-set message queue. This allows the message queue to determine whether the object has been frequently accessed over a period of time. The message queue can be used to record access information corresponding to the object, such as the number of times the object has been accessed over a period of time.
[0105] Step 104, determining the popularity of the object based on the access information in the message queue;
[0106] Generally speaking, frequently accessed objects are more likely to be stored in the cache, allowing users to quickly retrieve them. In contrast, less frequently accessed objects are more likely to be stored on slower storage media to avoid consuming smaller caches. Therefore, when evaluating whether an object not stored in the cache should be moved to the cache, the object's popularity can be determined to determine whether the object is frequently accessed.
[0107] Step 105, obtaining the object size of the object;
[0108] In the embodiments of the present application, after larger objects are moved to the cache, a large number of smaller objects may be moved to a lower-speed storage medium, resulting in a lower cache hit rate. Therefore, when evaluating whether objects not stored in the cache need to be moved to the cache, the object size can be further considered. Thus, the object size of objects retrieved from the object storage system can be obtained for subsequent evaluation.
[0109] Step 106 , moving objects not stored in the cache to the cache based on the object's popularity, object size, and preset access parameters; wherein the access parameters are dynamically adjusted as the load access pattern changes.
[0110] Based on the popularity of the object, it can be determined whether the object is frequently accessed. Subsequently, it can be determined whether the object needs to be moved to the cache by comprehensively considering the popularity of the object, the size of the object, and the preset access parameters. Generally speaking, for smaller objects with higher access frequencies, priority can be given to storing them in the cache, while for larger objects with higher access frequencies, whether they need to be stored in the cache can be considered based on the access parameters, taking into account whether it will significantly reduce the overall cache hit rate. Larger objects with lower access frequencies can remain stored in low-speed storage media.
[0111] Specifically, a user's access preferences may vary on different days and time periods. For example, a user may prefer to watch videos on weekend nights, making it easier for the object system to receive access to large objects such as videos on weekend nights. A user may prefer to search for office documents on weekday mornings, making it easier for the object system to receive access to small objects such as documents on weekday mornings.
[0112] Thus, the object storage system can have different load access modes. The load access modes can include at least a large object preference mode and a small object preference mode. In the large object preference mode, users tend to access large objects, while in the small object preference mode, users tend to access small objects.
[0113] In a specific implementation, the load access mode can be determined based on the access requests received within a certain historical period. The object storage system can record the access requests received within a certain historical period, such as the last 1 hour, the last 2 hours, the last 4 hours, etc., and determine the current load access mode based on the object size ratio of the objects pointed to by the access requests. For example, among the access requests received within a certain historical period, if the access requests for small objects account for more than 60% of the total access requests, it can be determined that the current load access mode is a small object preference mode. If among the access requests received within a certain historical period, if the access requests for large objects account for more than 50% of the total access requests, it can be determined that the current load access mode is a large object preference mode.
[0114] In an embodiment of the present application, access requests received within a period of time in history can be continuously collected and updated, and the load access pattern can be dynamically adjusted based on the collected and updated access requests, so as to subsequently determine more accurately whether the object can be moved to the cache, so that the object cache system can better adapt to user needs in different time periods and different environments.
[0115] Under different load access modes, in order to ensure a high overall cache hit rate for the object storage system, when determining whether an object should be moved to the cache, the evaluation results can be dynamically adjusted based on changes in the load access mode. For example, for large objects, if the system is currently in large object preference mode, the access parameters can be adjusted to make it easier for large objects to be moved from low-speed storage media to the cache. If the system is currently in small object preference mode, the access parameters can be adjusted to make it more difficult for large objects to be moved to the cache, thereby reducing the situation in which a large amount of small object storage space is occupied due to large objects being moved to the cache under small object preference mode.
[0116] The dynamic caching method provided by the embodiment of the present application receives an access request sent by a user; the access request is used to obtain an object; it is determined whether the object is stored in the cache; if the object is not stored in the cache, the access information corresponding to the object is stored in a preset message queue; based on the access information in the message queue, the popularity of the object is determined; the object size of the object is obtained; according to the popularity of the object, the object size and the preset access parameters, the object not stored in the cache is moved to the cache; wherein the access parameters are dynamically adjusted as the load access pattern changes. Thus, the storage location of the object can be adjusted based on the object size and popularity, so that the access request as a whole can more easily extract the required object from the cache, thereby improving the performance of the object storage system. At the same time, the access parameters are dynamically adjusted according to the changes in the load access pattern, so that whether the object is moved to the cache can change according to the changes in the load access pattern, so that the dynamic caching method of the present application can adapt to different load access patterns and obtain a better cache hit rate under different user access preferences.
[0117] 2 , a flowchart of a dynamic caching method provided in an embodiment of the present application is shown, which may specifically include the following steps:
[0118] Step 201: Receive an access request from a user; the access request contains information about the object;
[0119] When a user needs to retrieve an object from an object storage system, the user can send an access request to the object storage system. The access request can be used to request the object to be retrieved from the object storage system. The access request can record object-related information such as the object name, so that the object storage system can determine the object to be retrieved.
[0120] Step 202, determining whether the object is stored in the cache;
[0121] The object storage system may include a low-speed storage medium and a cache. Objects may be stored in the low-speed storage medium or the cache. The object storage system may determine whether the object corresponding to the access request is stored in the cache by searching the bidirectional cache linked list for information about the object.
[0122] Step 203: If the object is not stored in the cache, determine whether access information for the object already exists in the message queue;
[0123] If the object is not stored in the cache, the message queue can be used to record the access information of the object that was not retrieved from the cache. Generally speaking, each object in the message queue corresponds to a piece of access information. If the access information already exists in the message queue, it can be updated without adding new information to the message queue. Therefore, it is necessary to first determine whether the object's access information already exists in the message queue to determine whether the access information needs to be updated or created.
[0124] Step 204: If the object already has access information in the message queue, update the access information;
[0125] If the object already has access information in the message queue, there is no need to create new access information. Instead, the existing access information can be directly updated to obtain relevant information about the object being accessed by users within a period of time by recording the access information in the message queue.
[0126] In one embodiment of the present application, if access information of the object already exists in the message queue, the step of updating the access information includes:
[0127] S11: If the object already has access information in the message queue, update the access information to increase the number of accesses.
[0128] In a specific implementation, access information can be used to record the number of times an object is accessed. A message queue can be used to record access information within a time window. This allows the message queue to determine the number of times an object is accessed within that time window, and thus the frequency of access to the object over a period of time. If access information for the object already exists in the message queue, the access information can be updated and the access count can be increased to record the access request. For example, upon receiving an access request for an object, if the object is not stored in the cache, the access information corresponding to the object can be updated in the message queue, increasing the access count recorded in the access information by 1.
[0129] Step 205: If the object does not have access information in the message queue, create access information for the object in the message queue;
[0130] If there is no access information for an object in the message queue, it can be considered that the object has been accessed for the first time in a period of time and is not stored in the message queue. In this case, in order to record the access to the object in the message queue, the object's access information can be created in the message queue and the access count can be recorded as 1.
[0131] In one embodiment of the present application, the method further includes:
[0132] S21 , when the access information of the objects stored in the message queue is greater than a preset number, if new access information of the objects is created in the message queue, the historically stored access information is deleted from earliest to latest in the order of creation.
[0133] In a specific implementation, a message queue may have a storage limit, which can store access information corresponding to a preset number of objects. For example, a message queue may store access information corresponding to 10 objects, 100 objects, 1000 objects, etc. This application does not impose any restrictions on this.
[0134] When the amount of access information stored in a message queue for an object exceeds a preset amount, if it is necessary to create access information for a new object in the message queue, the first-in, first-out rule can be used to delete the access information historically stored in the message queue in the order of creation, from earliest to latest. For example, when it is necessary to create access information for a new object, the access information for the first object in the message queue, i.e., the access information with the earliest creation time, can be deleted first. This allows the access information of the most recently accessed object to be stored preferentially in the message queue. Thus, by controlling the message queue to store a preset amount of access information and using the first-in, first-out rule to delete the historically stored access information, it is possible to store the access information of objects within a recent time window, thereby allowing the message queue to know the access frequency of the object within the recent time window.
[0135] Step 206: Determine the popularity of the object based on the access information in the message queue; the popularity is dynamically adjusted as the load access pattern changes.
[0136] In one embodiment of the present application, the step of determining the popularity of an object based on access information in a message queue includes:
[0137] S31, determining the number of accesses to the object within a preset time window based on the access information in the message queue;
[0138] S32: The number of times the object is accessed within a preset time window is used as the popularity of the object.
[0139] Specifically, if an object is frequently accessed within a preset time window, it can be considered popular, while if it is rarely accessed within a preset time window, it can be considered unpopular. The access information in the message queue records the number of times the object was accessed within the preset time window. Therefore, the number of times an object was accessed within the preset time window can be used as the object's popularity, and the number of accesses can be used to evaluate the popularity of an object.
[0140] Step 207, obtaining the object size of the object;
[0141] In the embodiments of the present application, after larger objects are moved to the cache, a large number of smaller objects may be moved to a lower-speed storage medium, resulting in a lower cache hit rate. Therefore, when evaluating whether objects not stored in the cache need to be moved to the cache, the object size can be further considered. Thus, the object size of objects retrieved from the object storage system can be obtained for subsequent evaluation.
[0142] Step 208 , moving objects not stored in the cache to the cache based on the object's popularity, object size, and preset access parameters; wherein the access parameters are dynamically adjusted as the load access pattern changes.
[0143] Based on the object's popularity, it can be determined whether the object is frequently accessed. Subsequently, a determination can be made whether the object needs to be moved to the cache, taking into account both the object's size and popularity. Generally speaking, smaller, more frequently accessed objects are prioritized for storage in the cache, while larger, more frequently accessed objects are considered for storage in the cache, taking into account whether this will significantly reduce the overall cache hit rate. Larger, less frequently accessed objects can be stored on lower-speed storage media.
[0144] In one embodiment of the present application, the step of moving an object not stored in the cache to the cache based on the popularity and size of the object includes:
[0145] S41, obtaining access parameters;
[0146] Specifically, to evaluate whether an object can be moved to the cache, an access parameter can be set. By adjusting the access parameter, the rules for object admission to the cache can be adjusted to meet the cache storage method under different load access patterns, providing users with a better access experience.
[0147] S42, determining a size parameter of the object according to the access parameter and the object size of the object;
[0148] Based on the access parameters and the object's size, the object's size parameter can be calculated. The object's size parameter can be used to assess the difficulty of moving the object into the cache. The larger the object's size parameter, the more difficult it is to move the object into the cache. Conversely, the smaller the object's size parameter, the easier it is to move the object into the cache. By adjusting the access parameters, the object's size parameter can be adjusted to make it easier or more difficult to move the object into the cache. In a specific implementation, the size parameter can be object size / access parameter.
[0149] S43 , moving objects not stored in the cache to the cache according to the popularity and size parameters of the objects.
[0150] Specifically, whether an object not stored in the cache can be moved to the cache can be comprehensively evaluated based on the object's popularity and size parameter. When the size parameter is large, the object must have a high popularity before it can be moved to the cache, while when the size parameter is small, the object can be moved to the cache even if it has a low popularity.
[0151] In one embodiment of the present application, the step of moving objects not stored in the cache to the cache based on popularity and size parameters includes:
[0152] S51, comparison of object popularity and size parameters;
[0153] S52: When the popularity is greater than the size parameter, move the object not stored in the cache to the cache.
[0154] Specifically, the popularity and size parameter of the object can be compared to determine whether the popularity is greater than the size parameter. When the popularity is greater than the size parameter, that is, popularity K> object size size / access parameter n, it can be considered that the object has sufficient value to be moved to the cache, and moving to the cache can help users access the object more efficiently. At this time, objects not stored in the cache can be moved to the cache. When the popularity is not greater than the size parameter, that is, popularity K≤object size size / access parameter n, it can be considered that the object still does not have sufficient value to be moved to the cache, and the object can be retained in the low-speed storage medium.
[0155] In a specific implementation, if the current load access pattern is large object preference, a larger access parameter can be set to make it easier for the popularity K to be greater than the object size / access parameter n, making it easier for large objects to be moved into the cache. If the current load access pattern is small object preference, a smaller access parameter can be set to make it harder for the popularity K to be greater than the object size / access parameter n, making it harder for large objects to be moved into the cache.
[0156] In one embodiment of the present application, the method further includes:
[0157] S61, record access request;
[0158] In the embodiments of the present application, users' access habits may vary in different time periods. For example, during the day, fewer access requests are available, and users tend to access large objects. On the other hand, online, more access requests are available, and users tend to access small objects. To adapt to different user habits, the load access pattern can be regularly re-determined and the access parameters updated based on the access requests. The load access pattern and access parameters can be dynamically adjusted to achieve a good cache hit rate in different situations. Thus, all access requests generated within a period of time can be regularly recorded so that appropriate access parameters can be determined based on the access requests.
[0159] Specifically, in order to save storage space, for an access request, the object name of the object corresponding to the access request is mapped to a 64-bit identifier id, and the object size is converted to a 64-bit unsigned integer; a 16-byte tuple is generated based on the 64-bit identifier object name and the 64-bit unsigned integer object size.<id,size> ; Use 16-byte tuple<id,size> Log access requests.
[0160] S62, determining at least one access parameter;
[0161] In a specific implementation, it is possible to determine which objects need to be moved to the cache based on an access parameter. The access parameter may be associated with the size of the object. One or more access parameters may be set.
[0162] S63, replaying the access request for each access parameter;
[0163] In a specific implementation, access requests can be replayed for different access parameters to simulate how objects are moved under different access parameters.
[0164] S64, determining a cache hit rate in the case of replaying the access request based on the storage simulation information;
[0165] During the replay of access requests, the cache hit rate can be calculated. Specifically, if the object corresponding to the access request can be found in the cache, it can be considered a cache hit. Therefore, the cache hit rate corresponding to the access request can be determined based on the number of cache hits for the object corresponding to the access request and the total number of access requests.
[0166] S65 , determining target access parameters from the access parameters according to the cache hit rate.
[0167] Thereafter, an access parameter with the highest cache hit rate may be determined from the access parameters according to the cache hit rate, and the access parameter may be used as the target access parameter.
[0168] In one embodiment of the present application, the method further includes:
[0169] S71 , after the storage location of the object is moved from the preset low-speed storage medium to the cache, the access information corresponding to the object in the message queue is deleted.
[0170] After the object's storage location is moved from the preset low-speed storage medium to the cache, the object's access information in the message queue is mainly used to store access information of objects not in the cache. Therefore, the access information corresponding to the object in the message queue can be deleted, and there is no need to determine whether the object needs to be moved to the cache later.
[0171] As a specific example of the present application, FIG3 is a schematic diagram of the architecture of an object storage system provided in an embodiment of the present application. The object storage system may include a cache module 301 and a backend low-speed storage medium 302. The cache module 301 may include an object admission filter 3011, an object replay simulator 3012, and a request recorder 3013.
[0172] The object admission filter 3011 can be used to determine, upon receiving an access request, whether information about the object corresponding to the access request is stored in the bidirectional cache linked list based on a preset bidirectional cache linked list. If information about the object corresponding to the access request is stored in the bidirectional cache linked list, the object can be retrieved from the cache. If information about the object corresponding to the access request is not stored in the bidirectional cache linked list, the object can be retrieved from a back-end low-speed storage medium. Simultaneously, the access request can be sent to an object replay simulator to record all access requests within a period of time.
[0173] The request logger 3012 can maintain a message queue that can record access information of objects that are not retrieved from the cache. The message queue can be used to record access information within a time window, thereby knowing the number of times an object is accessed in the time window through the message queue, and thus knowing the frequency of access to the object over a period of time.
[0174] The object replay simulator 3013 can record all access requests within a period of time to replay the access requests, simulate the accesses within a period of time, and determine the target cache parameters from several cache parameters.
[0175] It should be noted that for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the order of the actions described, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0176] 4 shows a block diagram of a dynamic cache device provided in an embodiment of the present application, which may include the following modules:
[0177] The request receiving module 401 is used to receive an access request sent by a user; the access request is used to obtain an object;
[0178] a cache determination module 402 for determining whether the object is stored in the cache;
[0179] The queue storage module 403 is used to store the access information corresponding to the object in a preset message queue if the object is not stored in the cache;
[0180] a popularity determination module 404 for determining the popularity of an object based on access information in the message queue;
[0181] A size acquisition module 405 is used to acquire the object size of the object;
[0182] The object moving module 406 is configured to move objects not stored in the cache to the cache based on the object's popularity, object size, and preset access parameters; wherein the access parameters are dynamically adjusted as the load access pattern changes.
[0183] Optionally, the popularity determination module includes:
[0184] The access count determination submodule is used to determine the access count of an object within a preset time window based on the access information in the message queue;
[0185] The popularity determination submodule is used to take the number of visits to an object within a preset time window as the popularity of the object.
[0186] Optionally, the object movement module includes:
[0187] The access count acquisition submodule is used to obtain access parameters;
[0188] A size parameter determination submodule, for determining a size parameter of an object according to an access parameter and an object size of the object;
[0189] The object moving submodule is used to move objects that are not stored in the cache to the cache according to the popularity and size parameters of the objects.
[0190] Optionally, the object movement submodule includes:
[0191] A comparison unit, used to compare the popularity and size parameters of objects;
[0192] The object moving unit is configured to move an object not stored in the cache to the cache if the popularity is greater than a size parameter.
[0193] Optionally, the device further comprises:
[0194] Request recording module, used to record access requests;
[0195] an access parameter determination module, configured to determine at least one access parameter;
[0196] A simulation module is used to generate storage simulation information corresponding to the access parameters based on the access parameters; the storage simulation information is used to record the simulation storage location of at least one object;
[0197] A replay module, used to replay the access request;
[0198] a hit rate calculation module, configured to determine a cache hit rate in a case of replaying an access request based on the storage simulation information;
[0199] The target access parameter determination module is used to determine the target access parameter in the access parameters according to the cache hit rate.
[0200] Optionally, the queue storage module includes:
[0201] a queue determination submodule, for determining whether access information of the object already exists in the message queue if the object is not stored in the cache;
[0202] The update submodule is used to update the access information if the object already has access information in the message queue;
[0203] A creation submodule is used to create access information of the object in the message queue if there is no access information of the object in the message queue.
[0204] Optionally, the access information is used to record the number of accesses;
[0205] Update submodules include:
[0206] The updating unit is used to update the access information to increase the access count if the access count information of the object already exists in the message queue.
[0207] Optionally, the device further comprises:
[0208] The historical access information deletion module is used to delete the historically stored access information from earliest to latest in the creation order if new object access information is created in the message queue and the amount of object access information stored in the message queue is greater than a preset amount.
[0209] Optionally, the device further comprises:
[0210] The access information deletion module is used to delete the access information corresponding to the object in the message queue after the object is moved to the cache.
[0211] Optionally, the request recording module includes:
[0212] An information conversion submodule, for mapping an object name of an object corresponding to an access request into a 64-bit identifier and converting the object size into a 64-bit unsigned integer;
[0213] Generate a submodule for generating a 16-byte tuple based on a 64-bit identified object name and a 64-bit unsigned integer object size;
[0214] The request recording submodule is used to record access requests using 16-byte tuples.
[0215] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0216] In addition, an embodiment of the present application further provides an electronic device, as shown in FIG5 , including 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 communicate with each other through the communication bus 504.
[0217] Memory 503, used for storing computer programs;
[0218] The processor 501 is configured to execute the program stored in the memory 503, and implement the following steps:
[0219] Receive access requests sent by users; access requests are used to obtain objects;
[0220] Determine if the object is stored in the cache;
[0221] If the object is not stored in the cache, the access information corresponding to the object is stored in a preset message queue;
[0222] Determine the popularity of the object based on the access information in the message queue;
[0223] Get the object size of the object;
[0224] Objects not stored in the cache are moved to the cache based on their popularity, size, and preset access parameters, which are dynamically adjusted as the load access pattern changes.
[0225] Optionally, the step of determining the popularity of the object based on the access information in the message queue includes:
[0226] Based on the access information in the message queue, determine the number of times the object has been accessed within a preset time window;
[0227] The number of visits to an object within a preset time window is used as the popularity of the object.
[0228] Optionally, the step of moving objects not stored in the cache to the cache based on the popularity and size of the objects includes:
[0229] Get access parameters;
[0230] Determine the size parameter of the object according to the access parameter and the object size of the object;
[0231] Objects not stored in the cache are moved to the cache based on the object's popularity and size parameters.
[0232] Optionally, the step of moving objects not stored in the cache to the cache based on popularity and size parameters includes:
[0233] Compare the popularity and size parameters of the objects;
[0234] In case the popularity is greater than the size parameter, objects not stored in the cache are moved to the cache.
[0235] Optionally, the method further comprises:
[0236] Log access requests;
[0237] determining at least one access parameter;
[0238] Based on the access parameters, storage simulation information corresponding to the access parameters is generated respectively; the storage simulation information is used to record the simulated storage location of at least one object;
[0239] Replay access requests;
[0240] determining a cache hit rate in a case of replaying the access request based on the storage simulation information;
[0241] According to the cache hit ratio, target access parameters are determined among the access parameters.
[0242] Optionally, if the object is not stored in the cache, the step of storing the access information corresponding to the object in the message queue includes:
[0243] If the object is not stored in the cache, determine whether access information for the object already exists in the message queue;
[0244] If the object already has access information in the message queue, update the access information;
[0245] If the object does not have access information in the message queue, create the object's access information in the message queue.
[0246] Optionally, the access information is used to record the number of accesses;
[0247] If the object already has access information in the message queue, the steps for updating the access information include:
[0248] If the object already has access count information in the message queue, update the access information to increase the access count.
[0249] Optionally, the method further comprises:
[0250] If access information of a new object is created in the message queue, and the amount of access information of the object stored in the message queue is greater than a preset amount, the historically stored access information is deleted from earliest to latest in the order of creation.
[0251] Optionally, the method further comprises:
[0252] After the object is moved to the cache, the access information corresponding to the object in the message queue is deleted.
[0253] Optionally, the step of recording the access request includes:
[0254] For an access request, mapping the object name of the object corresponding to the access request into a 64-bit identifier, and converting the object size into a 64-bit unsigned integer;
[0255] Generates a 16-byte tuple based on the object name of the 64-bit identifier and the object size of the 64-bit unsigned integer;
[0256] A 16-byte tuple is used to record access requests.
[0257] The communication bus mentioned in the terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0258] The communication interface is used for communication between the above terminal and other devices.
[0259] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0260] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0261] As shown in FIG6 , in another embodiment provided by the present application, a computer-readable storage medium 601 is further provided, in which instructions are stored. When the instructions are executed on a computer, the computer executes the dynamic caching method in the above embodiment.
[0262] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the dynamic caching method in the above embodiment.
[0263] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0264] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0265] Each embodiment in this specification is described in a related manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For related parts, refer to the description of the method embodiment.
[0266] The above are only preferred embodiments of the present application and are not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application are included in the scope of protection of the present application.
Claims
1. A dynamic caching method, characterized in that: The method comprises: Receiving an access request sent by a user; the access request is used to obtain 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 access information in the message queue; Get the object size of the object; The objects not stored in the cache are moved to the cache according to the popularity of the objects, the size of the objects and preset access parameters; wherein the access parameters are dynamically adjusted as the load access pattern changes.
2. The method according to claim 1, characterized in that: The step of determining the popularity of the object based on the access information in the message queue comprises: Determining the number of accesses to the object within a preset time window based on the access information in the message queue; The number of visits to the object within a preset time window is taken as the popularity of the object.
3. The method according to claim 1, characterized in that The step of moving the object not stored in the cache to the cache according to the popularity of the object, the object size and the preset access parameters comprises: Get access parameters; Determining a size parameter of the object according to the access parameter and the object size of the object; Objects not stored in the cache are moved to the cache according to the popularity and the size parameter of the object.
4. The method according to claim 3, characterized in that The step of moving the object not stored in the cache to the cache according to the popularity and the size parameter comprises: comparing the popularity and the size parameter of the objects; When the popularity is greater than the size parameter, objects not stored in the cache are moved to the cache.
5. The method according to claim 1 or 3, characterized in that: The method further comprises: recording the access request; determining at least one access parameter; Replaying the access request for each of the access parameters; determining a cache hit rate in a case of replaying the access request based on the storage simulation information; According to the cache hit rate, a target access parameter is determined in the access parameters.
6. The method according to claim 1, characterized in that The step of storing the access information corresponding to the object in a message queue if the object is not stored in the cache comprises: If the object is not stored in the cache, determining whether access information of the object already exists in the message queue; If the object already has access information in the message queue, update the access information; If the access information of the object does not exist in the message queue, the access information of the object is created in the message queue.
7. The method according to claim 6, characterized in that The access information is used to record the number of accesses; If the object already has access information in the message queue, the step of updating the access information comprises: If the object already has access count information in the message queue, the access information is updated to increase the access count.
8. The method according to claim 6, characterized in that The method further comprises: If new access information of the object is created in the message queue, and the amount of access information of the object stored in the message queue is greater than a preset amount, the historically stored access information is deleted from earliest to latest in the order of creation.
9. The method according to claim 6, characterized in that The method further comprises: After the object is moved to the cache, the access information corresponding to the object in the message queue is deleted.
10. The method according to claim 5, characterized in that The step of recording the access request comprises: For an access request, mapping the object name of the object corresponding to the access request into a 64-bit identifier, and converting the object size into a 64-bit unsigned integer; Generates a 16-byte tuple based on the 64-bit identifier of the object name and the 64-bit unsigned integer object size; The access request is recorded in a 16-byte tuple.
11. A dynamic cache device, characterized in that: The device comprises: A request receiving module, used to receive an access request sent by a user; the access request is used to obtain an object; A cache determination module, used to determine whether the object is stored in the cache; A queue storage module, configured to store access information corresponding to the object in a preset message queue if the object is not stored in the cache; A popularity determination module, configured to determine the popularity of the object based on the access information in the message queue; A size acquisition module, used to acquire the object size of the object; An object moving module is used to move the object not stored in the cache to the cache according to the popularity of the object, the object size and preset access parameters; wherein the access parameters are dynamically adjusted as the load access pattern changes.
12. The device according to claim 11, characterized in that: The popularity determination module includes: An access count determination submodule, used to determine the access count of the object within a preset time window based on the access information in the message queue; The popularity determination submodule is used to use the number of visits to the object within a preset time window as the popularity of the object.
13. The device according to claim 11, characterized in that The object moving module comprises: The access count acquisition submodule is used to obtain access parameters; A size parameter determination submodule, used to determine the size parameter of the object according to the access parameter and the object size of the object; The object moving submodule is used to move objects not stored in the cache to the cache according to the popularity and the size parameter of the object.
14. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; The memory is used to store computer programs; The processor is used to implement the method according to any one of claims 1 to 10 when executing the program stored in the memory.
15. One or more computer-readable media having instructions stored thereon, which when executed by one or more processors cause the processors to perform the method of any one of claims 1-10.
Citation Information
Patent Citations
Storage system access method, apparatus and electronic device
CN108875046A
Content distribution network caching method and system based on spectral clustering
CN113225380A
Caching method and device and readable storage medium
CN114116634A
Cache content management method and device, electronic equipment and storage medium
CN114461681A
Dynamic caching method and device, electronic equipment and computer readable medium
CN116069529A
