Data caching method and device, computer equipment and storage medium
By dividing the computing side cache for the virtual machine on the upper layer of the virtual machine logical volume, the problem of slow IO request speed of virtual machine is solved, and high-performance, low-latency and low-volatility IO response is achieved, which is suitable for server nodes in distributed storage systems.
Patent Information
- Application Number
- CN202510541185.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-08-08
AI Technical Summary
IO requests initiated by virtual machines require data read and write operations on low-performance storage devices, resulting in slow IO response speed, especially in concurrent scenarios that affect the normal use of services.
The upper layer of the virtual machine logical volume divides the computing side cache with higher performance for the virtual machine, so that the cache location is closer to the virtual machine, and the virtual machine's business requests are processed through the computing side cache, including reading and writing data.
It improves the response speed of IO requests, provides high performance, low latency and low fluctuation, while not affecting virtualization functions, and has flexible cache settings and scalability capabilities.
Smart Images

Figure CN120448033A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data caching method, device, computer equipment and storage medium. Background Art
[0002] After a virtual machine initiates a business IO (Input / Output) request, it needs to perform data read and write operations on the storage pool based on the IO request. Since most data is stored in low-performance storage devices, this will affect the IO response speed, especially in concurrent scenarios, which can easily affect the normal use of the business. Summary of the Invention
[0003] In view of this, the present invention provides a data caching method, apparatus, computer equipment and storage medium to solve the problem of slow virtual machine IO response speed.
[0004] In a first aspect, the present invention provides a data caching method, comprising:
[0005] In response to a read request for first business data initiated by a target virtual machine, searching for the first business data in a target cache on a computing side, where the target cache is allocated for the target virtual machine from a cache device on the computing side;
[0006] If the first service data exists in the target cache, the first service data in the target cache is sent to the target virtual machine.
[0007] In some optional embodiments, the method further comprises:
[0008] If the first business data does not exist in the target cache, the first business data is read from the target logical volume, sent to the target virtual machine, and written to the target cache; the target logical volume is a logical volume allocated from the storage device for the target virtual machine.
[0009] In some optional embodiments, the method further comprises:
[0010] In response to a write request for second business data initiated by the target virtual machine, writing the second business data into the target cache;
[0011] The data to be written in the target cache is written to the target logical volume corresponding to the target virtual machine; the target logical volume is a logical volume divided from the storage device for the target virtual machine, the data to be written is business data that has not been written to the target logical volume, and the data to be written includes the second business data.
[0012] In some optional implementations, the target cache is divided into a plurality of data blocks;
[0013] Writing the to-be-written data in the target cache to the target logical volume corresponding to the target virtual machine includes:
[0014] At each preset time interval, a preset number of to-be-processed data blocks are selected from the target cache as target to-be-processed data blocks, and the data in the target to-be-processed data blocks are written to the target logical volume; the to-be-processed data blocks written to the target logical volume are marked as written to the logical volume.
[0015] In some optional implementations, selecting a preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks at each preset time interval, and writing data in the target to-be-processed data blocks to the target logical volume includes:
[0016] When the target cache is idle, selecting a first preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks at intervals of a first preset time, and writing data in the first preset number of target to-be-processed data blocks to the target logical volume;
[0017] When the target cache is not idle, selecting a second preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks at intervals of a second preset time, and writing data in the second preset number of target to-be-processed data blocks to the target logical volume;
[0018] The ratio of the first preset number to the first preset time is greater than the ratio of the second preset number to the second preset time.
[0019] In some optional implementations, writing the data in the first preset number of target to-be-processed data blocks to the target logical volume includes:
[0020] writing the data in the first preset number of target to-be-processed data blocks to the target logical volume in parallel;
[0021] Writing the data in the second preset number of target to-be-processed data blocks to the target logical volume includes:
[0022] The data in the second preset number of target to-be-processed data blocks are serially written to the target logical volume.
[0023] In some optional implementations, the target cache includes a plurality of data groups; each of the data groups is configured with a corresponding priority, and each of the data groups includes data blocks to be processed with the same priority;
[0024] The selecting a preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks includes:
[0025] A preset number of data blocks to be processed are selected from the data group having data blocks to be processed and having the lowest priority as target data blocks to be processed.
[0026] In some optional embodiments, the data group includes a plurality of data subgroups; each of the data subgroups is configured with a corresponding access frequency level, and each of the data subgroups includes data blocks to be processed having the same priority level and access frequency level;
[0027] The step of selecting a preset number of data blocks to be processed from the data group having data blocks to be processed and having the lowest priority as target data blocks to be processed includes:
[0028] A preset number of data blocks to be processed are selected from the data group with the lowest priority level and the data subgroup with the lowest access frequency level as target data blocks to be processed.
[0029] In some optional implementations, the target cache is determined according to the following operations:
[0030] Dividing a corresponding target cache for a target virtual machine from a plurality of distributed cache devices; the target cache is divided into a plurality of data blocks;
[0031] Writing the second service data into the target cache includes:
[0032] Writing the second service data into a target data block allocated to a target cache in at least one cache device, and recording global metadata and local metadata of the second service data;
[0033] The global metadata is used to record the node location of the cache device storing the second business data, and the local metadata is used to record the storage location of the target data block in the cache device storing the second business data;
[0034] The searching for the first service data in the target cache on the computing side includes:
[0035] Locating a target cache device for storing the first service data according to the global metadata;
[0036] The storage location of the first business data in the target cache device is determined according to the local metadata corresponding to the target cache device, and the first business data is extracted from the storage location.
[0037] In a second aspect, the present invention provides a data caching device, comprising:
[0038] a request module, configured to search for the first business data in a target cache on a computing side in response to a read request for the first business data initiated by the target virtual machine, the target cache being allocated for the target virtual machine from a cache device on the computing side;
[0039] The processing module is configured to send the first business data in the target cache to the target virtual machine if the first business data exists in the target cache.
[0040] In a third aspect, the present invention provides a computer device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the data caching method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0041] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the data caching method of the first aspect or any corresponding embodiment thereof.
[0042] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the data caching method of the first aspect or any corresponding embodiment thereof.
[0043] The present invention allocates a high-performance computing-side cache for the virtual machine at the upper layer of the virtual machine's logical volume, so that the cache is located closer to the virtual machine. Service requests initiated by the virtual machine can be processed based on the cache, so that feedback can be quickly provided, improving the response speed of the request, and having the characteristics of high performance, low latency, and low volatility. While providing high performance and low latency, it can ensure that there is no impact on the virtualization function. A certain size of cache can be flexibly set for the virtual machine on demand without having to worry about the specific architecture or deployment requirements of the distributed storage bottom layer. Not only can the cache be flexibly increased or decreased, but it also has a certain scalability and can adaptively improve the read and write capabilities of each virtual machine, and is flexible in applicable scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in related technologies, the following briefly introduces the drawings required for use in the specific embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0045] Figure 1 It is a schematic diagram of a virtual machine reading and writing data;
[0046] Figure 2 is a flow chart of a data caching method according to an embodiment of the present invention;
[0047] Figure 3 This is a schematic diagram of processing a service request of a target virtual machine according to an embodiment of the present invention;
[0048] Figure 4 is a flow chart of another data caching method according to an embodiment of the present invention;
[0049] Figure 5 is a schematic diagram of a layout of a target cache according to an embodiment of the present invention;
[0050] Figure 6 is a schematic diagram of a distributed architecture according to an embodiment of the present invention;
[0051] Figure 7 is a schematic diagram of a metadata management logic framework according to an embodiment of the present invention;
[0052] Figure 8 is a schematic diagram of organizing all data blocks to be processed in a linked list format according to an embodiment of the present invention;
[0053] Figure 9 is a structural block diagram of a data cache device according to an embodiment of the present invention;
[0054] Figure 10 Schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0055] To make the purpose, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts shall fall within the scope of protection of the present invention.
[0056] For the convenience of description, some terms involved in this embodiment are first explained. These explanations are intended to make the embodiments of this application easier to understand and should not be regarded as limiting the scope of protection claimed in this application.
[0057] (1) Hyper-converged architecture: Also known as Hyper Converged Infrastructure (HCI), it refers to the integration of computing, networking, storage, and server virtualization resources and technologies within a single unit device (e.g., an x86 server), as well as backup software, snapshot technology, data deduplication, and online data compression. Multiple units can be aggregated over the network to achieve modular, seamless scale-out, forming a unified resource pool. In such an architecture, hardware units such as servers and storage, along with virtualization software, are integrated into a single chassis.
[0058] (2) Virtual Machine: Virtual Machine, abbreviated as VM, refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment.
[0059] (3) QEMU: Quick EMUlator. QEMU allows multiple virtual machines to run simultaneously on a physical host, realizing computing virtualization, network virtualization, and storage virtualization of virtual machines, and providing management and control capabilities for these virtual machines.
[0060] (4) Hybrid Storage: It is a storage architecture that combines a solid-state drive (SSD) with a traditional mechanical hard disk drive (HDD). It aims to provide acceleration for the HDD through the high-speed read and write performance of the SSD, thereby achieving a balance between cost and performance.
[0061] In the current era of rapid development of information technology, efficient data storage performance is crucial for enterprise users. Hyperconvergence has shown strong advantages in infrastructure integration. If the performance can be further improved, it can greatly enhance market competitiveness and improve user experience.
[0062] The distributed storage system integrates the local hard disk resources of the server through software to build a unified resource pool, providing unified block, file, and object storage services to upper-level applications, meeting the needs of multiple types of data storage such as structured, unstructured, and semi-structured data. It supports rich enterprise-level features such as snapshots, thin configuration, and remote replication, helping users to easily respond to the flexible and reliable data access needs when the business changes. At the same time, the use of a distributed architecture, an extremely easy-to-maintain management platform, and fully automated operation and maintenance capabilities achieves linear expansion of storage performance, greatly improves reliability, and lowers the user's usage threshold.
[0063] Distributed storage systems mainly use HDDs to build storage pools. After a virtual machine initiates a business IO request, it needs to perform data read and write operations on the storage pool based on the IO request. Since most data is stored in low-performance HDDs, this will affect the IO response speed, especially in concurrent scenarios, which can easily affect normal business use.
[0064] For example, in industries like finance, telecom, and manufacturing, OLTP (Online Transaction Processing) businesses experience increased business volume, especially during special periods like the end and beginning of the month, leading to slow IT system responses, business interruptions, and numerous customer complaints. For OLAP (Online Analytical Processing) businesses, as business volume grows, batch processing often faces the problem of insufficient processing time windows.
[0065] Figure 1 A schematic diagram of a virtual machine reading and writing data is shown, Figure 1 As shown, the virtual machine sends a business-related IO request to QEMU, and QEMU sends the IO request to the distributed storage block device layer. After the distributed storage block device layer makes a decision, it performs data read and write operations on the corresponding storage device in the distributed storage data pool. Figure 1 In the example, the storage device is a low-performance HDD with poor read and write speeds.
[0066] Some solutions use a hybrid flash storage architecture, deploying solid-state drives to dynamically allocate storage locations for hot and cold data to achieve performance acceleration. The accelerated IO performance is improved, but the architectural technology differences among storage manufacturers lead to significant differences in test performance under the same hardware and the same test methods. Some manufacturers only support read caching and not write caching. In different concurrency scenarios, performance fluctuates greatly and latency is high.
[0067] In addition, the solid-state drive is configured during initialization. Based on the physical disk acceleration on the storage side, its performance will change significantly with changes in disk specifications and the disk ratio of the solid-state drive to the mechanical disk, resulting in unstable performance.
[0068] An embodiment of the present invention provides a data caching method, which allocates a higher-performance computing-side cache for the virtual machine on the upper layer of the virtual machine logical volume. The cache is located closer to the virtual machine. Service requests initiated by the virtual machine can be processed based on the computing-side cache, so that data can be read quickly, and the response speed of the request is improved. While providing high performance and low latency effects, it can ensure that there is no impact on the virtualization function.
[0069] According to an embodiment of the present invention, an embodiment of a data caching method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0070] This embodiment provides a data caching method, which is applied to a server, such as a server node in a distributed storage system. Figure 2 is a flow chart of a data caching method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps.
[0071] Step S201 , in response to a read request for first business data initiated by a target virtual machine, searching for the first business data in a target cache on a computing side, where the target cache is allocated for the target virtual machine from a cache device on the computing side.
[0072] In this embodiment, in addition to a storage device for storing data, a cache device is also deployed to achieve performance acceleration. It is understood that the cache device itself is also a device with storage functionality, and its read and write performance is higher than that of the storage device. For example, the cache device can be an SSD, such as an NVMe (Non-Volatile Memory Express) device, and the storage device can be an HDD. This embodiment does not limit the specific form of the two devices.
[0073] The server can configure virtual machines (VMs) for corresponding services to meet customer business needs. The number of VMs can be one or more, and they can be deployed on multiple servers. For ease of description, one of the VMs will be referred to as the target VM, and the method of this embodiment will be explained using the target VM as an example. It is understood that the method of this embodiment can also be applied to other VMs (e.g., VMs requiring performance acceleration).
[0074] The architecture for implementing data storage in scenarios such as cloud computing may include a computing side and a storage side. As the name implies, the computing side is the side that processes data, such as the part of the server responsible for executing computationally intensive operations such as calculations, logical processing, and task scheduling. The core of the side is to process data and generate results. The storage side is the side that stores data, and is responsible for persisting data and providing high-reliability storage services. For example, a virtual machine on the computing side can read and write data to a storage device on the storage side. In this embodiment, a cache device can be deployed on the computing side, so that a corresponding cache is set for each virtual machine on the computing side. The cache is also a cache on the computing side, which is located between the virtual machine and the storage device.
[0075] Specifically, for the target virtual machine, a cache space is allocated from the compute-side cache device as the target virtual machine's cache, i.e., the target cache. This cache is the compute-side cache. The target cache can be used to store data that the target virtual machine needs to quickly access. The target cache can correspond one-to-one with the target virtual machine, meaning that the target cache is used only to accelerate the performance of the target virtual machine and is not relevant to other virtual machines.
[0076] In this embodiment, in order to provide the required services to the user, a corresponding service request may be initiated based on the virtual machine. The service request is specifically used to read and write related service data, that is, the service request may be a write request or a read request.
[0077] Among them, the target virtual machine will send the business request to the virtual machine manager (such as QEMU), which will pass it on. After obtaining the business request passed by the virtual machine manager, cache-related processing can be performed on the computing side, such as reading and writing data based on the target cache on the computing side.
[0078] Specifically, when data needs to be read, a read request for the first business data can be initiated based on the target virtual machine. After obtaining the read request, a search can be performed in the target cache on the computing side to determine whether the first business data exists in the target cache.
[0079] For example, when it is necessary to read the first business data, the virtual machine can initiate a read request for reading the first business data and send it to the cache layer through QEMU; the cache layer can determine the first business data that needs to be read based on the read request, and first determine whether the first business data exists in the target cache.
[0080] Step S202: If the first service data exists in the target cache, the first service data in the target cache is sent to the target virtual machine.
[0081] In this embodiment, when configuring a target virtual machine for a service, a corresponding block device is also allocated from the storage device for the target virtual machine. This is a type of logical volume. For ease of description, the logical volume allocated for the target virtual machine is referred to as the target logical volume. Specifically, it can be a block device displayed in the virtual machine, and the size is determined by the user. For example, the target logical volume allocated to the target virtual machine can be flexibly allocated based on at least one storage device in a distributed storage system (such as distributed block storage).
[0082] It can be understood that each target virtual machine may correspond to an exclusive target logical volume and target cache, that is, the target cache and the target logical volume also correspond one to one, and different virtual machines do not interfere with each other.
[0083] The size of the target cache can be determined based on the size of the target logical volume, for example, it can be smaller than the size of the target logical volume. For example, if the target logical volume size of the target virtual machine is 100GB, a target cache size of 20GB, 25GB, etc. can be allocated to the target virtual machine, depending on the actual situation.
[0084] If the first business data currently exists in the target cache, for example, the first business data has not yet been flushed to the target logical volume, or the first business data has not yet been cleared from the target cache after being flushed to the target logical volume, the first business data can be directly obtained from the target cache and sent to the target virtual machine. This process does not require passing through the storage device on the storage side, and efficient write performance can be achieved.
[0085] Optionally, the method further includes: if the first business data does not exist in the target cache, reading the first business data from the target logical volume, sending it to the target virtual machine, and writing the first business data to the target cache. The target logical volume is a logical volume allocated for the target virtual machine from the storage device.
[0086] In this embodiment, if the first business data does not currently exist in the target cache, it is necessary to read the lower-layer target logical volume so that the first business data can be read from the target logical volume, and then the read first business data can be written back to the target cache, and the read request is fed back based on the first business data in the target cache, that is, the first business data is sent to the target virtual machine.
[0087] Figure 3 FIG. 1 shows a schematic diagram of processing a service request of a target virtual machine according to this embodiment. Figure 1 As shown, for the target virtual machine, a target logical volume of a certain size can be allocated for it from the distributed storage data pool. A service request initiated by the target virtual machine is sent to the newly added computing-side cache layer through the virtual machine manager (e.g., QEMU). This cache layer allocates a target cache from the computing-side cache device and uses this target cache to process the service request; for example, it reads the first service data from the target cache.
[0088] The data caching method provided in this embodiment allocates a high-performance computing-side cache for the virtual machine at the upper layer of the virtual machine's logical volume, so that the cache location is closer to the virtual machine. Service requests initiated by the virtual machine can be processed based on the cache, so that feedback can be quickly provided, improving the response speed of the request, and having the characteristics of high performance, low latency, and low volatility; while providing high performance and low latency effects, it can ensure that there is no impact on virtualization functions. A certain size of cache can be flexibly set for the virtual machine on demand without having to worry about the specific architecture or deployment requirements of the distributed storage underlying layer. Not only can the cache be flexibly increased or decreased, but it also has a certain scalability and can adaptively improve the read and write capabilities of each virtual machine, with flexible application scenarios.
[0089] This embodiment provides a data caching method, which is applied to a server, such as a server node in a distributed storage system. Figure 4 is a flow chart of a data caching method according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps.
[0090] Step S401: allocate a corresponding target cache for a target virtual machine from a cache device.
[0091] In this embodiment, the target cache is divided into multiple data blocks (DataBlocks); the size of each data block can be set according to actual needs. For example, the target cache can be divided into multiple data blocks at a 4KB granularity, that is, the size of each data block is 4KB.
[0092] The target cache includes, in addition to data blocks for caching corresponding service data, storage blocks for recording configuration information and metadata information of the target cache. The size of the storage blocks may be, for example, 4 KB.
[0093] Figure 5 A schematic diagram showing the layout of the entire cache space of the target cache is shown in FIG. Figure 5 As shown, the target cache includes a configuration zone (configzone), a metadata zone (metazone) and a data zone (datazone). When the performance acceleration function is first enabled for the target virtual machine, the layout of the target cache can be initialized.
[0094] The configuration area is used to record the target cache's header information and the target virtual machine's runtime parameters. For example, the configuration area can be a 4KB storage block. The metadata area is used to record the status information of each data block, including the data block's LBA (Logical Block Address), priority, and flags (dirty / clean, used to indicate whether the data block is a pending data block). The data area is the main part of the target cache and includes the data blocks used to cache business data.
[0095] Step S402 : writing the second business data into the target cache in response to a write request for the second business data initiated by the target virtual machine.
[0096] As described above, the service request initiated based on the target virtual machine may also be a write request, which is specifically used to write the second service data. In this embodiment, the second service data will be written to the corresponding computing side cache, ie, the target cache.
[0097] After the second business data is written to the target cache, feedback can be provided on the write request, meaning that it does not need to go through the back-end storage device, enabling a fast response. For example, if the business request is a write request that requires writing the second business data, after the target cache on the computing side obtains data consistency confirmation, feedback can be provided on the write request even if the second business data has not been written to the storage device on the storage side, resulting in a short IO path and a faster response speed.
[0098] Specifically, when adding secondary business data, the target VM can initiate a write request containing the secondary business data and send it to the cache layer on the computing side through QEMU. After confirming the data consistency of the secondary business data, the cache layer generates a corresponding feedback message and returns it to the target VM through QEMU. This write process does not involve low-performance storage devices, achieving high performance, low latency, and low volatility.
[0099] Furthermore, the second service data written to the target cache is marked as not written to the logical volume, so that the second service data can be flushed to the corresponding target logical volume later.
[0100] For example, the second business data may correspond to one or more data blocks in the target cache, and the second business data may be stored in these data blocks. Furthermore, the flag bits of these data blocks are set to dirty, indicating that the data in the data blocks has not been written to the logical volume. In other words, these data blocks may also be referred to as dirty data blocks. For example, the value of the flag bit is a binary integer, where 0 represents clean and 1 represents dirty, i.e., the flag bits of these data blocks are all set to 1.
[0101] In some optional implementations, to ensure cache reliability, a target cache is configured using a distributed cache. Specifically, step S401, "allocating a corresponding target cache for the target virtual machine from a cache device," includes: allocating a corresponding target cache for the target virtual machine from a plurality of distributed cache devices; and dividing the target cache into a plurality of data blocks.
[0102] Figure 6 A schematic diagram of a distributed architecture of this embodiment is shown. Figure 6 As shown, multiple distributed nodes provide cache devices and storage devices. Figure 6 In this example, three nodes are configured, each with an NVMe device and an OSD (Object-based Storage Device). Each node's NVMe device acts as a cache device, forming a distributed cache pool. Each node's OSD acts as a storage device, forming a distributed storage data pool. Deploying the distributed storage pool and distributed cache pool separately based on independent hard drives allows them to operate independently without interfering with each other.
[0103] For the target virtual machine, when the user creates the target virtual machine, a target logical volume LUNA of a specified size can be allocated from the distributed storage data pool. The target logical volume LUNA can correspond to the storage device of one or more nodes. In addition, if the target virtual machine needs to perform performance acceleration, for example, the target virtual machine needs to provide low-latency, high IOPS (Input / Output Operations Per Second, the number of read and write operations per second) services, a target cache LUNB can also be allocated for the target virtual machine from the distributed cache pool. Among them, the role of the target cache LUNB is to perform performance reading and writing acceleration for the target logical volume LUNA. Its entire life cycle is bound to the target logical volume LUNA and cannot accelerate other logical volumes.
[0104] Furthermore, step S402, "writing the second business data to the target cache," may specifically include writing the second business data to a target data block allocated to the target cache in at least one cache device, and recording global metadata and local metadata for the second business data. The global metadata records the node location of the target cache device, and the local metadata records the storage location of the target data block in the target cache device.
[0105] In this embodiment, if the service request is a write request for the second service data, the second service data is written to the corresponding data block in the target cache and marked as not written to the logical volume, for example, as dirty. For ease of description, the data block in the target cache used to cache the second service data is referred to as the "target data block."
[0106] When the second service data is written into the corresponding one or more target data blocks, the metadata of each target data block needs to be recorded. Figure 5 As shown, metadata of each target data block can be recorded based on the metadata area.
[0107] Specifically, the metadata of the target data block includes global metadata and local metadata, wherein the global metadata is used to record the node location of the target cache device, for example, which disk pool and node the target cache device corresponds to; the local metadata is used to record the storage location of the target data block in the target cache device, such as the address offset of the target data block, etc.
[0108] When data in the target data block needs to be read later, the corresponding target cache device can be located based on the global metadata, and then the storage location of the target data block can be located based on the local metadata, thereby achieving data reading. For example, the process of searching for first business data in the target cache on the computing side can include: locating the target cache device used to store the first business data based on the global metadata; determining the storage location of the first business data in the target cache device based on the local metadata corresponding to the target cache device, and extracting the first business data from the storage location.
[0109] In this embodiment, metadata is split into global and local metadata. Global metadata manages node distribution, while local metadata manages physical disk distribution. This allows for load balancing and decentralized metadata management, breaking the performance bottleneck of non-centralized metadata management. Furthermore, the distributed cache approach ensures data consistency and persistence for unflushed data in the event of power outages, network outages, node anomalies, cluster power outages, and disk unplugging, thereby improving data reliability.
[0110] Metadata can be recorded in the form of tables, including root index tables (roottable), pool index tables (pooltable), volume index tables (volumetable), and data block index tables (chunktable). The root index table mainly stores the location of each pool, the names and IDs of all nodes, etc., and takes up very little space; the pool index table is used to store the node location and attributes corresponding to each volume; the volume index table is used to store the node location and attributes corresponding to each data block; the data block index table runs on each node and is used to store the specific hard disk location, attributes, and other information of the data block on the node.
[0111] by Figure 7For example, the root index table records the index tables of three pools: Pool Index Table 1, Pool Index Table 2, and Pool Index Table 3. Pool Index Table 2 records the index tables of two volumes: Volume Index Table 1 and Volume Index Table 2. Volume Index Table 1 records metadata for data blocks C10, C11, and C12, while Volume Index Table 2 records metadata for data blocks C20, C21, and C22. Furthermore, each data block corresponds to a corresponding data block index table.
[0112] The global metadata includes the root index table, the pool index table, and the volume index table, and the local metadata includes the data block index table.
[0113] Metadata, like regular business data, can be distributed across any node in the cluster, depending on the data distribution algorithm. After each node is assigned an identity and leased by a management node (determined through elections and replaced by a new one in the event of a failure), it loads the corresponding metadata table into local memory for fast data access.
[0114] like Figure 7 As shown, for the data corresponding to the data block C10, multiple copies can be formed and stored in different nodes, such as the master copy of the data block C10 and the slave copy of the data block C10; Figure 7 As shown in the figure, the former is stored in the cache device (NVMe device) of node N1, and the latter is stored in the cache device (NVMe device) of node N2. Similarly, the remaining data blocks can also form multiple copies and perform distributed caching. In addition, the volume index table, pool index table, etc. can also be stored in a distributed cache. For details, see Figure 7 As shown, no further details are given here.
[0115] In addition, the replica location can be specified, so that a replica (such as the primary replica) can be placed close to the virtual machine on the same node, so that the reading and writing of the replica does not need to cross the network, greatly improving data reading and writing performance.
[0116] Step S403, write the data to be written in the target cache to the target logical volume corresponding to the target virtual machine; the target logical volume is a logical volume divided from the storage device for the target virtual machine, the data to be written is business data that has not been written to the target logical volume, and the data to be written includes second business data.
[0117] The target cache is used to temporarily store a certain amount of business data, which will eventually be sent to the corresponding storage device, namely the target logical volume. Therefore, there are two main types of business data in the target cache: business data that has not yet been written to the target logical volume, which is referred to as pending data and is considered dirty data; and business data that has already been written to the target logical volume and can be marked as written to the logical volume and is considered clean data.
[0118] For data in the target cache that has not been written to the target logical volume, it is necessary to flush the data to the corresponding storage device, that is, to the target logical volume corresponding to the target virtual machine, so that the target logical volume can store the business data of the target virtual machine. After the business data is written to the target logical volume, since the business data is no longer business data that has not been written to the target logical volume, the status of the business data changes to written to the logical volume, for example, from dirty to clean. However, the business data can still be stored in the target cache unless it is cleared from the target cache.
[0119] Specifically, for clean business data, since it has been recorded in the target logical volume, when the target cache is short of space (when new business data needs to be written), these clean business data can be cleared to ensure that the target cache can cache data normally.
[0120] It is understood that the second business data in the write request is also data to be written and will subsequently need to be written to the target logical volume. Since the cache device also has a persistence function, after obtaining the second business data, it can be immediately written from the target cache to the target logical volume; alternatively, the target cache can temporarily store the second business data for a period of time and then write it to the target logical volume.
[0121] Specifically, the above step S403 of “writing the data to be written in the target cache to the target logical volume corresponding to the target virtual machine” specifically includes steps S4031 and S4032.
[0122] Step S4031 : selecting a preset number of to-be-processed data blocks from the target cache at every preset time interval as target to-be-processed data blocks.
[0123] Step S4032: writing the data in the target data block to be processed into the target logical volume; the data block to be processed written into the target logical volume is marked as having been written into the logical volume.
[0124] In this embodiment, the target cache stores data in units of data blocks. For a data block, if the data stored therein is data that has not been written to the target logical volume, then the data block is a data block to be processed, for example, the data block is a dirty data block.
[0125] To ensure that the target logical volume can persist business data and avoid the target cache from running out of available space, in this embodiment, the disk is flushed periodically at certain preset time intervals, that is, the data in a certain number (i.e., a preset number) of pending data blocks in the target cache are flushed to the target logical volume.
[0126] Among them, based on certain selection rules, the pending data blocks that need to be flushed, i.e., the target pending data blocks, can be selected. It is understood that after the target pending data blocks are flushed, the target pending data blocks will be converted into written data blocks, i.e., the pending data blocks written to the target logical volume are marked as written to the logical volume; for example, the flag bit of the target pending data blocks changes from 1 (indicating dirty) to 0 (indicating clean), i.e., the target pending data blocks are converted from dirty data blocks to clean data blocks.
[0127] In some optional implementations, the process shown in the above steps S4031 to S4032 may specifically include the following steps A1 and A2.
[0128] Step A1: When the target cache is idle, at every first preset time interval, select a first preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks, and write data in the first preset number of target to-be-processed data blocks to the target logical volume.
[0129] In step A2, if the target cache is not idle, at intervals of a second preset time, a second preset number of to-be-processed data blocks are selected from the target cache as target to-be-processed data blocks, and data in the second preset number of target to-be-processed data blocks are written to the target logical volume. The ratio of the first preset number to the first preset time is greater than the ratio of the second preset number to the second preset time.
[0130] In this embodiment, different disk flushing strategies may be adopted when the target cache is in different states; wherein the state of the target cache may be determined based on the IO usage of the target cache.
[0131] Specifically, if the target cache IO is idle, for example, the number of IO requests between the target cache and the target logical volume is relatively small, a first preset number of to-be-processed data blocks can be selected from the target cache as target to-be-processed data blocks at intervals of a first preset time, and then flushed in parallel.
[0132] If the target cache IO is not idle, for example, the number of IO requests between the target cache and the target logical volume is relatively large and it is in a busy state, then a second preset number of to-be-processed data blocks can be selected from the target cache as target to-be-processed data blocks at intervals of a second preset time, and then the disk is flushed in a serial manner.
[0133] In this embodiment, the target cache has a higher flushing efficiency when idle than when not idle; that is, the ratio of the first preset number to the first preset time is greater than the ratio of the second preset number to the second preset time. This allows the data blocks to be processed to be flushed to the target logical volume more efficiently when idle.
[0134] Optionally, in order to further improve the disk flushing efficiency during idle time and reduce the impact of disk flushing on other IO services during busy time, when the target cache is idle, the data in a first preset number of target data blocks to be processed are written in parallel to the target logical volume; when the target cache is not idle, the data in a second preset number of target data blocks to be processed are written serially to the target logical volume.
[0135] For example, when the target cache IO is idle, 32 data blocks to be processed are selected every 100ms and flushed to disk concurrently in 32 ways. When the target cache IO is busy, 16 data blocks to be processed are selected every 100ms and flushed to disk serially.
[0136] In some optional implementations, when flushing data blocks to be processed, the least important data blocks to be processed are flushed first. Specifically, the target cache includes multiple data groups; each data group is configured with a corresponding priority, and each data group includes data blocks to be processed with the same priority.
[0137] Furthermore, the above step S4031 of “selecting a preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks” includes step B1.
[0138] Step B1: Select a preset number of data blocks to be processed from a data group having data blocks to be processed and having the lowest priority as target data blocks to be processed.
[0139] In this embodiment, for the newly added second business data in the write request, a corresponding priority can be set according to business needs. Accordingly, the data block storing the second business data also has a corresponding priority; Figure 5 As shown, the priority of each data block can be recorded based on the metadata. In addition, since the second service data is newly added data, the data block is a data block to be processed.
[0140] Each pending data block is grouped based on its priority, forming multiple data groups, each with a corresponding priority. The lower the priority, the less important the data in the pending data block, and the more likely it is to be flushed to the target logical volume. These unimportant pending data blocks are marked as clean and can be cleared later. More important pending data blocks can be cleared later, making subsequent reads by the virtual machine more likely to hit the target cache.
[0141] Optionally, for each data group, the data group may include multiple data subgroups; each data subgroup is configured with a corresponding access frequency level, and each data subgroup includes data blocks to be processed with the same priority and access frequency level.
[0142] Accordingly, the above-mentioned step B1 of “selecting a preset number of data blocks to be processed from the data group having data blocks to be processed and having the lowest priority as target data blocks to be processed” may include step B11.
[0143] Step B11 , selecting a preset number of to-be-processed data blocks from the data group containing to-be-processed data blocks with the lowest priority and the data subgroup containing to-be-processed data blocks with the lowest access frequency level as target to-be-processed data blocks.
[0144] In this embodiment, data blocks of a certain priority level can be further grouped based on their corresponding access frequency levels, thereby forming multiple data subgroups. Each data subgroup is used to record the data blocks to be processed at the corresponding access frequency level. For example, based on the access frequency level, the data blocks can be divided into warm (warn) data subgroups and hot (hot) data subgroups, or into cold (cold) data subgroups, warm (warn) data subgroups, and hot (hot) data subgroups. This embodiment does not limit the specific grouping method.
[0145] Correspondingly, the lower the access frequency level, the less important the data in the data block to be processed is, so it can be refreshed first, that is, the target data block to be processed is selected from the data subgroup with the lowest access frequency level.
[0146] To facilitate querying, the data group or data subgroup may be in the form of a linked list, such as a hash linked list.
[0147] Figure 8 A schematic diagram showing the organization of all data blocks to be processed in the form of a linked list is shown. Figure 8 As shown in the figure, based on the business IO priority, the data blocks to be processed can be divided into four priority levels, namely priority 0 to 3, forming four linked lists (data groups); each generated data block to be processed can be attached to the corresponding linked list. In addition, each priority linked list is divided into two sub-linked lists (i.e., data subgroups): warm chain and hot chain. Based on the IO access frequency level, the corresponding data block to be processed is attached to the warm chain or hot chain.
[0148] See also Figure 8 As shown, for a priority 0 warm link, the target cache is divided into multiple LRU blocks of 1MB each. Each LRU block can carry multiple pending data blocks. The least recently used data block is then determined based on the LRU (Least Recently Used) algorithm. If the pending data block is 4KB in size, then one LRU block can carry up to 256 pending data blocks.
[0149] When refreshing the disk later, for example, when selecting the data blocks to be processed based on step A1 or step A2, the low-priority linked lists are refreshed first (the data blocks to be processed need to exist), and the warm links are refreshed first, and then the hot links.
[0150] Optionally, the method further includes step B2.
[0151] Step B2: for a pending data block belonging to the first data subgroup of the target data group, when the access frequency level of the pending data block becomes the second data subgroup corresponding to the target data group, switch the pending data block from the first data subgroup to the second data subgroup.
[0152] In this embodiment, for any data subgroup within a data group, if a corresponding pending data block exists within it, the access frequency level of each pending data block can be determined in real time. For ease of description, the pending data block is referred to as a pending data block, and the data group and data subgroup to which the pending data block belongs are referred to as the target data group and the first data subgroup, respectively. Since the priority of the pending data block remains unchanged, the target data group to which it belongs remains unchanged.
[0153] If the access frequency of the pending data block changes, but rather the corresponding access frequency level changes, and the changed access frequency level no longer corresponds to the first data subgroup to which it currently belongs, a new data subgroup, i.e., a second data subgroup, needs to be determined based on the changed access frequency level, thereby switching the pending data block from the first data subgroup to the second data subgroup. It is understood that the second data subgroup is another data subgroup belonging to the target data group.
[0154] by Figure 8 Taking the linked list shown as an example, for the data block 1-1 to be processed, it belongs to the warm link (i.e., the first data subgroup) under the linked list (i.e., the target data group) with a priority of 0; if the access frequency level of the data block 1-1 to be processed increases, and the data stored therein can be classified as hot data, the hot link can be used as the second data subgroup, and the data block 1-1 to be processed can be switched from the warm link to the hot link, so that the linked list can be updated in real time, and in conjunction with the disk flushing strategy, it is ensured that unimportant data is flushed first.
[0155] This embodiment can achieve performance acceleration on the computing side through distributed caching, and its functional modules can be specifically divided into: acceleration cache layer, cache ownership layer, driver layer and front end.
[0156] The acceleration cache layer implements acceleration based on cache software. It handles I / O read and write operations passed by QEMU, manages data and memory in the target cache, and provides I / O concurrency conflict detection and cache hit rate verification. Furthermore, it flushes pending data to the distributed storage pool and simultaneously updates metadata persistence. It also eliminates clean data from the target cache. Upon restart, metadata is loaded into memory, and the memory request management unit is attached to the LRU unit, allowing for the removal of the corresponding management unit based on the LRU algorithm.
[0157] The cache persistence layer is used to implement distributed cache cluster management, provide high redundancy, ensure strong data consistency in network and node disconnection scenarios, permanently store cache metadata, and ultimately flush user business data to the distributed storage pool. It also provides business operations such as cluster disk expansion, node expansion, alarms, and creation of distributed cache disks.
[0158] The driver layer manages device drivers for the acceleration cache layer in QEMU through dynamic library loading; and provides lifecycle management for the corresponding virtual machines.
[0159] The front end is used to provide a simple interface operation for the virtual machine on the computing side; for example, the acceleration function of the virtual machine can be turned on and off through the interface operation.
[0160] The data caching method provided in this embodiment takes over business IO through distributed caching to implement acceleration functions and achieve the purpose of performance improvement; the entire architecture logic level is clear and simple, and can provide stable, reliable, and low-fluctuation IO read and write performance for business virtual machines. It is particularly suitable for low-latency, high-IOPS businesses, and the processing capacity is greatly improved, thereby meeting business demands and improving customer satisfaction.
[0161] After the acceleration function provided by this embodiment is enabled for the virtual machine, the standalone latency of 4KB random read and write performance can be significantly reduced, and the 4KB disk endurance and cluster 4KB random read performance can be significantly improved. 4KB random write can exceed 200,000 IOPS. In addition, the IO performance volatility of the standalone performance in high-concurrency scenarios can be controlled at a low level, and virtual machines do not interfere with each other. It can provide a highly reliable distributed cache to ensure stable and efficient offline and online migration, and ensure the consistency of application data in the event of power outages, network disconnections, and disk unplugging. In addition, it can also support ISCSI (Internet Small Computer System Interface) and RDMA (remote direct memory access) protocol access, with a wide range of applications.
[0162] In this embodiment, a data caching device is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments. The details that have been described will not be repeated here. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0163] This embodiment provides a data cache device, such as Figure 9 As shown, including:
[0164] A request module 901 is configured to, in response to a read request for first business data initiated by a target virtual machine, search for the first business data in a target cache on a computing side, where the target cache is allocated for the target virtual machine from a cache device on the computing side;
[0165] The processing module 902 is configured to send the first service data in the target cache to the target virtual machine if the first service data exists in the target cache.
[0166] In some optional implementations, the processing module 902 is further configured to:
[0167] If the first business data does not exist in the target cache, the first business data is read from the target logical volume, sent to the target virtual machine, and written to the target cache; the target logical volume is a logical volume allocated from the storage device for the target virtual machine.
[0168] In some optional implementations, the request module 901 is further configured to: write the second business data into the target cache in response to a write request for the second business data initiated by the target virtual machine;
[0169] The processing module 902 is also used to: write the data to be written in the target cache to the target logical volume corresponding to the target virtual machine; the target logical volume is a logical volume divided from the storage device for the target virtual machine, and the data to be written is business data that has not been written to the target logical volume, and the data to be written includes the second business data.
[0170] In some optional implementations, the target cache is divided into a plurality of data blocks;
[0171] The processing module 902 writes the to-be-written data in the target cache to the target logical volume corresponding to the target virtual machine, including:
[0172] At each preset time interval, a preset number of to-be-processed data blocks are selected from the target cache as target to-be-processed data blocks, and the data in the target to-be-processed data blocks are written to the target logical volume; the to-be-processed data blocks written to the target logical volume are marked as written to the logical volume.
[0173] In some optional implementations, the processing module 902 selects a preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks at preset time intervals, and writes data in the target to-be-processed data blocks to the target logical volume, including:
[0174] When the target cache is idle, selecting a first preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks at intervals of a first preset time, and writing data in the first preset number of target to-be-processed data blocks to the target logical volume;
[0175] When the target cache is not idle, selecting a second preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks at intervals of a second preset time, and writing data in the second preset number of target to-be-processed data blocks to the target logical volume;
[0176] The ratio of the first preset number to the first preset time is greater than the ratio of the second preset number to the second preset time.
[0177] In some optional implementations, writing the data in the first preset number of target to-be-processed data blocks to the target logical volume includes:
[0178] writing the data in the first preset number of target to-be-processed data blocks to the target logical volume in parallel;
[0179] Writing the data in the second preset number of target to-be-processed data blocks to the target logical volume includes:
[0180] The data in the second preset number of target to-be-processed data blocks are serially written to the target logical volume.
[0181] In some optional implementations, the target cache includes a plurality of data groups; each of the data groups is configured with a corresponding priority, and each of the data groups includes data blocks to be processed with the same priority;
[0182] The processing module 902 selects a preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks, including:
[0183] A preset number of data blocks to be processed are selected from the data group having data blocks to be processed and having the lowest priority as target data blocks to be processed.
[0184] In some optional embodiments, the data group includes a plurality of data subgroups; each of the data subgroups is configured with a corresponding access frequency level, and each of the data subgroups includes data blocks to be processed having the same priority level and access frequency level;
[0185] The processing module 902 selects a preset number of data blocks to be processed from the data group having data blocks to be processed and having the lowest priority as target data blocks to be processed, including:
[0186] A preset number of data blocks to be processed are selected from the data group with the lowest priority level and the data subgroup with the lowest access frequency level as target data blocks to be processed.
[0187] In some optional implementations, the target cache is determined according to the following operations:
[0188] Dividing a corresponding target cache for a target virtual machine from a plurality of distributed cache devices; the target cache is divided into a plurality of data blocks;
[0189] The request module 901 writes the second service data into the target cache, including:
[0190] Writing the second service data into a target data block allocated to a target cache in at least one cache device, and recording global metadata and local metadata of the second service data;
[0191] The global metadata is used to record the node location of the cache device storing the second business data, and the local metadata is used to record the storage location of the target data block in the cache device storing the second business data;
[0192] The request module 901 searches for the first business data in the target cache on the computing side, including:
[0193] Locating a target cache device for storing the first service data according to the global metadata;
[0194] The storage location of the first business data in the target cache device is determined according to the local metadata corresponding to the target cache device, and the first business data is extracted from the storage location.
[0195] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0196] The data cache device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, including a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0197] The present invention also provides a computer device. Figure 10 , Figure 10 is a structural diagram of a computer device provided by an optional embodiment of the present invention, such as Figure 10 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components utilize different buses to communicate with each other and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of a GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories. Equally, multiple computer devices can be connected, and each device provides part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 10 A processor 10 is taken as an example.
[0198] The processor 10 may be a central processing unit, a network processor, or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic, or any combination thereof.
[0199] The memory 20 stores instructions that can be executed by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0200] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and application programs required for at least one function; the data storage area may store data created based on the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0201] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0202] The computer device further includes a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0203] The embodiment of the present invention also provides a computer-readable storage medium. The above-mentioned method according to the embodiment of the present invention can be implemented in hardware, firmware, or implemented as a computer code that can be recorded in a storage medium, or implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and downloaded through a network and will be stored in a local storage medium, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor or hardware, the method shown in the above embodiment is implemented.
[0204] A portion of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the form in which the computer program instruction exists in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc. Accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium that can be accessed by the computer.
[0205] Although the embodiments of the present invention have been described with reference to the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations should all be included in the scope of protection of the present invention.
Claims
1. A data caching method, characterized in that: The method comprises: In response to a read request for first business data initiated by a target virtual machine, searching for the first business data in a target cache on a computing side, where the target cache is allocated for the target virtual machine from a cache device on the computing side; If the first service data exists in the target cache, the first service data in the target cache is sent to the target virtual machine.
2. The method according to claim 1, characterized in that The method further comprises: If the first business data does not exist in the target cache, the first business data is read from the target logical volume, sent to the target virtual machine, and written to the target cache; the target logical volume is a logical volume allocated from the storage device for the target virtual machine.
3. The method according to claim 1, characterized in that The method further comprises: In response to a write request for second business data initiated by the target virtual machine, writing the second business data into the target cache; The data to be written in the target cache is written to the target logical volume corresponding to the target virtual machine; the target logical volume is a logical volume divided from the storage device for the target virtual machine, the data to be written is business data that has not been written to the target logical volume, and the data to be written includes the second business data.
4. The method according to claim 3, characterized in that The target cache is divided into a plurality of data blocks; Writing the to-be-written data in the target cache to the target logical volume corresponding to the target virtual machine includes: At each preset time interval, selecting a preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks, and writing data in the target to-be-processed data blocks to the target logical volume; The data blocks to be processed written to the target logical volume are marked as having been written to the logical volume.
5. The method according to claim 4, characterized in that The method of selecting a preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks at each preset time interval, and writing data in the target to-be-processed data blocks to the target logical volume, includes: When the target cache is idle, selecting a first preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks at intervals of a first preset time, and writing data in the first preset number of target to-be-processed data blocks to the target logical volume; When the target cache is not idle, selecting a second preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks at intervals of a second preset time, and writing data in the second preset number of target to-be-processed data blocks to the target logical volume; The ratio of the first preset number to the first preset time is greater than the ratio of the second preset number to the second preset time.
6. The method according to claim 5, characterized in that Writing the data in the first preset number of target to-be-processed data blocks to the target logical volume includes: writing the data in the first preset number of target to-be-processed data blocks to the target logical volume in parallel; Writing the data in the second preset number of target to-be-processed data blocks to the target logical volume includes: The data in the second preset number of target to-be-processed data blocks are serially written to the target logical volume.
7. The method according to claim 4, characterized in that The target cache includes a plurality of data groups; each of the data groups is configured with a corresponding priority, and each of the data groups includes data blocks to be processed with the same priority; The selecting a preset number of to-be-processed data blocks from the target cache as target to-be-processed data blocks includes: A preset number of data blocks to be processed are selected from the data group having data blocks to be processed and having the lowest priority as target data blocks to be processed.
8. The method according to claim 7, characterized in that The data group includes a plurality of data subgroups; each of the data subgroups is configured with a corresponding access frequency level, and each of the data subgroups includes data blocks to be processed with the same priority level and access frequency level; The step of selecting a preset number of data blocks to be processed from the data group having data blocks to be processed and having the lowest priority as target data blocks to be processed includes: A preset number of data blocks to be processed are selected from the data group with the lowest priority level and the data subgroup with the lowest access frequency level as target data blocks to be processed.
9. The method according to claim 3, characterized in that The target cache is determined based on the following operations: Allocate corresponding target cache for the target virtual machine from the distributed multiple cache devices; The target cache is divided into a plurality of data blocks; Writing the second service data into the target cache includes: Writing the second service data into a target data block allocated to a target cache in at least one cache device, and recording global metadata and local metadata of the second service data; The global metadata is used to record the node location of the cache device storing the second business data, and the local metadata is used to record the storage location of the target data block in the cache device storing the second business data; The searching for the first service data in the target cache on the computing side includes: Locating a target cache device for storing the first service data according to the global metadata; The storage location of the first business data in the target cache device is determined according to the local metadata corresponding to the target cache device, and the first business data is extracted from the storage location.
10. A data cache device, characterized in that: The device comprises: a request module, configured to search for the first business data in a target cache on a computing side in response to a read request for the first business data initiated by the target virtual machine, the target cache being allocated for the target virtual machine from a cache device on the computing side; The processing module is configured to send the first business data in the target cache to the target virtual machine if the first business data exists in the target cache.
11. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the data caching method according to any one of claims 1 to 9 by executing the computer instructions.
12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the data caching method according to any one of claims 1 to 9.