A data caching method and apparatus, an electronic device, and a computer readable medium
By monitoring the I/O latency of the front-end host and the back-end hard drive, and dynamically adjusting the disk write concurrency, the problem of uneven latency caused by differences in write cache pressure was solved, thus improving the performance and efficiency of data caching.
Patent Information
- Application Number
- CN202311616452.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-29
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-11-29
AI Technical Summary
In centralized storage systems, differences in write cache pressure lead to uneven disk write latency on the backend hard drives, affecting frontend host latency and data cache performance.
By monitoring the I/O latency of the front-end host and the back-end hard drive, the disk write concurrency is dynamically adjusted according to the cache pressure to achieve the target I/O latency and optimize cache operations and disk write operations.
It improves the performance of data caching, ensures that the latency of the front-end host and the back-end hard drive is within the normal range, and maximizes the utilization of the back-end hard drive's processing capacity.
Smart Images

Figure CN117743198B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data caching technology, and in particular to a data caching method, apparatus, electronic device, and computer-readable medium. Background Technology
[0002] In the design of centralized storage systems, during the process of writing data to hard disk devices, the data is temporarily stored in a cache according to certain rules. This part used to temporarily store user data is called the write cache. The write cache provides a reservoir-like function in centralized storage systems. This mechanism adds a buffer layer between the front-end host where the user resides and the back-end hard disk. The user only needs to write the data into memory to return a successful write. In memory, the data that needs to be written to the hard disk is asynchronously written to the hard disk according to a certain strategy. However, during the process of writing data to the hard disk, there are different cache pressures in the write cache. Different cache pressures will cause differences in the data write latency on the back-end hard disk. When the write latency of the back-end hard disk is large, it will affect the latency of the front-end host and also affect the performance of the data cache. Summary of the Invention
[0003] In view of this, this application aims to propose a data caching method, apparatus, electronic device, and computer-readable medium that can determine different disk write concurrency levels according to different cache pressures, and adjust the concurrency level through feedback adjustment of the first IO delay of the front-end host and the second IO delay of the back-end hard disk, thereby improving the performance of data caching.
[0004] A first aspect of this application provides a data caching method, the method comprising:
[0005] When a write instruction to the target cache is received, the cache pressure at the current moment is obtained;
[0006] Based on the cache pressure, a preset disk write concurrency is determined, and the disk write concurrency of the cache is set based on the preset disk write concurrency.
[0007] Monitor the first I / O latency of the front-end host and the second I / O latency of the back-end hard drive;
[0008] The disk write concurrency of the cache is adjusted at least once based on the first IO latency and the second IO latency, so that the first IO latency reaches the first target IO latency and the second IO latency reaches the second target IO latency;
[0009] Based on the adjusted disk write concurrency, cache operations and disk write operations are performed on the data corresponding to the target write cache instruction.
[0010] In one embodiment, the preset adjustment includes a first preset adjustment and a second preset adjustment, wherein the step of performing at least one preset adjustment on the disk write concurrency of the cache based on the first IO delay and the second IO delay includes:
[0011] When the first IO delay is greater than the first preset IO delay or the second IO delay is greater than the second preset IO delay, the disk write concurrency of the cache is reduced by at least one first preset adjustment so that the first IO delay reaches the first target IO delay and the second IO delay reaches the second target IO delay;
[0012] When the first IO latency is less than the first preset IO latency and the second IO latency is less than the second preset IO latency, the disk write concurrency of the cache is increased by at least one second preset adjustment so that the first IO latency reaches the first target IO latency and the second IO latency reaches the second target IO latency;
[0013] Wherein, the first preset adjustment is used to reduce the disk write concurrency of the cache by a first preset concurrency, and the second preset adjustment is used to increase the disk write concurrency of the cache by a second preset concurrency.
[0014] In one implementation, determining a preset disk write concurrency based on the cache pressure, and setting the disk write concurrency of the cache based on the preset disk write concurrency, includes:
[0015] When the cache pressure is less than a first threshold, the preset disk write concurrency is determined to be a first preset disk write concurrency, and the disk write concurrency of the cache is set to the first preset disk write concurrency. The cache pressure being less than the first threshold indicates that the processing capacity of the backend hard disk can meet the cache pressure.
[0016] When the cache pressure is not less than the first threshold and less than the second threshold, the preset disk write concurrency is determined to be the second preset disk write concurrency, and the cache disk write concurrency is set to the second preset disk write concurrency. The cache pressure being not less than the first threshold and less than the second threshold indicates that the processing capacity of the backend hard disk needs to be improved to cope with the cache pressure.
[0017] When the cache pressure is not less than the second threshold, the preset disk write concurrency is determined to be the third preset disk write concurrency, and the disk write concurrency of the cache is set to the third preset disk write concurrency. The cache pressure not less than the second threshold indicates that the processing capacity of the back-end hard disk needs to reach its limit to cope with the cache pressure.
[0018] Wherein, the first threshold is less than the second threshold, the first preset disk write concurrency is less than the second preset disk write concurrency, and the second preset disk write concurrency is less than the third preset disk write concurrency.
[0019] In one implementation, when the cache pressure is not less than the first threshold and less than the second threshold, determining the preset disk write concurrency as the second preset disk write concurrency includes:
[0020] When the cache pressure is not less than the first threshold and less than the second threshold, the second preset disk write concurrency corresponding to the cache pressure is calculated, wherein the cache pressure is proportional to the second preset disk write concurrency.
[0021] In one embodiment, the method further includes:
[0022] When the cache pressure reaches the third threshold, the cache mechanism is turned off.
[0023] Set the disk write concurrency of the cache to the fourth preset disk write concurrency;
[0024] Wherein, the third threshold is greater than the second threshold, and the fourth preset disk placement concurrency is greater than the first preset disk placement concurrency.
[0025] In one implementation, after the cache write-to-disk concurrency is set to the fourth preset write-to-disk concurrency, the method further includes:
[0026] The data corresponding to the target write cache instruction is directly written to disk.
[0027] In one embodiment, the method further includes:
[0028] After performing a caching operation on the data corresponding to the target write cache instruction, a first response message is sent to the front-end host;
[0029] After performing a write-to-disk operation on the data corresponding to the target write cache instruction, a second response message is sent to the cache.
[0030] A second aspect of this application provides a data caching device, the device comprising:
[0031] The cache pressure acquisition module is used to obtain the cache pressure at the current moment when a target write cache instruction is received;
[0032] The disk write concurrency setting module is used to determine a preset disk write concurrency based on the cache pressure, and set the disk write concurrency of the cache based on the preset disk write concurrency.
[0033] The monitoring module is used to monitor the first I / O latency of the front-end host and the second I / O latency of the back-end hard drive;
[0034] The adjustment module is used to perform at least one preset adjustment on the disk write concurrency of the cache based on the first IO delay and the second IO delay, so that the first IO delay reaches the first target IO delay and the second IO delay reaches the second target IO delay;
[0035] The operation module is used to perform caching and disk write operations on the data corresponding to the target write cache instruction based on the adjusted disk write concurrency.
[0036] A third aspect of this application provides an electronic device including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method described in the first aspect.
[0037] A fourth aspect of this application provides a computer-readable medium having a computer program / instructions stored thereon, which, when executed by a processor, implements the method described in the first aspect.
[0038] This application has the following advantages and positive effects:
[0039] This application provides a data caching method, apparatus, electronic device, and computer-readable medium. The method includes: upon receiving a target write cache instruction, obtaining the cache pressure at the current moment; determining a preset disk write concurrency based on the cache pressure, and setting the disk write concurrency of the cache based on the preset disk write concurrency; monitoring a first I / O latency of the front-end host and a second I / O latency of the back-end hard drive; performing at least one preset adjustment on the disk write concurrency of the cache based on the first I / O latency and the second I / O latency, so that the first I / O latency reaches a first target I / O latency and the second I / O latency reaches a second target I / O latency; and performing caching and disk write operations on the data corresponding to the target write cache instruction based on the adjusted disk write concurrency. This method can determine different disk write concurrency based on different cache pressures and adjust the concurrency through feedback adjustment using the first I / O latency of the front-end host and the second I / O latency of the back-end hard drive, thereby achieving the technical effect of improving data caching performance. Attached Figure Description
[0040] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.
[0041] To more clearly illustrate the technical solution of this application, the drawings used in the description of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a schematic diagram of data caching and disk persistence in a data caching method provided in an embodiment of this application;
[0043] Figure 2 This is a flowchart of a data caching method provided in an embodiment of this application;
[0044] Figure 3 This is a flowchart of a disk write concurrency adjustment mechanism in a data caching method provided in an embodiment of this application;
[0045] Figure 4 This is a schematic diagram of the framework of a data caching device provided in an embodiment of this application. Detailed Implementation
[0046] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other.
[0047] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0048] Figure 1 This is a schematic diagram of data caching and disk persistence in a data caching method provided in an embodiment of this application, as shown below. Figure 1 As shown, in the design of a centralized storage system, when users need to write data to the disk device, the data is temporarily stored in memory according to certain rules. This part used to temporarily store user data is called the cache. The cache provides a buffer-like function in the centralized storage system, adding a buffer layer between the user and the disk. The user only needs to write data to the cache to receive a successful write response. Afterwards, the data in the cache is written to the hard drive according to a certain strategy; this process is called data persistence. The design of the cache offers the following advantages:
[0049] 1. Since the access speed of the cache is much faster than that of the hard disk, the WCA design allows users to get a response as soon as they write data to the cache, without having to wait for the data to be written to disk. This allows user requests to receive a system response much faster.
[0050] 2. A certain amount of data can be temporarily stored in the cache. When user write requests suddenly increase, the cache can withstand some of the write pressure, temporarily relieving the pressure on the hard drive and ensuring that the system's write performance is not limited by the hard drive's write speed bottleneck to a certain extent.
[0051] 3. If a user performs multiple write operations to a certain address, the cache uses a certain replacement algorithm to ensure that these write operations all occur in the cache. Only the final result needs to be written to disk, which reduces the number of write operations to the backend hard drive. This can greatly improve performance in scenarios with high write IO hit rate.
[0052] However, during the process of writing data to the hard disk, there are different cache pressures in the write cache. Different cache pressures will cause differences in the data write latency on the back-end hard disk. When the write latency of the back-end hard disk is large, it will affect the latency of the front-end host and also affect the performance of the data cache. Therefore, this application provides a data caching method.
[0053] Figure 2 This is a flowchart of a data caching method provided in an embodiment of this application, such as... Figure 2 As shown in this embodiment, a data caching method is provided. The method includes:
[0054] In step S101, when a target write cache instruction is received, the cache pressure at the current moment is obtained;
[0055] In step S102, a preset disk write concurrency is determined based on the cache pressure, and the disk write concurrency of the cache is set based on the preset disk write concurrency.
[0056] In step S103, the first I / O latency of the front-end host and the second I / O latency of the back-end hard disk are monitored;
[0057] In step S104, the disk write concurrency of the cache is adjusted at least once based on the first IO delay and the second IO delay, so that the first IO delay reaches the first target IO delay and the second IO delay reaches the second target IO delay;
[0058] In step S105, based on the adjusted disk write concurrency, the data corresponding to the target write cache instruction is cached and written to disk.
[0059] First, in step S101, when a target write cache instruction is received, the cache pressure at the current moment is obtained. In this embodiment, the write cache disk write control adopts a watermark flushing strategy, where the watermark value represents the current usage percentage of the cache, i.e., the cache pressure. Therefore, when a target write cache instruction is received from the front-end host, it is necessary to obtain the cache pressure at the current moment and determine the current usage percentage of the cache.
[0060] Further, in step S102, a preset disk write concurrency is determined based on the cache pressure, and the disk write concurrency of the cache is set based on the preset disk write concurrency. In this embodiment, the disk write concurrency of the write cache is controlled by the cache pressure. Different cache pressures correspond to different preset disk write concurrency levels for the write cache. Therefore, after determining the cache pressure, the preset disk write concurrency of the write cache can be determined based on the cache pressure. The preset disk write concurrency is a write cache disk write concurrency preset according to different cache pressures, and the current cache disk write concurrency is further set to the size of the preset disk write concurrency. The preset disk write concurrency can adapt to the current cache pressure.
[0061] Further, in step S103, the first IO latency of the front-end host and the second IO latency of the back-end hard drive are monitored. In this embodiment, it is necessary to monitor the first IO latency of the front-end host and the second IO latency of the back-end hard drive in real time. The first IO latency represents the time it takes for the front-end host to receive a write cache response. When the front-end host has a large number of write cache tasks or the cache pressure is too high, the first IO latency will increase. The second IO latency represents the time it takes for the back-end hard drive to respond to the cache after writing to the disk. When the processing power of the back-end hard drive decreases or the cache pressure is too high, the second IO latency will increase. Therefore, after setting the current disk write concurrency of the cache to the preset disk write concurrency, it is necessary to further monitor the first IO latency of the front-end host and the second IO latency of the back-end hard drive to obtain the performance changes of the data cache in real time.
[0062] Furthermore, in step S104, the disk write concurrency of the cache is preset and adjusted at least once based on the first IO delay and the second IO delay, so that the first IO delay reaches the first target IO delay and the second IO delay reaches the second target IO delay. In this embodiment, since the preset disk write concurrency determined by cache pressure is a theoretical value, in practical applications, it is necessary to adjust the preset disk write concurrency according to the current front-end and back-end latency to ensure that the adjusted disk write concurrency keeps the front-end and back-end latency within a normal range. Therefore, after determining the first IO latency of the front-end host and the second IO latency of the back-end hard drive, it is determined whether the first IO latency of the front-end host and the second IO latency of the back-end hard drive are normal. If the first IO latency of the front-end host and the second IO latency of the back-end hard drive are not within the normal latency duration, the disk write concurrency of the cache is adjusted at least once. The preset adjustment can be to increase or decrease the disk write concurrency by one unit. After the disk write concurrency of the cache is adjusted at least once, the first IO latency of the front-end host reaches the first target IO latency, and the second IO latency of the back-end hard drive reaches the second target IO latency.
[0063] Finally, in step S105, based on the adjusted disk write concurrency, the data corresponding to the target write cache instruction is cached and written to disk. After adjustment, based on the adjusted disk write concurrency, the data corresponding to the target write cache instruction is cached and written to disk.
[0064] Through the above embodiments, when a target write cache instruction is received, the cache pressure at the current moment can be obtained. A preset disk write concurrency level is determined based on the cache pressure, and the disk write concurrency level is set based on this preset level. The first I / O latency of the front-end host and the second I / O latency of the back-end hard drive are monitored, and the disk write concurrency level is adjusted to ensure that the first I / O latency reaches the first target I / O latency and the second I / O latency reaches the second target I / O latency. Based on the adjusted disk write concurrency level, caching and disk write operations are performed on the data corresponding to the target write cache instruction. Thus, different disk write concurrency levels are determined based on different cache pressures, and the concurrency level is adjusted based on feedback from the latency of the front-end host and the latency of the back-end hard drive, thereby achieving the technical effect of improving data caching performance.
[0065] Optionally, the preset adjustment includes a first preset adjustment and a second preset adjustment, and step S104 includes:
[0066] When the first IO delay is greater than the first preset IO delay or the second IO delay is greater than the second preset IO delay, the disk write concurrency of the cache is reduced by at least one first preset adjustment so that the first IO delay reaches the first target IO delay and the second IO delay reaches the second target IO delay;
[0067] When the first IO latency is less than the first preset IO latency and the second IO latency is less than the second preset IO latency, the disk write concurrency of the cache is increased by at least one second preset adjustment so that the first IO latency reaches the first target IO latency and the second IO latency reaches the second target IO latency;
[0068] Wherein, the first preset adjustment is used to reduce the disk write concurrency of the cache by a first preset concurrency, and the second preset adjustment is used to increase the disk write concurrency of the cache by a second preset concurrency.
[0069] Figure 3 This is a flowchart of a disk persistence concurrency adjustment mechanism in a data caching method provided in an embodiment of this application, as shown below. Figure 3 As shown.
[0070] Specifically, this application embodiment provides a disk write concurrency adjustment mechanism based on front-end and back-end processing latency. The preset adjustment includes a first preset adjustment and a second preset adjustment. The first preset adjustment is a negative feedback adjustment, indicating that the latency of the current front-end host or the back-end hard disk is high, and the disk write concurrency can be appropriately reduced to improve the response time of new IO requests. It is used to reduce the disk write concurrency of the cache by the first preset concurrency. The first preset concurrency is one unit of disk write concurrency. That is, when the first IO latency or the second IO latency is high, the disk write concurrency of the cache is reduced according to the first preset adjustment. Specifically, when the first IO latency is greater than the first preset IO latency or the second IO latency is greater than the second preset IO latency, the disk write concurrency of the cache is reduced by at least one first preset adjustment so that the first IO latency reaches the first target IO latency and the second IO latency reaches the second target IO latency. For example, if the first preset concurrency is 16 IO units, then the disk write concurrency of the cache is reduced by 16 IO units through the first preset adjustment.
[0071] The second preset adjustment is a positive feedback adjustment, indicating that the current front-end and back-end latencies are relatively low, and the disk write concurrency can be appropriately increased to utilize the processing power of the back-end hard drive. This is used to increase the disk write concurrency of the cache by the second preset concurrency, which is one unit of disk write concurrency. When the first IO latency is less than the first preset IO latency and the second IO latency is less than the second preset IO latency, the disk write concurrency of the cache is increased by at least one second preset adjustment so that the first IO latency reaches the first target IO latency and the second IO latency reaches the second target IO latency. For example, if the second preset concurrency is 20 IOs, then the disk write concurrency of the cache is increased by 20 IOs through the second preset adjustment.
[0072] Preferably, the unit size of the first preset concurrency and the second preset concurrency can be the same or different, and can be set according to the actual situation. No specific limitation is made here.
[0073] Through the above embodiments, the cache disk write concurrency can be adjusted according to the first IO latency of the front-end host and the second IO latency of the back-end hard disk. This allows the adjusted cache disk write concurrency to maximize the processing capacity of the back-end hard disk while ensuring that the first IO latency of the front-end host and the second IO latency of the back-end hard disk are normal, thereby enabling the front-end IO requests to be responded to faster and improving the performance of read and write IO to a certain extent.
[0074] Optionally, step S102 includes:
[0075] When the cache pressure is less than a first threshold, the preset disk write concurrency is determined to be a first preset disk write concurrency, and the disk write concurrency of the cache is set to the first preset disk write concurrency. The cache pressure being less than the first threshold indicates that the processing capacity of the backend hard disk can meet the cache pressure.
[0076] When the cache pressure is not less than the first threshold and less than the second threshold, the preset disk write concurrency is determined to be the second preset disk write concurrency, and the cache disk write concurrency is set to the second preset disk write concurrency. The cache pressure being not less than the first threshold and less than the second threshold indicates that the processing capacity of the backend hard disk needs to be improved to cope with the cache pressure.
[0077] When the cache pressure is not less than the second threshold, the preset disk write concurrency is determined to be the third preset disk write concurrency, and the disk write concurrency of the cache is set to the third preset disk write concurrency. The cache pressure not less than the second threshold indicates that the processing capacity of the back-end hard disk needs to reach its limit to cope with the cache pressure.
[0078] Wherein, the first threshold is less than the second threshold, the first preset disk write concurrency is less than the second preset disk write concurrency, and the second preset disk write concurrency is less than the third preset disk write concurrency.
[0079] Specifically, in this embodiment, the write cache disk concurrency is controlled by the cache pressure. Different cache pressures correspond to different preset write cache disk concurrency. Therefore, after determining the cache pressure, the preset write cache disk concurrency can be determined through the cache pressure. The preset write cache disk concurrency is the write cache disk concurrency preset according to different cache pressures, and the current cache disk concurrency is further set to the preset write cache concurrency. The preset write cache concurrency can adapt to the current cache pressure.
[0080] Specifically, when the cache pressure is less than the first threshold, the preset disk write concurrency is set to the first preset disk write concurrency, and the cache write concurrency is set to the first preset disk write concurrency; when the cache pressure is not less than the first threshold and less than the second threshold, the preset disk write concurrency is set to the second preset disk write concurrency, and the cache write concurrency is set to the second preset disk write concurrency; when the cache pressure is not less than the second threshold, the preset disk write concurrency is set to the third preset disk write concurrency, and the cache write concurrency is set to the third preset disk write concurrency; the first threshold is less than the second threshold, the first preset disk write concurrency is less than the second preset disk write concurrency, and the second preset disk write concurrency is less than the third preset disk write concurrency.
[0081] For example, the first threshold can be 70% of the total cache space, and the first preset disk write concurrency is 1% of the maximum disk write concurrency. That is, when the cache pressure is less than 70% of the total cache space, the preset disk write concurrency is 1% of the maximum disk write concurrency. At this time, the processing capacity of the back-end hard drive can meet the current cache pressure. The second threshold can be 80% of the total cache space, and the second preset disk write concurrency is 50% of the maximum disk write concurrency. That is, when the cache pressure is greater than or equal to 70% of the total cache space and less than 80% of the total cache space, the preset disk write concurrency is 50% of the maximum disk write concurrency. At this time, in order to cope with the current cache pressure, the processing capacity of the back-end hard drive needs to be appropriately increased to meet the current cache pressure. The third preset disk write concurrency can be 100% of the maximum disk write concurrency. That is, when the cache pressure is greater than or equal to 80% of the total cache space, the preset disk write concurrency is 100% of the maximum disk write concurrency. At this time, the processing capacity of the back-end hard drive needs to reach its limit to meet the current cache pressure.
[0082] Through the above embodiments, different preset disk write concurrency can be determined according to different cache pressures to adapt to the current cache pressure and the processing capacity of the backend hard disk.
[0083] Optionally, when the cache pressure is not less than the first threshold and less than the second threshold, the preset disk write concurrency is determined as the second preset disk write concurrency, including:
[0084] When the cache pressure is not less than the first threshold and less than the second threshold, the second preset disk write concurrency corresponding to the cache pressure is calculated, wherein the cache pressure is proportional to the second preset disk write concurrency.
[0085] Specifically, when the cache pressure is not less than the first threshold and less than the second threshold, a second preset disk write concurrency can be set. For example, the second preset disk write concurrency corresponding to the current cache pressure can be calculated. The cache pressure is proportional to the second preset disk write concurrency. For instance, if the first threshold is 70% of the total cache space and the second threshold is 80% of the total cache space, when the cache pressure is greater than or equal to 70% of the total cache space and less than 80%, the higher the cache pressure, the higher the second preset disk write concurrency. When the cache pressure equals 70% of the total cache space, the second preset disk write concurrency is 10% of the maximum disk write concurrency. Furthermore, for every 1% increase in the total cache space, the second preset disk write concurrency increases by 9% of the maximum disk write concurrency, until the cache pressure equals 80% of the total cache space, at which point the second preset disk write concurrency reaches 100% of the maximum disk write concurrency.
[0086] Through the above embodiments, when the cache pressure is not less than the first threshold and less than the second threshold, the second preset disk write concurrency can be increased as the cache pressure increases, thereby making the determined disk write concurrency adapt to the current cache pressure and the processing capacity of the backend hard disk.
[0087] Optionally, the method further includes:
[0088] When the cache pressure reaches the third threshold, the cache mechanism is turned off.
[0089] Set the disk write concurrency of the cache to the fourth preset disk write concurrency;
[0090] Wherein, the third threshold is greater than the second threshold, and the fourth preset disk placement concurrency is greater than the first preset disk placement concurrency.
[0091] Specifically, the third threshold is greater than the second threshold. The third threshold can be 100% of the total cache space. When the cache pressure reaches the third threshold, it means that the cache space has been exhausted. New write cache requests need to wait for the data in the write cache requests in the cache to be written to disk before they can be written to the cache. At this time, the response result of the front-end host receiving the new write cache request will take a long time. Therefore, when the cache space is exhausted, the cache mechanism can be turned off so that the received new write cache requests no longer go through the cache, but are directly stored in the back-end disk. In addition, the disk write concurrency needs to be further adjusted. Since the disk write concurrency is at a high level when the cache pressure is about to reach the third threshold, the current disk write concurrency needs to be adjusted to the fourth preset disk write concurrency when the cache space is exhausted. The fourth preset disk write concurrency is greater than the first preset disk write concurrency. For example, the current disk write concurrency can be adjusted to 50% of the maximum disk write concurrency, so as to avoid the high disk write concurrency affecting the disk write or data reading of new write cache requests.
[0092] When the cache pressure returns to normal or is low, the caching mechanism is restarted.
[0093] Through the above embodiments, to ensure that the normal operation of the front-end host is not affected after the cache space is exhausted, the caching mechanism can be promptly shut down after the cache space is full, simplifying the process of new write cache requests. Conversely, the caching mechanism can be promptly activated when the cache pressure is low, allowing new write cache requests to receive faster responses and improving write cache performance to a certain extent.
[0094] Optionally, after the cache write-to-disk concurrency is set to the fourth preset write-to-disk concurrency, the method further includes:
[0095] The data corresponding to the target write cache instruction is directly written to disk.
[0096] Specifically, when the cache space is exhausted, after setting the cache disk write concurrency to the fourth preset disk write concurrency, the data corresponding to the target write cache instruction will not pass through the cache space, and the disk write operation will be performed directly.
[0097] Through the above embodiments, the caching mechanism can be turned off after the cache space is full, and the data corresponding to the target write cache instruction can be directly written to disk, thus simplifying the write cache request process.
[0098] Optionally, the method further includes:
[0099] After performing a caching operation on the data corresponding to the target write cache instruction, a first response message is sent to the front-end host;
[0100] After performing a write-to-disk operation on the data corresponding to the target write cache instruction, a second response message is sent to the cache.
[0101] Specifically, after the data corresponding to the target write cache instruction is cached in the cache space, the cache will send a first response message to the front-end host so that the front-end host can obtain the response result of the data corresponding to the target write cache instruction. After the back-end hard disk performs the write-to-disk operation on the data corresponding to the target write cache instruction in the cache, the back-end hard disk will send a second response message to the cache so that the cache can obtain the response result of the data corresponding to the target write cache instruction.
[0102] Through the above embodiments, after the data corresponding to the target write cache instruction is cached or written to disk, a corresponding response message can be fed back.
[0103] Figure 3 This is a schematic diagram of the framework of a data caching device provided in an embodiment of this application, as shown below. Figure 3 As shown, one embodiment of this application provides a data caching device, the device comprising:
[0104] The cache pressure acquisition module 11 is used to acquire the cache pressure at the current moment when a target write cache instruction is received;
[0105] The disk write concurrency setting module 12 is used to determine a preset disk write concurrency based on the cache pressure, and set the disk write concurrency of the cache based on the preset disk write concurrency.
[0106] Monitoring module 13 is used to monitor the first I / O latency of the front-end host and the second I / O latency of the back-end hard drive;
[0107] The adjustment module 14 is used to perform at least one preset adjustment on the disk write concurrency of the cache based on the first IO delay and the second IO delay, so that the first IO delay reaches the first target IO delay and the second IO delay reaches the second target IO delay;
[0108] Operation module 15 is used to perform caching and disk write operations on the data corresponding to the target write cache instruction based on the adjusted disk write concurrency.
[0109] Optionally, the preset adjustment includes a first preset adjustment and a second preset adjustment, and the adjustment module 14 includes:
[0110] The first adjustment unit is used to reduce the disk write concurrency of the cache by at least one first preset adjustment when the first IO delay is greater than the first preset IO delay or the second IO delay is greater than the second preset IO delay, so that the first IO delay reaches the first target IO delay and the second IO delay reaches the second target IO delay;
[0111] The second adjustment unit is used to increase the disk write concurrency of the cache by at least one second preset adjustment when the first IO delay is less than the first preset IO delay and the second IO delay is less than the second preset IO delay, so that the first IO delay reaches the first target IO delay and the second IO delay reaches the second target IO delay;
[0112] Wherein, the first preset adjustment is used to reduce the disk write concurrency of the cache by a first preset concurrency, and the second preset adjustment is used to increase the disk write concurrency of the cache by a second preset concurrency.
[0113] Optionally, the disk concurrency setting module 12 includes:
[0114] The first setting unit is configured to determine the preset disk write concurrency as the first preset disk write concurrency when the cache pressure is less than the first threshold, and set the cache disk write concurrency to the first preset disk write concurrency, wherein the cache pressure being less than the first threshold indicates that the processing capacity of the backend hard disk can meet the cache pressure.
[0115] The second setting unit is used to determine the preset disk write concurrency as the second preset disk write concurrency when the cache pressure is not less than the first threshold and less than the second threshold, and set the cache disk write concurrency as the second preset disk write concurrency, wherein the cache pressure being not less than the first threshold and less than the second threshold indicates that the processing capacity of the backend hard disk needs to be improved to cope with the cache pressure.
[0116] The third setting unit is used to determine the preset disk write concurrency as the third preset disk write concurrency when the cache pressure is not less than the second threshold, and set the cache disk write concurrency as the third preset disk write concurrency, wherein the cache pressure not less than the second threshold indicates that the processing capacity of the back-end hard disk needs to reach its limit to cope with the cache pressure.
[0117] Wherein, the first threshold is less than the second threshold, the first preset disk write concurrency is less than the second preset disk write concurrency, and the second preset disk write concurrency is less than the third preset disk write concurrency.
[0118] Optionally, when the cache pressure is not less than the first threshold and less than the second threshold, the preset disk write concurrency is determined as the second preset disk write concurrency, including:
[0119] The calculation unit is configured to calculate the second preset disk write concurrency corresponding to the cache pressure when the cache pressure is not less than the first threshold and less than the second threshold, wherein the cache pressure is proportional to the second preset disk write concurrency.
[0120] Optionally, the device further includes:
[0121] The shutdown unit is used to shut down the caching mechanism of the cache when the cache pressure reaches the third threshold.
[0122] The fourth setting unit is used to set the disk write concurrency of the cache to a fourth preset disk write concurrency.
[0123] Wherein, the third threshold is greater than the second threshold, and the fourth preset disk placement concurrency is greater than the first preset disk placement concurrency.
[0124] Optionally, after the cache write-to-disk concurrency is set to the fourth preset write-to-disk concurrency, the apparatus further includes:
[0125] The direct disk write unit is used to directly perform a disk write operation on the data corresponding to the target write cache instruction.
[0126] Optionally, the device further includes:
[0127] The first sending unit is configured to send a first response message to the front-end host after performing a caching operation on the data corresponding to the target write cache instruction;
[0128] The second sending unit is used to send a second response message to the cache after performing a disk write operation on the data corresponding to the target write cache instruction.
[0129] Based on the same inventive concept, another embodiment of this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the data caching method as described in any of the above embodiments.
[0130] Based on the same inventive concept, another embodiment of this application provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the data caching method as described in any of the above embodiments.
[0131] As the apparatus is basically similar to the method embodiment, it is described in a relatively simple way. For relevant details, please refer to the description of the method embodiment.
[0132] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0133] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this application can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this application can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0134] This application describes embodiments with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0135] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0136] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0137] Although preferred embodiments of the present application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present application.
[0138] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes the element.
[0139] The above provides a detailed description of a data caching method, apparatus, electronic device, and computer-readable medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A data caching method, characterized in that, The method includes: When a target write cache instruction is received, the cache pressure at the current moment is obtained; the cache pressure represents the current percentage of cache usage. Based on the cache pressure, a preset disk write concurrency is determined, and the disk write concurrency of the cache is set based on the preset disk write concurrency. Monitor the first I / O latency of the front-end host and the second I / O latency of the back-end hard drive; The disk write concurrency of the cache is adjusted at least once based on the first IO latency and the second IO latency, so that the first IO latency reaches the first target IO latency and the second IO latency reaches the second target IO latency; Based on the adjusted disk write concurrency, cache operations and disk write operations are performed on the data corresponding to the target write cache instruction; The step of determining a preset disk write concurrency based on the cache pressure, and setting the disk write concurrency of the cache based on the preset disk write concurrency, includes: When the cache pressure is less than a first threshold, the preset disk write concurrency is determined to be a first preset disk write concurrency, and the disk write concurrency of the cache is set to the first preset disk write concurrency. The cache pressure being less than the first threshold indicates that the processing capacity of the backend hard disk can meet the cache pressure. When the cache pressure is not less than the first threshold and less than the second threshold, the preset disk write concurrency is determined to be the second preset disk write concurrency, and the cache disk write concurrency is set to the second preset disk write concurrency. The cache pressure being not less than the first threshold and less than the second threshold indicates that the processing capacity of the backend hard disk needs to be improved to cope with the cache pressure. When the cache pressure is not less than the second threshold, the preset disk write concurrency is determined to be the third preset disk write concurrency, and the disk write concurrency of the cache is set to the third preset disk write concurrency. The cache pressure not less than the second threshold indicates that the processing capacity of the back-end hard disk needs to reach its limit to cope with the cache pressure. Wherein, the first threshold is less than the second threshold, the first preset disk write concurrency is less than the second preset disk write concurrency, and the second preset disk write concurrency is less than the third preset disk write concurrency.
2. The data caching method according to claim 1, characterized in that, The preset adjustment includes a first preset adjustment and a second preset adjustment. The step of performing at least one preset adjustment on the disk write concurrency of the cache based on the first IO delay and the second IO delay includes: When the first IO delay is greater than the first preset IO delay or the second IO delay is greater than the second preset IO delay, the disk write concurrency of the cache is reduced by at least one first preset adjustment so that the first IO delay reaches the first target IO delay and the second IO delay reaches the second target IO delay; When the first IO latency is less than the first preset IO latency and the second IO latency is less than the second preset IO latency, the disk write concurrency of the cache is increased by at least one second preset adjustment so that the first IO latency reaches the first target IO latency and the second IO latency reaches the second target IO latency; Wherein, the first preset adjustment is used to reduce the disk write concurrency of the cache by a first preset concurrency, and the second preset adjustment is used to increase the disk write concurrency of the cache by a second preset concurrency.
3. The data caching method according to claim 1, characterized in that, When the cache pressure is not less than the first threshold and less than the second threshold, the preset disk write concurrency is determined as the second preset disk write concurrency, including: When the cache pressure is not less than the first threshold and less than the second threshold, the second preset disk write concurrency corresponding to the cache pressure is calculated, wherein the cache pressure is proportional to the second preset disk write concurrency.
4. The data caching method according to claim 1, characterized in that, The method further includes: When the cache pressure reaches the third threshold, the cache mechanism is turned off. Set the disk write concurrency of the cache to the fourth preset disk write concurrency; Wherein, the third threshold is greater than the second threshold, and the fourth preset disk placement concurrency is greater than the first preset disk placement concurrency.
5. The data caching method according to claim 4, characterized in that, After the cache write-to-disk concurrency is set to the fourth preset write-to-disk concurrency, the method further includes: The data corresponding to the target write cache instruction is directly written to disk.
6. The data caching method according to any one of claims 1-5, characterized in that, The method further includes: After performing a caching operation on the data corresponding to the target write cache instruction, a first response message is sent to the front-end host; After performing a write-to-disk operation on the data corresponding to the target write cache instruction, a second response message is sent to the cache.
7. A data caching device, characterized in that, The device includes: The cache pressure acquisition module is used to acquire the cache pressure at the current moment when a target write cache instruction is received; the cache pressure represents the current percentage of cache usage. The disk write concurrency setting module is used to determine a preset disk write concurrency based on the cache pressure, and set the disk write concurrency of the cache based on the preset disk write concurrency. The monitoring module is used to monitor the first I / O latency of the front-end host and the second I / O latency of the back-end hard drive; The adjustment module is used to perform at least one preset adjustment on the disk write concurrency of the cache based on the first IO delay and the second IO delay, so that the first IO delay reaches the first target IO delay and the second IO delay reaches the second target IO delay; The operation module is used to perform caching and disk write operations on the data corresponding to the target write cache instruction based on the adjusted disk write concurrency. The disk concurrency setting module includes: The first setting unit is configured to determine the preset disk write concurrency as the first preset disk write concurrency when the cache pressure is less than the first threshold, and set the cache disk write concurrency to the first preset disk write concurrency, wherein the cache pressure being less than the first threshold indicates that the processing capacity of the backend hard disk can meet the cache pressure. The second setting unit is used to determine the preset disk write concurrency as the second preset disk write concurrency when the cache pressure is not less than the first threshold and less than the second threshold, and set the cache disk write concurrency as the second preset disk write concurrency, wherein the cache pressure being not less than the first threshold and less than the second threshold indicates that the processing capacity of the backend hard disk needs to be improved to cope with the cache pressure. The third setting unit is used to determine the preset disk write concurrency as the third preset disk write concurrency when the cache pressure is not less than the second threshold, and set the cache disk write concurrency as the third preset disk write concurrency, wherein the cache pressure not less than the second threshold indicates that the processing capacity of the back-end hard disk needs to reach its limit to cope with the cache pressure. Wherein, the first threshold is less than the second threshold, the first preset disk write concurrency is less than the second preset disk write concurrency, and the second preset disk write concurrency is less than the third preset disk write concurrency.
8. An electronic device, characterized in that, The system includes a memory, a processor, and a computer program stored on the memory, wherein the processor executes the computer program to implement the data caching method as described in any one of claims 1-6.
9. A computer-readable medium, characterized in that, It stores a computer program, wherein the program, when executed by a processor, implements the data caching method as described in any one of claims 1-6.
Citation Information
Patent Citations
Metadata disk dropping method and device, terminal and computer readable storage medium
CN109582244A
Storage system and IO disk falling method and device thereof
CN110673798A
