A cache system, cache processing method, device, equipment and medium
By introducing the cache control module and analysis module into the cloud block storage system, real-time analysis of I/O requests and dynamic adjustment of the cache space solves the problem of poor performance of the cache allocation scheme in the cloud block storage system and improves the efficiency and effectiveness of the cache system. Resource utilization.
Patent Information
- Application Number
- CN202010585684.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-24
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-06-24
AI Technical Summary
Existing cache allocation solutions have poor performance in cloud block storage systems and cannot be deployed online, especially in scenarios where workloads are highly skewed and dynamically changing, making it difficult to achieve effective cache resource utilization.
By introducing the cache control module and analysis module into the cache system, I/O requests are analyzed in real time to determine the cache hit rate curve of each storage node, and based on this, the cache space of the cache instance is dynamically adjusted to achieve on-demand allocation of cache space.
It improves the cache efficiency and performance of the cache system, is suitable for diverse and ever-changing cloud workloads, and achieves optimized configuration of cache space and improved resource utilization.
Smart Images

Figure CN111737168B
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, specifically to the field of computer technology, and in particular to a cache system, a cache processing method, a cache processing device, a cache processing equipment and a computer storage medium. Background Art
[0002] In current business system design, it is often necessary to use cache to accelerate data access and improve the processing capacity of the business system. The data stored in the cache (ie, cache data) can usually be hot data (eg, frequently used data).
[0003] In actual applications, cache data can be managed by cache processing devices (such as cache servers) or cache instances in the cache system, and multiple cache instances usually compete for the same cache resource pool. In this case, how to reasonably allocate cache resources to each cache instance to ensure the service performance of the business system has become an urgent problem to be solved. Summary of the invention
[0004] The embodiments of the present application provide a cache system, a cache processing method, an apparatus, a device and a medium, which can analyze the cache hit rate curve of each storage node in real time according to the I / O request, and search for the best cache configuration scheme based on the cache hit rate curve of each storage node, and dynamically adjust the cache space of each cache instance.
[0005] On the one hand, an embodiment of the present application provides a cache system, including a cache control module, a cache analysis module and at least one cache instance, each cache instance providing data cache services for its corresponding storage node, wherein:
[0006] The cache analysis module is used to determine the cache hit rate curve of each storage node at the current moment according to the I / O request detected at the current moment, and when the cache processing conditions are met, determine the target cache configuration scheme based on the cache hit rate curve of each storage node at the latest moment, and synchronize the target cache configuration scheme to the cache control module. The target cache configuration scheme is the cache configuration scheme when each storage node reaches the optimization target, and the target cache configuration scheme indicates the size of the cache space to be allocated for each storage node;
[0007] The cache control module is used to adjust the cache space size of each storage node corresponding to the cache instance according to the cache space size to be allocated of each storage node indicated by the target cache configuration scheme.
[0008] On the other hand, an embodiment of the present application provides a cache processing method, which is applied to a cache system, wherein the cache system includes a cache control module, a cache analysis module, and at least one cache instance, each cache instance providing a data cache service for a corresponding storage node, the method comprising:
[0009] According to the I / O request detected at the current moment, determine the cache hit rate curve of each storage node at the current moment;
[0010] When the cache processing conditions are met, a target cache configuration scheme is determined based on the cache hit rate curve of each storage node at the latest moment. The target cache configuration scheme is a cache configuration scheme that enables each storage node to achieve the optimization target. The target cache configuration scheme indicates the size of the cache space to be allocated for each storage node.
[0011] According to the cache space size to be allocated of each storage node indicated by the target cache configuration scheme, the cache space size of the cache instance corresponding to each storage node is adjusted.
[0012] On the other hand, an embodiment of the present application provides a cache processing device, the device comprising:
[0013] A processing unit, configured to determine a cache hit rate curve of each storage node at the current moment according to the I / O request detected at the current moment;
[0014] The processing unit is further configured to determine a target cache configuration scheme based on a cache hit rate curve of each storage node at the latest moment when a cache processing condition is met, wherein the target cache configuration scheme is a cache configuration scheme that enables each storage node to achieve an optimization target, and the target cache configuration scheme indicates the size of the cache space to be allocated for each storage node;
[0015] The adjustment unit is used to adjust the cache space size of each storage node corresponding to the cache instance according to the cache space size to be allocated of each storage node indicated by the target cache configuration scheme.
[0016] Accordingly, an embodiment of the present application further provides a cache processing device, including a processor and a storage device; the cache processing device includes a processor and a storage device; the storage device is used to store program instructions; the processor calls the program instructions to perform the following steps:
[0017] According to the I / O request detected at the current moment, determine the cache hit rate curve of each storage node at the current moment;
[0018] When the cache processing conditions are met, a target cache configuration scheme is determined based on the cache hit rate curve of each storage node at the latest moment, the target cache configuration scheme being a cache configuration scheme that enables each storage node to achieve the optimization target, and the target cache configuration scheme indicates the size of the cache space to be allocated for each storage node;
[0019] According to the cache space size to be allocated of each storage node indicated by the target cache configuration scheme, the cache space size of the cache instance corresponding to each storage node is adjusted.
[0020] Accordingly, an embodiment of the present application further provides a computer storage medium, in which program instructions are stored. When the program instructions are executed, they are used to implement the above-mentioned methods.
[0021] In an embodiment of the present application, the cache hit rate curve of each storage node at the current moment can be determined according to the I / O request detected at the current moment. When the cache processing conditions are met, the target cache configuration scheme is determined based on the cache hit rate curve of each storage node at the latest moment, and the cache space of each cache instance is dynamically adjusted according to the target cache configuration scheme, which is conducive to realizing on-demand allocation of cache space and effectively improving cache utilization. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 It is a structural diagram of a cloud block storage system in the prior art;
[0024] Figure 2a It is a structural diagram of a cache system provided in an embodiment of the present application;
[0025] Figure 2b It is a structural diagram of a cloud block storage system provided by an embodiment of the present application;
[0026] Figure 3 It is a flowchart of a cache processing method provided in an embodiment of the present application;
[0027] Figure 4a is a schematic diagram of a cache hit rate curve provided in an embodiment of the present application;
[0028] Figure 4b is a schematic diagram of a reuse distance distribution provided in an embodiment of the present application;
[0029] Figure 4c This is a schematic diagram of a scenario for calculating reuse rate provided in an embodiment of the present application;
[0030] Figure 4d is a schematic diagram of a reuse rate curve provided in an embodiment of the present application;
[0031] Figure 5a This is a schematic diagram of a scenario for calculating reuse rate provided in an embodiment of the present application;
[0032] Figure 5b This is a schematic diagram of a scenario for calculating a cache hit rate curve provided in an embodiment of the present application;
[0033] Figure 6 It is a structural diagram of a cache processing device provided in an embodiment of the present application;
[0034] Figure 7 It is a structural diagram of a cache processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0036] Currently, cache allocation methods may include average allocation and fixed allocation methods. Among them, the average allocation method is to pre-analyze the total cache space requirements, and uniformly allocate cache resources to each cache instance according to the defined service level objectives. For example, the total cache space size is 5GB, and there are 5 cache instances, then the cache space size allocated to each cache instance can be 1GB. Fixed allocation is to allocate the same or different cache resources to each cache instance. For example, the total cache space size is 5GB, and there are 5 cache instances. The cache space size of the first cache instance can be configured to be 2GB, the cache space size of the second cache instance and the third cache instance can be configured to be 1GB, and the cache space size of the fourth cache instance and the fifth cache instance can be configured to be 0.5GB.
[0037] The above two allocation methods are essentially a static allocation strategy. If the cache space of the cache instance is over-configured, it may lead to insufficient utilization of cache resources; if the cache space of the cache instance is under-configured, it may lead to reduced cache performance, especially in scenarios where the workload is highly skewed and dynamically changing (such as CBS (Cloud blockstorage) system), the cache performance is low.
[0038] Among them, CBS is a commonly used cloud storage architecture that can provide users with a general block-level cloud storage service. Cloud storage is a new concept that extends and develops from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as a storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of different types of storage devices (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide external data storage and business access functions.
[0039] At present, the storage method of the storage system is: create a logical volume, and when creating a logical volume, allocate physical storage space for each logical volume. The physical storage space may be composed of disks of a storage device or several storage devices. The client stores data on a logical volume, that is, stores the data on the file system. The file system divides the data into many parts, each of which is an object. The object contains not only data but also additional information such as data identification (ID, IDentity). The file system writes each object into the physical storage space of the logical volume, and the file system records the storage location information of each object, so that when the client requests to access the data, the file system can allow the client to access the data according to the storage location information of each object.
[0040] Exemplarily, the cloud block storage system can be as follows Figure 1 As shown in FIG, the cloud block storage system includes a client, a cloud virtual machine, a cache system for providing cache services, and a storage system for providing storage services. Each part is connected through a network to achieve mutual communication and data transmission. Based on the cloud virtual machine provided by the cloud block storage system, the client can access the remote block storage service just like accessing a local hard disk. Among them, the cache system includes multiple cache instances (such as Figure 1 Instance 1 to Instance N in the cache, where N is an integer greater than 0), a cache instance provides data caching services for a storage node to improve the data access rate. Each cache instance can be understood as a cache service process that runs independently in the cache system and is used to manage the cache data of the corresponding storage node. The cache data is stored in multiple cache blocks, which are assigned to different cache instances for management. The data blocks managed by each cache instance are used to cache the data of the corresponding storage node, that is, the cache data stored in the data blocks managed by each cache instance can be regarded as a copy of the data stored in the storage node corresponding to the cache instance.
[0041] In the cloud block storage system, the cache system and the storage system can be deployed on the same physical device. Accordingly, the cache service and the storage service are provided by the same physical device, which can be a storage device (such as a storage server). Usually, a space can be divided from the physical memory of the storage device as a cache, that is, frequently used data is copied from the storage resource to the cache to provide cache services. When receiving a read data request, the cache is first accessed to check whether the cache has saved the data of the address to be accessed. If so, the data is quickly returned; if not, the disk is directly accessed and the data read from the disk is saved in the cache for the next access to the data at the address. When receiving a write data request, the data is written to the cache and the command is returned directly. Subsequently, the data in the cache can be automatically refreshed to the disk in the background according to a specific strategy to release the cache space. Through the cache technology, the high-speed access characteristics of physical memory can be effectively utilized to optimize the performance of the entire cloud block storage system.
[0042] Alternatively, the cache system and the storage system may be deployed on different physical devices, for example, the cache system may be deployed on a cache server, and cache services may be provided through the cache server; the storage system may be deployed on a storage server, and storage services may be provided through the storage server. The cache server and the storage server may be independent physical servers, or server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.
[0043] The above-mentioned client can be a terminal device such as a smartphone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., or it can be an application running on the terminal device (such as game application, Internet of Vehicles application, video application, etc.) or a network platform, but is not limited to this.
[0044] The present application embodiment proposes a cache system, which can be deployed in a CBS system or other storage systems. Figure 2a, the cache system includes a cache control module, a cache analysis module and at least one cache instance, each cache instance provides data cache services for its corresponding storage node. Among them: the cache analysis module is used to determine the cache hit rate curve of each storage node at the current moment according to the I / O request detected at the current moment, and when the cache processing conditions are met, the target cache configuration scheme is determined based on the cache hit rate curve of each storage node at the latest moment, and the target cache configuration scheme is synchronized to the cache control module. The target cache configuration scheme is a cache configuration scheme that enables each storage node to achieve the optimization target. The target cache configuration scheme indicates the size of the cache space to be allocated for each storage node. The cache control module is used to adjust the cache space size of the cache instance corresponding to each storage node according to the size of the cache space to be allocated for each storage node indicated by the target cache configuration scheme.
[0045] In an embodiment of the present application, after the cache analysis module synchronizes the target cache configuration scheme to the cache control module, the cache control module can adjust the cache space size of the cache instance corresponding to each storage node in real time according to the size of the cache space to be allocated of each storage node indicated by the target cache configuration scheme, and can also periodically adjust the size of the cache space to be allocated of each storage node (for example, once every 12 hours), and the present application does not make any specific limitations on this.
[0046] By implementing the cache system proposed in this application, the cache hit rate curve of each storage node can be analyzed in real time according to I / O requests, and the optimal cache configuration scheme can be searched based on the cache hit rate curve of each storage node, and the cache space of each cache instance can be dynamically adjusted, which is conducive to on-demand allocation of cache space and effectively improves cache utilization.
[0047] Cache is an important component of CBS system and plays a key role in meeting the service goals of tenants. However, in CBS scenarios where workloads are highly skewed and dynamically changing, existing cache allocation schemes are difficult to use in actual systems due to factors such as poor performance and inability to be deployed online. Among them, existing cache allocation methods can be roughly divided into two categories to improve the above-mentioned average allocation and fixed allocation methods. The first category is heuristic search schemes, such as TCM, REF, etc., which are qualitative methods based on intuition or experience. These schemes usually provide feasible solutions to combinatorial optimization problems at acceptable computational and space costs. For example, based on memory access characteristics, TCM classifies threads as latency-sensitive or bandwidth-sensitive, and when cache allocation is performed, latency-sensitive threads are prioritized over bandwidth-sensitive threads. However, this coarse-grained qualitative method depends heavily on previous reliable experience or load rules. Therefore, its efficiency cannot be guaranteed for diverse and changing cloud workloads, and the performance of this cache allocation scheme is poor.
[0048] The other category is cache model-based schemes, which are usually quantitative allocation schemes based on hit rate curves. Compared with heuristic strategies, cache model-based schemes contain exact space requirement information about each cache instance, so they have the ability to search for close to optimal solutions. However, the biggest challenge of this approach is how to construct a cache model to accurately determine the cache hit rate curve. Due to the huge computational complexity and storage cost, most cache models can only be constructed through offline analysis, which limits their applicability in practice.
[0049] To solve the problem of poor performance and inability to deploy online in the existing cache allocation solution in CBS scenarios, see Figure 2b In the embodiment of the present application, the cache system can be deployed in a cloud block storage system, which also includes a client and a storage system. The cache system is used to provide cache services, and the storage system is used to provide storage services. Figure 2b The cloud block storage system shown is compared to Figure 1 The cloud block storage system shown in the figure mainly adds a cache control module and an analysis module to the original cache architecture, and the original cache index, cache data, and cache metadata in the cache architecture remain unchanged. The storage system includes at least one storage node, each storage node includes a data block for storing data (see Figure 1 A storage node corresponds to a cache instance, and each cache instance is used to manage the cache data of the corresponding storage node. The above I / O request is a read and write request from a client in the cloud block storage system, which is used to read and write data. Specifically, the I / O request can be used to read the target data in the target data block, or to write the target data in the target data block.
[0050] The cache analysis module includes an I / O request statistics module, a cache modeling module and a search module.
[0051] The I / O request statistics module is used to update the access statistics information according to the currently detected I / O request. Specifically, the access statistics information may include the total number of accessed data blocks, the number of repeatedly accessed data blocks, and the access traffic of each storage node. Exemplarily, assuming that the access sequence of the data blocks accessed by the I / O request within a period of time is ABCDBDEFBA, and the repeatedly accessed data blocks include data blocks B, D, and A. Data block B is repeatedly accessed 2 times, and data blocks D and A are repeatedly accessed once each. Then the total number of accessed blocks during this period is 10, and the number of repeatedly accessed data blocks is 4.
[0052] The cache modeling module is used to update the reuse distance distribution of the previous moment according to the updated access statistics, obtain the reuse distance distribution of the current moment, and determine the cache hit rate curve of each storage node at the current moment based on the pre-built cache model and the reuse distance distribution of the current moment. The reuse distance distribution at the current moment characterizes the distribution of reuse distances of each data block accessed by all I / O requests before the current moment, and the previous moment is the moment when the last I / O request was detected. Among them, the cache model is deployed online, and can be combined with the reuse distance distribution in real time or periodically to calculate the cache hit rate curve of each storage node under system time.
[0053] The search module is used to search for a target cache configuration scheme that enables each storage node to achieve the optimization target based on the cache hit rate curve of each storage node at the latest moment when the cache processing conditions are met. The optimization target can be to maximize the total hit flow of each storage node, or to simultaneously minimize the write volume of the cache processing device and maximize the total hit flow.
[0054] The cache control module includes an instance management module and a configuration delivery module. The instance management module is used to manage cache instances (such as adding or deleting cache instances). The configuration delivery module is used to adjust the cache space size of each storage node corresponding to the cache instance according to the target cache configuration scheme.
[0055] In the cloud block storage system scenario, how to allocate reasonable cache space to different storage nodes on demand is a huge challenge. This requires the cache allocation strategy to determine the actual demand for cache space of each storage node based on the load characteristics. However, determining the demand for cache space is not easy. This not only requires an effective model to quantify, but also requires a lot of computing resources for analysis.
[0056] In the embodiment of the present application, the cache system can search for a target cache configuration scheme that is close to the optimal solution with extremely low complexity through the cache analysis module, thereby improving the cache efficiency of the cache system. Its core idea is mainly divided into three steps. The first step is to deploy a new cache model online through the cache modeling module, which can obtain the cache hit rate curve of each storage node in the CBS system according to the I / O request; the second step is to define the optimization index and point out the final optimization goal; the third step is to search for the optimal strategy (i.e., the target cache configuration scheme) through the search module, and finally dynamically adjust the cache space of the cache instance corresponding to each storage node according to the target cache configuration scheme. In the CBS scenario, it can be applied to diverse and changing cloud workloads, so that the cache system can achieve the best performance and cost.
[0057] Based on the above description, the embodiment of the present application proposes a cache processing method, which is applied to the cache system mentioned above. The cache system includes a cache control module, a cache analysis module and at least one cache instance. Each cache instance provides data cache services for its corresponding storage node. Figure 3 The cache processing method may include the following steps S301-S303:
[0058] S301, according to the I / O request detected at the current moment, determine the cache hit rate curve of each storage node at the current moment. Wherein, the above-mentioned I / O request is used to access the target data block, to read the target data from the target data block or to write the target data in the target data block, and the target data block is any data block included in each storage node.
[0059] The cache hit rate curve of each storage node represents the corresponding relationship between the cache hit rate of each storage node and the cache space size. The cache hit rate is the most important indicator for determining cache efficiency. The higher the cache hit rate, the greater the role of the cache, that is, the higher the cache efficiency. For example, the cache hit rate curve can be as follows: Figure 4a As shown, the corresponding relationship between the cache hit rate and the cache space size of the corresponding storage node is represented.
[0060] The cache hit rate curve plays a vital role in guiding the configuration of the cache size. Existing methods for obtaining the cache hit rate curve include simulation method and model method. The simulation method, as the name implies, is to obtain the distribution of hit rates under different cache sizes through offline simulation. However, this method is difficult to implement in large-scale cloud storage systems. On the one hand, the simulation requires a lot of computing resources (multiple processes for simulation), and on the other hand, due to the huge amount of data, the simulation takes a lot of time. Another common method is the model method, which converts the reuse distance distribution into a hit rate curve through statistical analysis. However, the current reuse distance statistical method is extremely complex, and it is difficult to achieve real-time online statistics. In an embodiment of the present application, the above problems can be effectively solved by a statistical method of reuse distance distribution based on reuse rate.
[0061] The reuse distance refers to the amount of unique data accessed between two consecutive accesses to the same data block. For example, assuming an access sequence is ABCCDBDDA, the reuse distance of data block A is 3, because the amount of unique data between two consecutive accesses to A is {B, C, D}. The reuse distance distribution characterizes the distribution of the reuse distances of all data blocks. Figure 4b As shown, it is a typical reuse distance distribution diagram, where the horizontal axis is the reuse distance and the vertical axis is the proportion of the corresponding reuse distance.
[0062] For a typical LRU cache algorithm, a data block can only be hit when its reuse distance is less than the cache size. The cache hit rate of the cache in the corresponding cache space can be converted into a function of the reuse distance distribution as shown in Formula 1.1. In Formula 1.1, hr(c) represents the cache hit rate when the cache space size is c, and r(i) represents the proportion of reuse distance i.
[0063]
[0064] Based on this, in an embodiment of the present application, a specific implementation method for determining the cache hit rate curve of each storage node at the current moment according to the I / O request detected at the current moment can be: updating the access statistics according to the I / O request detected at the current moment, updating the reuse distance distribution of the previous moment according to the updated access statistics, obtaining the reuse distance distribution of the current moment, and determining the cache hit rate curve of each storage node at the current moment based on the pre-built cache model and the reuse distance distribution of the current moment, wherein the reuse distance distribution of the current moment characterizes the distribution of reuse distances of each data block accessed by all I / O requests before the current moment, and the previous moment is the moment when the I / O request was last detected.
[0065] As a feasible implementation method, the cache hit rate of each storage node at the current moment under each cache space size can be determined according to the pre-constructed cache model and the reuse distance distribution at the current moment, and based on the cache hit rate of each storage node at the current moment under each cache space size, a cache hit rate curve of each storage node at the current moment is generated. In a specific implementation, the above-mentioned pre-constructed cache model can be constructed by the above-mentioned formula 1.1, and multiple different cache space sizes c can be pre-configured. After the reuse distance distribution at the current moment is determined, the cache hit rate of each storage node at different c values can be calculated by formula 1.1, and then the cache hit rate curve of each storage node at the current moment is drawn based on the cache hit rate of each storage node at different c values. The cache hit rate curve can be as shown Figure 4a shown.
[0066] However, the complexity of obtaining the reuse distance distribution is currently O(N*M), which makes it impossible to be applied in actual systems, where N is the total number of references in the access sequence (i.e., the total number of accessed data blocks) and M is the number of unique data blocks referenced (i.e., the unique data volume mentioned above). In order to reduce the complexity of obtaining the reuse distance distribution, a variety of methods have been proposed to reduce the computational complexity to O(Nlog(n)), such as using search trees, proportional trees, interval trees, etc. However, in essence, the calculations of these methods are still logarithmic each time, and the amount of calculation is large.
[0067] The embodiment of the present application can construct a reuse distance distribution through a reuse rate-based cache model (RAR-CM), and then convert it into a hit rate curve based on the reuse distance distribution. Specifically, the reuse distance distribution can be calculated based on the reuse rate. The biggest advantage of this method is that it can be deployed online and the complexity of obtaining the reuse distance distribution is low, and there is no need to collect I / O logs for offline analysis.
[0068] According to the definition of reuse distance, the reuse distance can be converted into reuse rate according to the following formula 1.2.
[0069] Reuse distance = total number of accessed data blocks * (1-reuse rate) Formula 1.2
[0070] The reuse rate refers to the ratio of the number of repeatedly accessed data blocks to the total number of accessed data blocks within a period of time. Figure 4c As shown in the figure, an example of reuse rate is given. The figure shows that the reuse rate within a time interval τ is 40%. Within this time interval τ, the number of repeated accesses to data blocks is 4 ( Figure 4c The total number of accessed blocks is 10, so the reuse rate is 40%. According to the definition of reuse rate, the reuse rate in a certain period of time can be obtained by counting the total number of accessed data blocks and the number of repeatedly accessed data blocks in this period of time.
[0071] in accordance with Figure 4c It can be seen that in a certain access sequence, the reuse rate is related to two parameters, namely the starting time t and the time interval τ. In the embodiment of the present application, the reuse rate can be recorded as RAR(t, τ), which represents the reuse rate in the time period τ starting from time t. When τ changes (increases or decreases) as an independent variable, RAR(t, τ) will also change accordingly. At this time, RAR(t, τ) can be called the reuse rate function at time t, and the curve graph formed by it is the reuse rate curve (such as Figure 4d In the implementation process, the reuse rate curve RAR(t, τ) at all times can be drawn, but this method is relatively complex. Through experimental data analysis, it is found that the reuse rate curve changes relatively little. Figure 4d The reuse rate curve of a certain storage node for 6 days is shown. It can be seen that the reuse rate curve changes relatively little within 6 days. Therefore, in the application embodiment, only one reuse rate curve can be stored in a specified period, for example, only one reuse rate curve is stored in a day. In this case, when calculating the reuse distance of any data block, the reuse rate curve (i.e., the specified reuse rate curve mentioned in the embodiment of the present application) that has been drawn in the last specified period can be directly used to calculate the reuse distance of the data block. Accordingly, each time a new I / O request is detected, a new reuse rate curve also needs to be generated. When the next specified period arrives, the reuse rate curve of the last specified period is replaced based on the new reuse rate curve.
[0072] In order to reduce the complexity of obtaining the reuse distance distribution, in an embodiment of the present application, each time a new I / O request is detected, the access statistics can be updated according to the currently detected I / O request, and the total number of accessed data blocks of the target data block from the time lt when the target data block was last accessed to the current time t1 is determined based on the updated access statistics, and the target reuse rate under the target time interval is found from the specified reuse rate curve, and the target time interval is t1-lt. The specified reuse rate curve characterizes the corresponding relationship between each time interval and the reuse rate.
[0073] The designated reuse rate curve refers to the reuse rate curve that has been drawn for the last designated period mentioned above. For example, the last designated period is June 9, 2020, and the current system time is 21:39 on June 10, 2020. In this case, the reuse rate curve drawn on June 9, 2020 can be directly determined as the designated reuse rate curve.
[0074] Furthermore, the total number of accessed data blocks and the target reuse rate of the target data block from the last access time lt to the current time t1 can be calculated according to the reuse distance function to obtain the reuse distance of the target data block, and the reuse distance distribution of the previous moment can be updated based on the reuse distance of the target data block to obtain the reuse distance distribution of the current moment.
[0075] It can be understood that, since each I / O request involves access to a target data block and calculation of the reuse distance of a target data block, the reuse distance distribution of the previous moment is updated based on the reuse distance of the target data block mentioned in the embodiment of the present application. In essence, as time goes by, it can be understood that the reuse distance distribution constructed previously is continuously updated based on the reuse distance of the currently determined target data block, so as to obtain the reuse distance distribution of the current moment.
[0076] The above reuse distance function is shown in the following formula 1.3. Where rd(x) represents the reuse distance of data block x, T(t, τ) represents the total number of accessed data blocks from the last access time t to the current time t1, the time interval τ = t1-t, and RAR(t, τ) is the reuse rate of data block x in the time interval τ.
[0077] rd(x)=(1-RAR(t,τ))×T(t,τ) Equation 1.3
[0078] For example, assuming that the target block accessed by the I / O request under system time is data block B, the time lt of the last access to B is 08:00, and the current time t1 is 09:00, the total number of accessed data blocks of data block B from the time lt of the last access to the current time t1 is determined to be 100 (i.e., T(t, τ) = 100) based on the updated access statistics, and the target reuse rate under the target time interval (t1-lt = 1 hour) is found to be 0.88 (RAR(t, τ) = 0.88) from the specified reuse rate curve, then the reuse distance of data block B can be calculated as 12 by formula 1.3.
[0079] In one embodiment, the access statistics include the total number of accessed data blocks. Each time an I / O request is detected, it can be detected whether the hash map includes the historical information of the target data block. If not, it is determined that the target data block is a new data block, and then the relevant information of the new data block can be written into the hash map. The relevant information includes that the new data block includes the current system time (which can also be understood as the time when the new data is accessed) and the block serial number after the new data block is accessed (which can also be understood as the total number of accessed data blocks up to now, or equivalent to the block serial number corresponding to the new data block at this time).
[0080] If it is detected that the hash map includes historical information of the target data block, which is equivalent to the target data block being a repeatedly accessed data block, the time lt of the last access to the target data block and the block sequence number corresponding to the last access to the target data block can be obtained from the historical information of the target data block, and the updated total number of accessed data blocks is subtracted from the block sequence number corresponding to the last access to the target data block to obtain the total number of accessed data blocks of the target data block from the last access time lt to the current time t1.
[0081] It can be understood that, when the target data block accessed by the I / O request detected at the current moment is a duplicate data block, the system time at this time and the block serial number after the target data block is accessed can also be recorded, and the total number of accessed data blocks from the last access time lt to the current time t1 of the target data block can be obtained in accordance with the above method. The total number of accessed data blocks from the last access time lt to the current time t1 of the target data block can be input into the above formula 1.3 to calculate the reuse distance of the target data block. After calculating the reuse distance of the target data block, the system time and the block serial number after the target data block is accessed can be written into the hash map as the above historical information required for calculating the reuse distance when the target data block is accessed next time.
[0082] S302, when the cache processing conditions are met, a target cache configuration scheme is determined based on the cache hit rate curve of each storage node at the latest moment, the target cache configuration scheme is a cache configuration scheme that enables each storage node to achieve the optimization target, and the target cache configuration scheme indicates the size of the cache space to be allocated for each storage node.
[0083] Among them, the above-mentioned cache processing condition can be a time condition, and the time condition can be the update time of the cache configuration plan arriving at the current time. For example, the update cycle of the cache configuration plan is 1 day, and the specific update time is 00:00. Then, when it is detected that the current time reaches 00:00, it can be determined that the cache processing condition is met; or, the cache processing condition is the detection of an update instruction of the cache configuration plan, and the update instruction can be manually input.
[0084] In one embodiment, the access statistics include the access traffic of each storage node. The access traffic of each storage node can be counted by using a 16-bit unsigned integer variable. Each time new access traffic is generated, the variable value is increased. The cache hit rate curve of each storage node represents the corresponding relationship between the cache hit rate of each storage node and the cache space size (see Figure 4a ). In this case, the specific implementation method of determining the target cache configuration scheme based on the cache hit rate curve of each storage node at the latest moment can be: searching according to the access traffic of each storage node so that the total hit traffic of each storage node is maximized, and the target cache hit rate of each storage node, wherein the total hit traffic is the sum of the products of the access traffic of each storage node and the cache hit rate.
[0085] Furthermore, the cache space size corresponding to the target cache hit rate of each storage node in the cache hit rate curve of each storage node at the latest moment is determined as the cache space size to be allocated for each storage node, and a target cache configuration scheme is generated based on the cache space size to be allocated for each storage node.
[0086] Among them, in the above scenario, in order to achieve the optimal hit rate and cost, the cache efficiency function E (objective function, as shown in the following formula 1.4) is defined. HitRatioi represents the cache hit rate of storage node i, and Traffic is the access traffic of storage node i. Therefore, this formula represents the total hit traffic, and the ultimate optimization goal is to search for the best configuration so that E (that is, the total hit traffic of each storage node) reaches the maximum value.
[0087]
[0088] The search process for the best configuration is to find a set of suitable [CacheSize0, CacheSize1, ..., CacheSizeN] to maximize the E value, where CacheSizeN represents the size of the cache space to be allocated for storage node N. This is a process of finding the optimal solution. As a feasible implementation method, a brute force search can be used to find the combination that maximizes E among all combinations. Specifically, the target cache hit rate of each storage node when E is maximized can be determined by brute force search based on formula 1.4. Furthermore, the cache space size corresponding to each target cache hit rate can be found from the cache hit rate curve of each storage node, and then the cache space size corresponding to each storage node's target cache hit rate can be determined as the cache space size to be allocated for each storage node.
[0089] However, the complexity of brute force search is extremely high. In order to optimize the solution process of brute force search, the embodiment of the present application uses the idea of dynamic programming and uses recursion to avoid repeated calculations, which can reduce the exponential computational complexity to a linear level. As another implementation method, the target recursive formula and the cache hit rate curve of each storage node at the latest moment can be used to search for the size of the cache space to be allocated for each storage node when the total hit flow of each storage node is maximized, and the target cache configuration scheme is generated based on the size of the cache space to be allocated for each storage node.
[0090] For example, the above target recursive formula can be shown as formula 1.5,
[0091]
[0092] In formula 1.5, N is the set of all storage nodes, S is the total size of the cache resource pool, and T is the set of all storage node access traffic. E(node, s, t) is the hit traffic obtained by the storage node when the cache space size is set to s and the access traffic is t. E(node, s, t) is obtained by multiplying the hit rate of the storage node when the cache space size is s by the access traffic t. Through the iterative recursive method of formula 1.5, the global optimal cache configuration solution can be finally obtained, that is, the cache space size to be allocated for each storage node is determined when the total hit traffic of each storage node is maximized.
[0093] Among them, the specific recursive process of searching for the optimal configuration solution through the above objective formula 1.5 is: first search for the cache space size s1 of the first storage node when E(node1, s, t) of the first storage node reaches the maximum value, and further search among the remaining N-1 storage nodes so that the cache space size s2 of the second storage node when E(node2, s, t) of the second storage node reaches the maximum value, and so on, and finally the global optimal cache configuration solution can be obtained.
[0094] S303: Adjust the cache space size of the cache instance corresponding to each storage node according to the cache space size to be allocated of each storage node indicated by the target cache configuration solution.
[0095] In one embodiment, each cache instance is used to manage cache data of its corresponding storage node, and the cache data is stored through cache blocks. According to the size of the cache space to be allocated of each storage node indicated by the target cache configuration scheme, the specific implementation method of adjusting the cache space size of the cache instance corresponding to each storage node can be: if it is determined according to the indication of the target cache configuration scheme that the size of the cache space to be allocated of the target storage node is smaller than the actual cache space size of the target storage node, then the cache block storing the target cache data is released, and the target cache data is the cache data managed by the cache instance corresponding to the target storage node. If it is determined according to the indication of the target cache configuration scheme that the size of the cache space to be allocated of the target storage node is larger than the actual cache space size of the target storage node, then a new cache block is allocated to the cache instance corresponding to the target storage node. Wherein, the target storage node is any storage node of each storage node.
[0096] Specifically, cache data is stored through multiple cache blocks, which are assigned to different cache instances for management. One cache instance corresponds to one storage node, and the data blocks managed by each cache instance are used to cache the data of the corresponding storage node, that is, the cache data stored in the data blocks managed by each cache instance can be regarded as a copy of the data stored in the storage node corresponding to the cache instance. In this case, if it is determined according to the instructions of the target cache configuration scheme that the size of the cache space to be allocated of the target storage node is smaller than the actual cache space size of the target storage node, in order to reduce the impact of the configuration process on the cache performance, the embodiment of the present application can only reallocate part of the cache blocks. As a feasible implementation method, the data blocks that have not been accessed the longest can be preferentially selected from the data blocks managed by the cache instance corresponding to the target storage node for release, and other data blocks are not adjusted. The released cache blocks are directly allocated on demand to the cache instance that needs to expand the cache space.
[0097] Exemplarily, the cache instance can manage cache blocks in the form of a cache queue. During the management process, each cache block can be sorted in the cache queue in descending order according to the historical frequency of access to each cache block. Assuming that a cache block is 32KB, the target storage node is storage node 1, the actual cache space size of storage node 1 is 200GB, and the target cache configuration scheme indicates that the cache space size to be allocated for storage node 1 is 100GB. In this case, the number of cache blocks to be released is 100GB / 32K=3276800. Then, the 3276800 cache blocks at the end of the cache queue of the cache instance corresponding to storage node 1 can be selected for release.
[0098] In one embodiment, the access statistics include the total number of accessed data blocks, the number of repeatedly accessed data blocks, and the access traffic of each storage node. The specific implementation method of updating the access statistics according to the I / O request detected at the current moment may be: according to the I / O request detected at the current moment, the total number of accessed data blocks is increased by a specified value. If the hash map contains historical information of the target data block, which is equivalent to the target data block being a repeatedly accessed data block, the number of repeatedly accessed data blocks is increased by a specified value, and the access traffic corresponding to the I / O request is obtained, and the access traffic of the storage node corresponding to the target data block is updated according to the access traffic. The specified value is pre-configured, for example, it can be 1.
[0099] In a specific implementation, a total access counter (TC) may be set, and a repeated access counter (RC) may be set for the data block. The value of TC is the total number of accessed data blocks, and the value of RC is the number of repeatedly accessed data blocks.
[0100] Furthermore, in one embodiment, the total number of accessed data blocks and the number of repeatedly accessed data blocks at different time intervals can also be obtained, and the total number of accessed data blocks and the number of repeatedly accessed data blocks at different time intervals are calculated according to the reuse rate function to obtain the reuse rates at different time intervals, and a reuse rate curve is generated based on the reuse rates at different time intervals. When it is detected that the reuse rate curve update condition is met, the specified reuse rate curve is replaced by the reuse rate curve.
[0101] In a specific implementation, each time an I / O request for requesting a target data block is detected, the total number of accessed data blocks and the number of repeatedly accessed data blocks of the target data block need to be updated. Subsequently, the latest total number of accessed data blocks and the number of repeatedly accessed data blocks of the target data block can be obtained periodically (for example, every hour). The latest total number of accessed data blocks and the number of repeatedly accessed data blocks are calculated according to the reuse rate function to obtain the reuse rate in the time interval before the current moment t1, thereby updating the reuse rate curve based on the reuse rate in the time interval before the current moment t1. As time goes by, the reuse rate in different time intervals can be obtained according to the same method, and a reuse rate curve representing the reuse rate in different time intervals can be drawn.
[0102] Among them, through the above Figure 4d As can be seen from the description, due to the relatively small changes in the reuse rate curve, in the application embodiment, only one reuse rate curve can be stored within a specified period, for example, only one reuse rate curve can be stored in a day, and when calculating the reuse distance of any data block, the reuse rate curve that has been drawn in the previous specified period (i.e., the specified reuse rate curve mentioned in the embodiment of the present application) can be directly used. In this case, the above-mentioned reuse rate curve update condition can be that the current moment reaches the next specified period. For example, the specified period is one day, the previous specified period is June 9, 2020, the next specified period is June 11, 2020, and the current moment is June 10, 2020. The reuse rate curve of June 10, 2020 can be obtained according to the above method. When it is detected that the current moment moves to the next specified period, the reuse rate curve of June 10, 2020 can be replaced by the reuse rate curve of June 9, 2020 in the previous specified period. Subsequently, the reuse distance of data blocks on June 11, 2020, was calculated in combination with the reuse rate curve on June 10, 2020.
[0103] For example, the above-mentioned specified time interval is 1 hour, the last specified cycle is June 9, 2020, and the current system time is June 10, 2020. In this case, the reuse rate curve drawn on June 9, 2020 can be directly determined as the above-mentioned specified reuse rate curve. However, on June 10, 2020, assuming that starting from 00:00, each time an I / O request for requesting a target data block is detected, the above-mentioned total number of accessed data blocks and the number of repeatedly accessed data blocks of the target data block need to be updated, and the current latest total number of accessed data blocks and the number of repeatedly accessed data blocks of the target data block are obtained once every cycle (for example, 1 hour), and the current latest total number of accessed data blocks and the number of repeatedly accessed data blocks are calculated according to the reuse rate function to obtain the reuse rate in the time interval before the current system time t1 (i.e., t1-00:00), thereby updating the reuse rate curve based on the reuse rate in the time interval before the current system time t1. As time goes by, the reuse rates at different time intervals can be obtained according to the same method, and a reuse rate curve representing the reuse rates at different time intervals can be drawn. Assuming that t1 is 4 hours, the reuse rates at time intervals of 4 hours, 8 hours, 12 hours, 16 hours, 20 hours and 24 hours can be determined in turn according to the above method, and the reuse rate curve is updated after the reuse rates at different time intervals are determined, and a reuse rate curve representing the reuse rates at time intervals of 4 hours, 8 hours, 12 hours, 16 hours, 20 hours and 24 hours is obtained.
[0104] Furthermore, after the reuse rate curve for June 10, 2020 is drawn, the reuse rate curve for June 9, 2020 can be used to replace the reuse rate curve for June 9, 2020. Subsequently, on the next day (i.e., June 11, 2020), the reuse rate curve for June 10, 2020 can be directly used to calculate the data block reuse distance.
[0105] For example, the reuse rate function may be RAR(t, τ) = RC / TC, where t is the start time and τ is the time interval, and RAR(t, τ) represents the reuse rate within the time interval τ starting from time t. Assuming that the target data block accessed by this I / O request is data block B, the reuse rate calculation method for data block B can be found in Figure 5a As shown, first, we can detect whether the hash map includes the historical information of data block B. If the hash map contains the historical information of data block B, it means that data block B is a repeated access data block, and the repeated access counter (RC) corresponding to the data block is incremented by 1, otherwise it is not incremented. For each I / O request, the total access counter (TC) is incremented by 1. Finally, the reuse rate is obtained by RC / TC.
[0106] See also Figure 5b, shows a statistical flow chart of a cache hit rate curve. Assuming that the target data block accessed by the I / O request currently detected in S301 is data block B, and the current time is t1, after detecting the I / O request, the historical information of data block B can be obtained from the hash map. The historical information includes the time lt( Figure 5b In the equation (1.3), the reuse rate of data block B in the time interval τ = t1-lt is determined according to (lt(B))) and the block sequence number lc corresponding to the last access to the target data block. Further, the total number of accessed data blocks T(t, τ) from the last access time lt to the current time t1 is determined. Here, τ in T(t, τ) = t1-lt, t = lt. According to the above formula 1.3, the reuse rate of data block B in the time interval τ = t1-lt is determined ( Figure 5b Furthermore, the reuse distance distribution of the last moment can be updated in real time based on the reuse distance of the data block B to obtain the reuse distance distribution of the current moment, and the cache hit rate curve can be calculated based on the reuse distance distribution of the current moment.
[0107] The embodiment of the present application can determine the cache hit rate curve of each storage node at the current moment according to the I / O request detected at the current moment, and when the cache processing conditions are met, determine the target cache configuration scheme based on the cache hit rate curve of each storage node at the latest moment, and adjust the cache space size of the cache instance corresponding to each storage node according to the size of the cache space to be allocated of each storage node indicated by the target cache configuration scheme. In this way, the cache hit rate curve of each storage node can be analyzed in real time according to the I / O request, and the best cache configuration scheme can be searched based on the cache hit rate curve of each storage node, and the cache space of each cache instance can be dynamically adjusted, which is conducive to realizing the on-demand allocation of cache space and effectively improving cache utilization.
[0108] An embodiment of the present application further provides a computer storage medium, in which program instructions are stored. When the program instructions are executed, they are used to implement the corresponding methods described in the above embodiments.
[0109] See also Figure 6 , is a schematic diagram of the structure of a cache processing device according to an embodiment of the present application. The cache processing device according to the embodiment of the present application can be arranged in a cache system (see Figure 2a and Figure 2b ) in a cache processing device, the device comprising:
[0110] The processing unit 60 is used to determine the cache hit rate curve of each storage node at the current moment according to the I / O request detected at the current moment;
[0111] The processing unit 60 is further configured to determine a target cache configuration scheme based on a cache hit rate curve of each storage node at the latest moment when the cache processing condition is met, wherein the target cache configuration scheme is a cache configuration scheme that enables each storage node to achieve an optimization target, and the target cache configuration scheme indicates a cache space size to be allocated for each storage node;
[0112] The adjusting unit 61 is configured to adjust the cache space size of the cache instance corresponding to each storage node according to the cache space size to be allocated for each storage node indicated by the target cache configuration scheme.
[0113] In one implementation of the device of the embodiment of the present application, the device includes the following structure.
[0114] In one embodiment, the processing unit 60 is specifically used to update the access statistics according to the I / O request detected at the current moment, update the reuse distance distribution at the previous moment according to the updated access statistics, obtain the reuse distance distribution at the current moment, and determine the cache hit rate curve of each storage node at the current moment based on the pre-built cache model and the reuse distance distribution at the current moment. The reuse distance distribution at the current moment characterizes the distribution of reuse distances of each data block accessed by all I / O requests before the current moment, and the previous moment is the moment when the I / O request was last detected.
[0115] In one embodiment, an I / O request is used to access a target data block, where the target data block is any data block included in each storage node. The processing unit 60 is further specifically used to determine the total number of accessed data blocks from the last access time lt to the current time t1 of the target data block based on the updated access statistics, and to find the target reuse rate under the target time interval from the specified reuse rate curve, where the target time interval is t1-lt, and the specified reuse rate curve represents the corresponding relationship between each time interval and the reuse rate; according to the reuse distance function, the total number of accessed data blocks and the target reuse rate of the target data block from the last access time lt to the current time t1 are calculated to obtain the reuse distance of the target data block, and based on the reuse distance of the target data block, the reuse distance distribution at the previous moment is updated to obtain the reuse distance distribution at the current moment.
[0116] In one embodiment, the access statistics information includes the total number of accessed data blocks. The processing unit 60 is further specifically used to obtain the time lt of the last access to the target data block and the block sequence number corresponding to the last access to the target data block from the historical information if it is detected that the hash map includes historical information of the target data block, and subtract the updated total number of accessed data blocks from the block sequence number to obtain the total number of accessed data blocks from the last access time lt to the current time t1 of the target data block.
[0117] In one embodiment, the processing unit 60 is further specifically used to determine the cache hit rate of each storage node at the current moment under each cache space size according to a pre-built cache model and the reuse distance distribution at the current moment, and generate a cache hit rate curve of each storage node at the current moment based on the cache hit rate of each storage node at the current moment under each cache space size.
[0118] In one embodiment, the access statistics include the access traffic of each storage node, and the cache hit rate curve of each storage node represents the corresponding relationship between the cache hit rate of each storage node and the cache space size. The processing unit 60 is also specifically used to search for the target cache hit rate of each storage node when the total hit traffic of each storage node is maximized according to the access traffic of each storage node, and the total hit traffic is the sum of the products of the access traffic and the cache hit rate of each storage node; the cache space size corresponding to the target cache hit rate of each storage node in the cache hit rate curve of each storage node at the latest moment is determined as the cache space size to be allocated for each storage node, and a target cache configuration plan is generated based on the cache space size to be allocated for each storage node.
[0119] In one embodiment, the processing unit 60 is further specifically used to search the cache hit rate curve of each storage node at the latest moment through a target recursive formula so that the total hit flow of each storage node is maximized, and to generate a target cache configuration plan based on the cache space to be allocated of each storage node.
[0120] In one embodiment, the access statistics include the total number of accessed data blocks, the number of repeatedly accessed data blocks and the access traffic of each storage node. The processing unit 60 is also specifically used to increase the total number of accessed data blocks by a specified value according to the I / O request detected at the current moment. If it is detected that the hash map includes historical information of the target data block, the number of repeatedly accessed data blocks is increased by a specified value, the access traffic corresponding to the I / O request is obtained, and the access traffic of the storage node corresponding to the target data block is updated according to the access traffic.
[0121] In one embodiment, the processing unit 60 is also used to obtain the total number of accessed data blocks and the number of repeatedly accessed data blocks at different time intervals, calculate the total number of accessed data blocks and the number of repeatedly accessed data blocks at different time intervals according to the reuse rate function, obtain the reuse rate at different time intervals, generate a reuse rate curve based on the reuse rate at different time intervals, and when it is detected that the reuse rate curve update condition is met, replace the specified reuse rate curve with the reuse rate curve.
[0122] In one embodiment, each cache instance is used to manage cache data of a corresponding storage node, and the cache data is stored in a cache block. The adjustment unit 61 is specifically used to release the cache block storing the target cache data if it is determined according to the indication of the target cache configuration scheme that the size of the cache space to be allocated of the target storage node is smaller than the actual cache space size of the target storage node, and the target cache data is the cache data managed by the cache instance corresponding to the target storage node;
[0123] If it is determined according to the target cache configuration scheme that the size of the cache space to be allocated of the target storage node is larger than the actual cache space size of the target storage node, a new cache block is allocated to the cache instance corresponding to the target storage node; wherein the target storage node is any one of the storage nodes.
[0124] In the embodiments of the present application, the specific implementation of each of the above-mentioned units can refer to the description of the relevant contents in the embodiments corresponding to the aforementioned figures.
[0125] The cache processing device in the embodiment of the present application can determine the cache hit rate curve of each storage node at the current moment according to the I / O request detected at the current moment, and when the cache processing conditions are met, determine the target cache configuration scheme based on the cache hit rate curve of each storage node at the latest moment, and adjust the cache space size of the cache instance corresponding to each storage node according to the size of the cache space to be allocated of each storage node indicated by the target cache configuration scheme. In this way, the cache hit rate curve of each storage node can be analyzed in real time according to the I / O request, and the best cache configuration scheme can be searched based on the cache hit rate curve of each storage node, and the cache space of each cache instance can be dynamically adjusted, which is conducive to the on-demand allocation of cache space and effectively improves cache utilization.
[0126] See also Figure 7 , is a schematic diagram of the structure of a cache processing device according to an embodiment of the present application, wherein the cache processing device is deployed with a cache system (see Figure 2a and Figure 2b ), the cache processing device may be, for example, a cache server for providing cache services. The cache processing of the embodiment of the present application includes a power supply module and other structures, and includes a processor 70, a storage device 71, and a communication interface 72. The processor 70, the storage device 71, and the communication interface 72 can exchange data, and the processor 70 implements the corresponding cache processing function.
[0127] The storage device 71 may include a volatile memory (volatile memory), such as a random-access memory (RAM); the storage device 71 may also include a non-volatile memory (non-volatile memory), such as a flash memory, a solid-state drive (SSD), etc.; the storage device 71 may also include a combination of the above-mentioned types of memory.
[0128] The processor 70 may be a central processing unit (CPU) 70. In one embodiment, the processor 70 may also be a graphics processing unit (GPU) 70. The processor 70 may also be a combination of a CPU and a GPU. In the cache processing device, multiple CPUs and GPUs may be included as needed to perform corresponding cache processing.
[0129] In one embodiment, the storage device 71 is used to store program instructions. The processor 70 can call the program instructions to implement the various methods involved in the embodiments of the present application.
[0130] In a first possible implementation, the processor 70 of the cache processing device calls the program instructions stored in the storage device 71 to detect I / O requests through the communication interface 72, and determine the cache hit rate curve of each storage node at the current moment according to the I / O requests detected at the current moment; when the cache processing conditions are met, determine the target cache configuration scheme based on the cache hit rate curve of each storage node at the latest moment, and the target cache configuration scheme is a cache configuration scheme that enables each storage node to achieve the optimization goal, and the target cache configuration scheme indicates the size of the cache space to be allocated for each storage node; according to the size of the cache space to be allocated for each storage node indicated by the target cache configuration scheme, adjust the cache space size of the cache instance corresponding to each storage node.
[0131] In one embodiment, the processor 70 is specifically used to update access statistics according to the I / O request detected by the communication interface 72 at the current moment, update the reuse distance distribution at the previous moment according to the updated access statistics, obtain the reuse distance distribution at the current moment, and determine the cache hit rate curve of each storage node at the current moment based on the pre-built cache model and the reuse distance distribution at the current moment. The reuse distance distribution at the current moment characterizes the distribution of reuse distances of each data block accessed by all I / O requests before the current moment, and the previous moment is the moment when the I / O request was last detected.
[0132] In one embodiment, an I / O request is used to access a target data block, where the target data block is any data block included in each storage node. The processor 70 is further specifically used to determine the total number of accessed data blocks from the last access time lt to the current time t1 of the target data block based on the updated access statistics, and to find the target reuse rate under the target time interval from the specified reuse rate curve, where the target time interval is t1-lt, and the specified reuse rate curve represents the corresponding relationship between each time interval and the reuse rate; according to the reuse distance function, the total number of accessed data blocks and the target reuse rate of the target data block from the last access time lt to the current time t1 are calculated to obtain the reuse distance of the target data block, and based on the reuse distance of the target data block, the reuse distance distribution at the previous moment is updated to obtain the reuse distance distribution at the current moment.
[0133] In one embodiment, the access statistics information includes the total number of accessed data blocks. The processor 70 is further specifically used to obtain the time lt of the last access to the target data block and the block sequence number corresponding to the last access to the target data block from the historical information if it is detected that the hash map includes historical information of the target data block, and subtract the updated total number of accessed data blocks from the block sequence number to obtain the total number of accessed data blocks from the last access time lt to the current time t1 of the target data block.
[0134] In one embodiment, the processor 70 is further specifically used to determine the cache hit rate of each storage node at the current moment under each cache space size according to a pre-built cache model and the reuse distance distribution at the current moment, and generate a cache hit rate curve of each storage node at the current moment based on the cache hit rate of each storage node at the current moment under each cache space size.
[0135] In one embodiment, the access statistics include the access traffic of each storage node, and the cache hit rate curve of each storage node represents the corresponding relationship between the cache hit rate of each storage node and the cache space size. The processor 70 is also specifically used to search for the target cache hit rate of each storage node when the total hit traffic of each storage node is maximized according to the access traffic of each storage node, and the total hit traffic is the sum of the products of the access traffic and the cache hit rate of each storage node; the cache space size corresponding to the target cache hit rate of each storage node in the cache hit rate curve of each storage node at the latest moment is determined as the cache space size to be allocated for each storage node, and a target cache configuration plan is generated based on the cache space size to be allocated for each storage node.
[0136] In one embodiment, the processor 70 is further specifically used to search the cache space size to be allocated of each storage node when the total hit flow of each storage node is maximized through the target recursive formula and the cache hit rate curve of each storage node at the latest moment, and generate a target cache configuration plan based on the cache space size to be allocated of each storage node.
[0137] In one embodiment, the access statistics include the total number of accessed data blocks, the number of repeatedly accessed data blocks and the access traffic of each storage node. The processor 70 is further specifically used to increase the total number of accessed data blocks by a specified value according to the I / O request detected at the current moment. If it is detected that the hash map includes historical information of the target data block, the number of repeatedly accessed data blocks is increased by a specified value, the access traffic corresponding to the I / O request is obtained, and the access traffic of the storage node corresponding to the target data block is updated according to the access traffic.
[0138] In one embodiment, the processor 70 is further used to obtain the total number of accessed data blocks and the number of repeatedly accessed data blocks at different time intervals, calculate the total number of accessed data blocks and the number of repeatedly accessed data blocks at different time intervals according to the reuse rate function, obtain the reuse rate at different time intervals, generate a reuse rate curve based on the reuse rate at different time intervals, and replace the specified reuse rate curve with the reuse rate curve when it is detected that the reuse rate curve update condition is met.
[0139] In one embodiment, each cache instance is used to manage cache data of a corresponding storage node, and the cache data is stored in a cache block. The processor 70 is further used to release the cache block storing the target cache data if it is determined according to the instruction of the target cache configuration scheme that the size of the cache space to be allocated of the target storage node is smaller than the actual cache space size of the target storage node, and the target cache data is the cache data managed by the cache instance corresponding to the target storage node;
[0140] If it is determined according to the target cache configuration scheme that the size of the cache space to be allocated of the target storage node is larger than the actual cache space size of the target storage node, a new cache block is allocated to the cache instance corresponding to the target storage node; wherein the target storage node is any one of the storage nodes.
[0141] In the embodiment of the present application, the specific implementation of the above-mentioned processor 70 can refer to the description of the relevant contents in the embodiments corresponding to the aforementioned figures.
[0142] The cache processing device in the embodiment of the present application can determine the cache hit rate curve of each storage node at the current moment according to the I / O request detected at the current moment, and when the cache processing conditions are met, determine the target cache configuration scheme based on the cache hit rate curve of each storage node at the latest moment, and adjust the cache space size of the cache instance corresponding to each storage node according to the size of the cache space to be allocated of each storage node indicated by the target cache configuration scheme. In this way, the cache hit rate curve of each storage node can be analyzed in real time according to the I / O request, and the best cache configuration scheme can be searched based on the cache hit rate curve of each storage node, and the cache space of each cache instance can be dynamically adjusted, which is conducive to the on-demand allocation of cache space and effectively improves cache utilization.
[0143] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0144] The above disclosure is only part of the embodiments of the present application, which certainly cannot be used to limit the scope of rights of the present application. Ordinary technicians in this field can understand that all or part of the processes of implementing the above embodiments and making equivalent changes according to the claims of this application are still within the scope of the invention.
Claims
1. A cache system, characterized in that: It includes a cache control module, a cache analysis module and at least one cache instance, each cache instance provides data cache services for its corresponding storage node, wherein: The cache analysis module is used to determine the cache hit rate curve of each storage node at the current moment according to the I / O request detected at the current moment, and when the cache processing condition is met, determine the target cache configuration scheme based on the cache hit rate curve of each storage node at the latest moment, and synchronize the target cache configuration scheme to the cache control module, the target configuration scheme is a cache configuration scheme that enables each storage node to achieve the optimization target, and the target cache configuration scheme indicates the size of the cache space to be allocated for each storage node; The cache control module is used to adjust the cache space size of the cache instance corresponding to each storage node according to the cache space size to be allocated of each storage node indicated by the target cache configuration scheme; Each storage node includes a data block for storing data, and the cache analysis module includes an I / O request statistics module, a cache modeling module and a search module, wherein: The I / O request statistics module is used to update access statistics information according to the currently detected I / O requests; The cache modeling module is used to update the reuse distance distribution of the previous moment according to the updated access statistics to obtain the reuse distance distribution of the current moment, and determine the cache hit rate curve of each storage node at the current moment based on the pre-built cache model and the reuse distance distribution of the current moment, wherein the reuse distance distribution at the current moment characterizes the distribution of reuse distances of each data block accessed by all I / O requests before the current moment, and the previous moment is the moment when the I / O request was last detected; The search module is used to search for a target cache configuration scheme that enables each storage node to achieve an optimization target based on a cache hit rate curve of each storage node at a latest moment when a cache processing condition is met.
2. The system according to claim 1, characterized in that The cache system is deployed in a cloud block storage system, which also includes a client and a storage system. The storage system includes at least one storage node, each storage node corresponds to a cache instance in the at least one cache instance, each cache instance is used to manage cache data of the corresponding storage node, and the I / O request is a read and write request from the client.
3. A cache processing method, characterized in that: Applied to a cache system, the cache system includes a cache control module, a cache analysis module and at least one cache instance, each cache instance provides data cache services for its corresponding storage node, the method includes: According to the I / O request detected at the current moment, determine the cache hit rate curve of each storage node at the current moment; When the cache processing conditions are met, a target cache configuration scheme is determined based on the cache hit rate curve of each storage node at the latest moment, wherein the target cache configuration scheme is a cache configuration scheme that enables each storage node to achieve the optimization target, and the target cache configuration scheme indicates the size of the cache space to be allocated for each storage node; According to the cache space size to be allocated of each storage node indicated by the target cache configuration scheme, adjust the cache space size of the cache instance corresponding to each storage node; Each storage node includes a data block for storing data, and determining a cache hit rate curve of each storage node at the current moment according to an I / O request detected at the current moment includes: Update access statistics based on the I / O requests detected at the current moment; Update the reuse distance distribution of the previous moment according to the updated access statistics to obtain the reuse distance distribution of the current moment, wherein the reuse distance distribution of the current moment represents the distribution of reuse distances of each data block accessed by all I / O requests before the current moment, and the previous moment is the moment when the I / O request was last detected; A cache hit rate curve of each storage node at the current moment is determined based on a pre-built cache model and the reuse distance distribution at the current moment.
4. The method according to claim 3, characterized in that The I / O request is used to access a target data block, and the target data block is any data block included in each storage node. The method updates the reuse distance distribution at a previous moment according to the updated access statistics information to obtain the reuse distance distribution at a current moment, including: Determine the total number of accessed data blocks of the target data block from the last access time lt to the current time t1 based on the updated access statistics information; Finding a target reuse rate at a target time interval from a specified reuse rate curve, wherein the target time interval is t1-lt, and the specified reuse rate curve represents a corresponding relationship between each time interval and the reuse rate; Calculating the total number of accessed data blocks and the target reuse rate of the target data block from the last access time lt to the current time t1 according to the reuse distance function to obtain the reuse distance of the target data block; The reuse distance distribution at the previous moment is updated based on the reuse distance of the target data block to obtain the reuse distance distribution at the current moment.
5. The method according to claim 4, characterized in that The access statistics information includes the total number of accessed data blocks, and determining the total number of accessed data blocks of the target data block from the time lt when the target data block was last accessed to the current time t1 based on the updated access statistics information includes: If it is detected that the hash map includes historical information of the target data block, the time lt of the last access to the target data block and the block sequence number corresponding to the last access to the target data block are obtained from the historical information; The updated total number of accessed data blocks is subtracted from the block sequence number to obtain the total number of accessed data blocks of the target data block from the time lt when the target data block was last accessed to the current time t1.
6. The method according to claim 4, characterized in that The determining of the cache hit rate curve of each storage node at the current moment based on the pre-built cache model and the reuse distance distribution at the current moment includes: Determine the cache hit rate of each storage node at each cache space size at the current moment according to the pre-built cache model and the reuse distance distribution at the current moment; Based on the cache hit rates of each storage node at each cache space size at the current moment, a cache hit rate curve of each storage node at the current moment is generated.
7. The method according to claim 3, characterized in that The access statistics information includes the access traffic of each storage node, the cache hit rate curve of each storage node represents the corresponding relationship between the cache hit rate of each storage node and the cache space size, and the target cache configuration scheme is determined based on the cache hit rate curve of each storage node at the latest moment, including: The target cache hit rate of each storage node when the total hit rate of each storage node is maximized according to the access traffic of each storage node, wherein the total hit traffic is the sum of the products of the access traffic of each storage node and the cache hit rate; Determine the cache space size corresponding to the target cache hit rate of each storage node in the cache hit rate curve of each storage node at the latest moment as the cache space size to be allocated for each storage node; A target cache configuration scheme is generated based on the cache space size to be allocated of each storage node.
8. The method according to claim 3, characterized in that The determining, based on the cache hit rate curve of each storage node at the latest moment, a target cache configuration scheme when each storage node reaches the optimization target comprises: The size of the cache space to be allocated for each storage node when the total hit flow of each storage node is maximized by searching the target recursive formula and the cache hit rate curve of each storage node at the latest moment; A target cache configuration scheme is generated based on the cache space size to be allocated of each storage node.
9. The method according to claim 3, characterized in that: The access statistics information includes the total number of accessed data blocks, the number of repeatedly accessed data blocks, and the access flow of each storage node, and the updating of the access statistics information according to the I / O request detected at the current moment includes: Increasing the total number of accessed data blocks by a specified value according to the I / O request detected at the current moment; If it is detected that the hash map includes the historical information of the target data block, the number of repeatedly accessed data blocks is increased by the specified value; The access flow corresponding to the I / O request is obtained, and the access flow of the storage node corresponding to the target data block is updated according to the access flow.
10. The method according to claim 9, characterized in that The method further comprises: Get the total number of accessed data blocks and the number of repeatedly accessed data blocks at different time intervals; Calculating the total number of accessed data blocks and the number of repeatedly accessed data blocks at different time intervals according to the reuse rate function to obtain the reuse rates at different time intervals; generating a reuse rate curve based on the reuse rates at the different time intervals; When it is detected that a re-use rate curve update condition is satisfied, the designated re-use rate curve is replaced by the re-use rate curve.
11. The method according to claim 3, characterized in that Each cache instance is used to manage cache data of a corresponding storage node, the cache data is stored through a cache block, and the cache space size of each storage node corresponding to the cache instance is adjusted according to the cache space size to be allocated of each storage node indicated by the target cache configuration scheme, including: If it is determined according to the indication of the target cache configuration scheme that the size of the cache space to be allocated of the target storage node is smaller than the actual cache space size of the target storage node, the cache block storing the target cache data is released, and the target cache data is the cache data managed by the cache instance corresponding to the target storage node; If it is determined according to the instruction of the target cache configuration scheme that the cache space size to be allocated of the target storage node is larger than the actual cache space size of the target storage node, a new cache block is allocated to the cache instance corresponding to the target storage node; The target storage node is any one of the storage nodes.
12. A cache processing device, characterized in that: The device includes: A processing unit, configured to determine a cache hit rate curve of each storage node at the current moment according to the I / O request detected at the current moment; The processing unit is further configured to determine a target cache configuration scheme based on a cache hit rate curve of each storage node at a latest moment when a cache processing condition is met, wherein the target cache configuration scheme is a cache configuration scheme that enables each storage node to achieve an optimization target, and the target cache configuration scheme indicates a size of a cache space to be allocated for each storage node; an adjusting unit, configured to adjust the cache space size of the cache instance corresponding to each storage node according to the cache space size to be allocated of each storage node indicated by the target cache configuration scheme; Each storage node includes a data block for storing data, and the processing unit is specifically used for: Update access statistics based on the I / O requests detected at the current moment; Update the reuse distance distribution of the previous moment according to the updated access statistics to obtain the reuse distance distribution of the current moment, wherein the reuse distance distribution of the current moment represents the distribution of reuse distances of each data block accessed by all I / O requests before the current moment, and the previous moment is the moment when the I / O request was last detected; A cache hit rate curve of each storage node at the current moment is determined based on a pre-built cache model and the reuse distance distribution at the current moment.
13. A cache processing device, characterized in that: The cache processing device includes a processor and a storage device, which are connected to each other, wherein the storage device is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method as described in any one of claims 3-11.
