Distributed storage data reading efficiency optimization method, system, device and medium
By dividing the SSD into primary partitions and obsolete partitions, and using the index tree and bitmap mechanism, the problem of SSD capacity limitations and excessive copy data occupancy is solved, the data reading efficiency of the distributed storage system is improved, and the overall IO response is improved rate.
Patent Information
- Application Number
- CN202111067855.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-13
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2041-09-13
AI Technical Summary
In distributed storage systems, solid-state drives (SSDs) have only a 30% increase in reading efficiency due to capacity limitations and excessive copy data usage, and competition for random read IO, write IO, and write-back IO resources has resulted in The overall response rate slows down, affecting business performance.
By dividing the SSD space into a primary partition and an obsolete partition, the primary partition is used to store the primary data, and the obsolete partition is used to store copy data. The data in the obsolete partition is written back to the hard disk drive (HDD) under preset conditions. Release SSD space to store more primary data, and use the index tree and bitmap mechanism to optimize data reading and writing.
It effectively increases the storage space of primary data in SSD, writes back dirty data in eliminated partitions in a timely manner, improves data reading efficiency, avoids resource contention, and improves the overall IO response rate.
Smart Images

Figure CN113778338B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a distributed storage data reading efficiency optimization method, system, equipment and medium, belonging to the technical field of databases. Background Art
[0002] In applications where the database realizes the separation of computing and storage, data is stored in a distributed storage cluster. The data read and write efficiency of the database is directly affected by the read and write efficiency of the storage layer. In order to improve the read and write efficiency of the storage layer, in current distributed storage applications, media such as SSD (Solid State Disk or Solid State Drive) are usually used as caches for HDD (Hard Disk Drive) hard disks, thereby accelerating the process. In order to ensure the reliability of stored data, the industry basically adopts a multi-copy method to store the master and replica of IO data on different nodes; at the same time, for IO data, both the master and the replica will be first stored in the SSD to achieve a fast response to upper-level requests; the background will then write the SSD data back to the HDD through a write-back method to free up SSD space to store new IO data.
[0003] However, if Figure 1 As shown in the figure, SSDs have a capacity limit (such as 1TB). If calculated based on three copies of data, the amount of primary data in the SSD only occupies 1 / 3 of the SSD capacity, while the copy occupies 2 / 3 of the SSD capacity. In a distributed storage system, the upper-layer IO request only reads the primary data. If the storage layer wants to respond to read requests quickly, it is ideal to store as much data as possible on the SSD. However, currently only 1 / 3 of the valid data can be read from the SSD, and 2 / 3 of the space is occupied by the copy data. Using SSD can only improve the reading efficiency by 30%.
[0004] If the replica data is written directly to the HDD instead of the SSD, all the space of the SSD can be used to store the master data. However, there will be resource competition among the upper-layer random read IO, random write IO (random IO of a large number of replicas written directly to the HDD), and IO that writes back to the HDD, resulting in an overall slower IO response rate, which has a greater impact on the upper-layer business. Summary of the invention
[0005] In view of the above problems, the purpose of the present invention is to provide a method, system, device and medium for optimizing the reading efficiency of distributed storage data. By reasonably allocating SSD storage space, SSD can be used to store more master data to improve reading efficiency.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] A first aspect of the present invention is to provide a method for optimizing the reading efficiency of distributed storage data, comprising:
[0008] Initialize the SSD and divide the SSD space into two partitions: the primary partition and the obsolete partition, which are used to store the primary data and the replica data respectively;
[0009] Receive upper-layer IO requests, and store IO data to the SSD according to the received IO requests, or read corresponding data from the SSD and / or HDD;
[0010] When the preset trigger condition is met, the copy data stored in the SSD eliminated partition is written back to the HDD.
[0011] Preferably, the initialization of the SSD includes setting the ratio of eliminated partitions and the ratio of eliminated partition flushing water level.
[0012] Preferably, the proportion of eliminated partitions and the proportion of eliminated partition re-flush water levels are 20% and 40% respectively.
[0013] Preferably, the method of receiving an upper-layer IO request and reading and writing IO data according to the received IO request includes:
[0014] Determine the type of upper-layer IO request received:
[0015] If it is a front-end write IO request, the IO data to be written is stored in the corresponding partition of the SSD, and the index tree and bitmap in the memory are updated based on the IO data; the bitmap includes a first bitmap and a second bitmap, which are respectively used to indicate whether data is stored in each section of HDD obsolete data and each section of non-obsolete data;
[0016] If it is a front-end read IO request, a data index key is generated based on the received IO request and the index tree in the memory is searched. The corresponding data is read from the SSD or HDD according to the search result.
[0017] Preferably, the method of storing the IO data to be written into the corresponding partition of the SSD and updating the index tree and bitmap in the memory based on the IO data includes:
[0018] The IO request mark is judged. If the IO data currently to be written is primary data, the IO data is stored in the primary partition of the SSD. If the IO data currently to be written is replica data, the IO data is stored in the obsolete partition of the SSD.
[0019] Generate a data index key and update the index tree in memory based on the data index key;
[0020] Update the corresponding bitmap in memory according to the starting offset and size of the current IO data.
[0021] Preferably, the method of generating a data index key based on the received IO request and searching the index tree, and reading corresponding data from the SSD or HDD according to the search result includes:
[0022] Generate data index key based on IO request;
[0023] The index tree is traversed based on the generated data index key. If the key can be found, the data is read from the SSD, otherwise the data is read from the HDD.
[0024] Preferably, the method of writing the copy data stored in the SSD obsolete partition back to the HDD after the preset trigger condition is met comprises the following steps:
[0025] ① Traverse the first bitmap and search each section of HDD eliminated data;
[0026] ② Determine whether there is dirty data in each corresponding segment of HDD eliminated data. If not, proceed to step ③, otherwise proceed to step ⑤;
[0027] ③ Traverse the second bitmap and search for each section of non-eliminated data on the HDD;
[0028] ④ Determine whether there is dirty data in each corresponding segment of the HDD non-eliminated data. If yes, proceed to step ⑤, otherwise return to step ①;
[0029] ⑤Traverse the index tree to find the data index key;
[0030] ⑥Read data on the SSD according to the data index key;
[0031] ⑦Write the data read from the SSD back to the HDD according to the data index key;
[0032] ⑧ Determine whether the proportion of dirty data stored in the SSD obsolete partition is lower than the preset obsolete partition flushing water level proportion. If so, end the write-back, otherwise return to step ①.
[0033] A second aspect of the present invention is to provide a distributed storage data reading efficiency optimization system, comprising:
[0034] The SSD initialization module is used to initialize the SSD and divide the SSD space into two partitions: the primary partition and the eliminated partition, which are used to store the primary data and the replica data respectively;
[0035] An IO request receiving and executing module, used for receiving an upper-layer IO request, storing IO data to the SSD according to the received IO request, or reading corresponding data from the SSD and / or HDD;
[0036] The data write-back module is used to write the data stored in the SSD obsolete partition back to the HDD after the preset trigger condition is met, thus releasing the SSD space for new IO data to be written.
[0037] The third aspect of the present invention is to provide a processing device, which includes at least a processor and a memory, wherein the memory stores a computer program, and when the processor runs the computer program, it executes the steps of the distributed storage data reading efficiency optimization method.
[0038] A fourth aspect of the present invention is to provide a computer storage medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the steps of the distributed storage data reading efficiency optimization method according to any one of claims 1 to 7.
[0039] The present invention adopts the above technical solution, which has the following advantages:
[0040] 1) The present invention divides the SSD into two logical areas, a primary partition and a discarded partition, stores primary data in the primary partition, and stores copy data in the discarded partition, which can effectively increase the storage space of the primary data in the SSD and store more primary data.
[0041] 2) The present invention reasonably sets the proportion of dirty data stored in the eliminated partition of the SSD, and can timely write back the dirty data stored in the eliminated partition of the SSD, thereby improving data reading efficiency.
[0042] 3) The present invention establishes an index tree mechanism, divides the HDD into sections, and sets a bitmap to determine whether each section stores dirty data, thereby further improving data reading efficiency.
[0043] Therefore, the present invention can be widely applied to the field of optimizing database data reading efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 This is a schematic diagram of the existing SSD capacity;
[0045] Figure 2 is a flow chart of a method for optimizing distributed storage data reading efficiency provided by an embodiment of the present invention;
[0046] Figure 3 is a schematic diagram of setting the ratio of SSD obsolete partitions provided by an embodiment of the present invention;
[0047] Figure 4 1. It is a schematic diagram of setting the proportion of back flushing water level in the eliminated partition provided by an embodiment of the present invention;
[0048] Figure 5 It is a schematic diagram of the front-end write IO request processing flow provided by an embodiment of the present invention;
[0049] FIG. 6( a ) and FIG. 6( b ) are index tree update processes provided by an embodiment of the present invention;
[0050] Figure 7 It is a schematic diagram of HDD segment division provided by an embodiment of the present invention;
[0051] Figure 8 It is a schematic diagram of the front-end read IO request processing flow provided by an embodiment of the present invention;
[0052] Fig. 9 It is a schematic diagram of the write-back task flow provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The present invention is described in detail below with reference to the accompanying drawings and embodiments.
[0054] Example 1
[0055] like Figure 2 As shown, a distributed storage data reading efficiency optimization method provided in this embodiment includes the following steps:
[0056] 1) Initialize the SSD and divide the SSD space into two partitions: the primary partition and the eliminated partition, which are used to store the primary data and the replica data respectively.
[0057] It should be noted that, in the embodiment of the present invention, the primary partition of the SSD space is used to store primary data, and the eliminated partition is used to store replica data.
[0058] Specifically, when the embodiment of the present invention initializes the SSD, it mainly includes setting the ratio of eliminated partitions and the ratio of eliminated partition flushing water level.
[0059] like Figure 3 As shown in the figure, the ratio of eliminated partitions refers to the percentage of eliminated partitions in the total capacity of the SSD space.
[0060] Optionally, for an SSD with a total capacity of 1TB, the percentage of the obsolete partition can be set to 20%, then 800GB of the space in the SSD is used as the primary partition to store primary data, and the remaining 200G of space is used as the obsolete partition to store replica data.
[0061] like Figure 4As shown in the figure, the percentage of the flushing water level of the eliminated partition refers to the percentage of dirty data volume to the total capacity of the eliminated partition. When the dirty data volume of the eliminated partition reaches the percentage of the flushing water level of the eliminated partition, the SSD data will be flushed to the HDD. Among them, dirty data refers to data that is still on the SSD and has not been flushed back to the HDD. If the data is flushed back to the HDD, the SSD space occupied by it can be released for subsequent IO use.
[0062] Optionally, in an embodiment of the present invention, the ratio of the flushing water level of the eliminated partition is set to 40%. This is because, if the ratio of the flushing water level of the eliminated partition is set too low, when the front-end IO volume is relatively large, the HDD flushing operation will be too frequent, resulting in resource contention for read and write IO and affecting the overall performance; if the ratio of the flushing water level of the eliminated partition is set too high, a large amount of dirty data cannot be flushed back in time, and the flushing rate cannot keep up with the front-end IO rate, resulting in the failure to write the copy data to the SSD in time and blocking the upper-level business.
[0063] 2) Receive an upper-layer IO request, and store the IO data to the SSD according to the received IO request, or read the corresponding data from the SSD and / or HDD.
[0064] Specifically, step 2) includes the following steps:
[0065] 2.1) Determine the type of the received upper-layer IO request. If it is a front-end write IO request, proceed to step 2.2), otherwise proceed to step 2.3).
[0066] It should be noted that, in the embodiment of the present invention, each IO request sent by the upper layer is required to indicate whether the current IO data is primary data or replica data.
[0067] 2.2) If Figure 5 As shown, the IO data to be written is stored in the corresponding partition of the SSD, and the index tree and bitmap in the memory are updated based on the IO data.
[0068] Specifically, the steps include:
[0069] 2.2.1) Determine the IO request mark. If the IO data currently to be written is primary data, store the IO data in the primary partition of the SSD. If the IO data currently to be written is replica data, store the IO data in the obsolete partition of the SSD.
[0070] Optionally, when storing the IO data, the method is: according to the size of the received IO data, apply for corresponding space on the SSD and store it in a corresponding partition.
[0071] 2.2.2) Generate a data index key and update the index tree in memory based on the data index key.
[0072] As shown in FIG. 6(a) and FIG. 6(b), an embodiment of the present invention maintains an index tree in the memory, and the index tree is used to quickly locate the data index key according to the starting offset (offset) of the IO data, and then read the data on the SSD according to the data index key for writing back or responding to upper-level read requests.
[0073] Preferably, when generating a data index key according to the received IO data, the following procedure can be used:
[0074] Struct io_key
[0075] {
[0076] long data_size; / / io size
[0077] long hdd_no; / / HDD number
[0078] long ssd_no; / / ssd number
[0079] long offset_hdd; / / the starting offset of io on hdd
[0080] long offset_ssd; / / The starting offset of io on ssd
[0081] bool is_dirty; / / Is the data dirty?
[0082] }
[0083] 2.2.3) Update the corresponding bitmap in memory according to the starting offset and size of the current IO data.
[0084] like Figure 7 As shown, in the embodiment of the present invention, the HDD capacity is divided into segments according to 64MB, each segment corresponds to a bit, the bit is 1, indicating that the segment has dirty data, and the bit is 0, indicating that the segment has been written back or has no dirty data; preferably, the embodiment of the present invention maintains two sets of bitmaps in the memory, the first bitmap and the second bitmap are respectively used to indicate whether each segment of HDD obsolete data and each segment of non-obsolete data stores data, and different types of bitmaps are updated according to the front-end IO data type (master / replica).
[0085] 2.3) Generate a data index key based on the received IO request and search the index tree in the memory, and read the corresponding data from the SSD or HDD according to the search results.
[0086] Specifically, Figure 8 As shown, the following steps are included:
[0087] 2.3.1) Generate data index key based on the received IO request.
[0088] 2.3.2) Based on the generated data index key, the index tree in the memory is traversed. If the data can be found, the data is read from the SSD, otherwise the data is read from the HDD.
[0089] 3) When the preset trigger condition is reached, the copy data stored in the SSD eliminated partition is written back to the HDD, freeing up the SSD space for new IO data to be written.
[0090] like Fig. 9 As shown in the figure, when the amount of dirty data stored in the SSD eliminated partition reaches the preset eliminated partition flushing water level ratio, the method of writing the data stored in the eliminated partition back to the HDD is:
[0091] 3.1) Traverse the first bitmap and search each section of HDD eliminated data;
[0092] 3.2) Determine whether there is dirty data in each corresponding segment of HDD eliminated data, if not, proceed to step 3.3), otherwise proceed to step 3.5);
[0093] 3.3) Traverse the second bitmap and search for each section of non-eliminated data on the HDD;
[0094] 3.4) Determine whether there is dirty data in each corresponding segment of the HDD non-eliminated data. If yes, proceed to step 3.5), otherwise return to step 3.1);
[0095] 3.5) Traverse the index tree to find the data index key;
[0096] 3.6) Read data on the SSD according to the data index key;
[0097] 3.7) Write the data read from the SSD back to the HDD according to the data index key;
[0098] 3.8) Determine whether the proportion of dirty data stored in the SSD obsolete partition is lower than the preset obsolete partition flushing water level proportion. If so, end the write-back, otherwise return to step 3.1).
[0099] Example 2
[0100] The above-mentioned embodiment 1 provides a distributed storage data reading efficiency optimization method, and correspondingly, this embodiment provides a distributed storage data reading efficiency optimization system. The system provided in this embodiment can implement the distributed storage data reading efficiency optimization method of embodiment 1, and the system can be implemented by software, hardware, or a combination of software and hardware. For example, the system may include integrated or separate functional modules or functional units to perform the corresponding steps in each method of embodiment 1. Since the recognition system of this embodiment is basically similar to the method embodiment, the process described in this embodiment is relatively simple, and the relevant parts can refer to the partial description of embodiment 1. The embodiment of the system of this embodiment is only schematic.
[0101] The distributed storage data reading efficiency optimization system provided in this embodiment includes:
[0102] The SSD initialization module is used to initialize the SSD and divide the SSD space into two partitions: the primary partition and the eliminated partition, which are used to store the primary data and the replica data respectively;
[0103] An IO request receiving and executing module, used for receiving an upper-layer IO request, storing IO data to the SSD according to the received IO request, or reading corresponding data from the SSD and / or HDD;
[0104] The data write-back module is used to write the data stored in the SSD obsolete partition back to the HDD after the preset trigger condition is met, thus releasing the SSD space for new IO data to be written.
[0105] Example 3
[0106] This embodiment provides a processing device corresponding to the distributed storage data reading efficiency optimization method provided in this embodiment 1. The processing device can be a processing device for a client, such as a mobile phone, a laptop computer, a tablet computer, a desktop computer, etc., to execute the method of embodiment 1.
[0107] The processing device includes a processor, a memory, a communication interface and a bus, and the processor, the memory and the communication interface are connected through the bus to complete mutual communication. The memory stores a computer program that can be run on the processor, and the processor executes the distributed storage data reading efficiency optimization method provided in this embodiment 1 when running the computer program.
[0108] In some implementations, the memory may be a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory.
[0109] In some other implementations, the processor may be a central processing unit (CPU), a digital signal processor (DSP), or other general-purpose processors of various types, which are not limited herein.
[0110] Example 4
[0111] The method for optimizing the distributed storage data reading efficiency of this embodiment 1 can be specifically implemented as a computer program product, which may include a computer-readable storage medium carrying computer-readable program instructions for executing the distributed storage data reading efficiency optimization method described in this embodiment 1.
[0112] Computer readable storage media can be tangible devices that hold and store instructions used by instruction execution devices. Computer readable storage media can be, for example, but not limited to, electronic storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any combination thereof.
[0113] It should be noted that the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present application. Each box in the flowchart or block diagram may represent a module, a program segment or a part of the code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions.
[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
[0115] The above embodiments are only used to illustrate the present invention, wherein the structure, connection mode and manufacturing process of each component may be changed. Any equivalent transformations and improvements based on the technical solution of the present invention should not be excluded from the protection scope of the present invention.
Claims
1. A method for optimizing the reading efficiency of distributed storage data. It is characterized in that include: Initialize the SSD and divide the SSD space into two partitions: the primary partition and the obsolete partition, which are used to store the primary data and the replica data respectively; When the SSD is initialized, the ratio of eliminated partitions and the ratio of the flushing water level of eliminated partitions are set; Receive upper-layer IO requests, and store IO data to the SSD according to the received IO requests, or read corresponding data from the SSD and / or HDD; The method of receiving an upper-layer IO request and reading and writing IO data according to the received IO request includes: Determine the type of upper-layer IO request received: If it is a front-end write IO request, the IO data to be written is stored in the corresponding partition of the SSD, and the index tree and bitmap in the memory are updated based on the IO data; the bitmap includes a first bitmap and a second bitmap, which are respectively used to indicate whether data is stored in each section of HDD obsolete data and each section of non-obsolete data; If it is a front-end read IO request, a data index key is generated based on the received IO request and the index tree in the memory is searched. The corresponding data is read from the SSD or HDD according to the search result. When the preset trigger condition is met, the copy data stored in the SSD eliminated partition is written back to the HDD; The method for writing the copy data stored in the SSD obsolete partition back to the HDD after the preset trigger condition is met includes the following steps: ① Traverse the first bitmap and search each section of HDD eliminated data; ② Determine whether there is dirty data in each corresponding segment of HDD eliminated data. If not, proceed to step ③, otherwise proceed to step ⑤; ③ Traverse the second bitmap and search for each section of non-eliminated data on the HDD; ④ Determine whether there is dirty data in each corresponding segment of the HDD non-eliminated data. If yes, proceed to step ⑤, otherwise return to step ①; ⑤Traverse the index tree to find the data index key; ⑥Read data on the SSD according to the data index key; ⑦Write the data read from the SSD back to the HDD according to the data index key; ⑧ Determine whether the proportion of dirty data stored in the SSD obsolete partition is lower than the preset obsolete partition flushing water level proportion. If so, end the write-back, otherwise return to step ①.
2. A distributed storage data reading efficiency optimization method as claimed in claim 1, It is characterized in that The proportion of eliminated partitions and the proportion of eliminated partition refresh water levels are 20% and 40% respectively.
3. A distributed storage data reading efficiency optimization method as claimed in claim 1, It is characterized in that The method of storing the IO data to be written into the corresponding partition of the SSD and updating the index tree and bitmap in the memory based on the IO data includes: The IO request mark is judged. If the IO data currently to be written is primary data, the IO data is stored in the primary partition of the SSD. If the IO data currently to be written is replica data, the IO data is stored in the obsolete partition of the SSD. Generate a data index key and update the index tree in memory based on the data index key; Update the corresponding bitmap in memory according to the starting offset and size of the current IO data.
4. A distributed storage data reading efficiency optimization method as claimed in claim 1, It is characterized in that The method of generating a data index key based on a received IO request and searching the index tree, and reading corresponding data from the SSD or HDD according to the search result, includes: Generate data index key based on IO request; The index tree is traversed based on the generated data index key. If the key can be found, the data is read from the SSD, otherwise the data is read from the HDD.
5. A distributed storage data reading efficiency optimization system, It is characterized in that include: The SSD initialization module is used to initialize the SSD and divide the SSD space into two partitions: a primary partition and a discarded partition, which are used to store primary data and replica data respectively; when initializing the SSD, the discarded partition ratio and the discarded partition backwash water level ratio are set; The IO request receiving and executing module is used to receive the upper layer IO request, store the IO data to the SSD according to the received IO request, or read the corresponding data from the SSD and / or HDD, including: Determine the type of upper-layer IO request received: If it is a front-end write IO request, the IO data to be written is stored in the corresponding partition of the SSD, and the index tree and bitmap in the memory are updated based on the IO data; the bitmap includes a first bitmap and a second bitmap, which are respectively used to indicate whether data is stored in each section of HDD obsolete data and each section of non-obsolete data; If it is a front-end read IO request, a data index key is generated based on the received IO request and the index tree in the memory is searched. The corresponding data is read from the SSD or HDD according to the search result. The data write-back module is used to write the data stored in the SSD obsolete partition back to the HDD after the preset trigger condition is met, so as to release the SSD space for new IO data to be written, including the following steps: ① Traverse the first bitmap and search each section of HDD eliminated data; ② Determine whether there is dirty data in each corresponding segment of HDD eliminated data. If not, proceed to step ③, otherwise proceed to step ⑤; ③ Traverse the second bitmap and search for each section of non-eliminated data on the HDD; ④ Determine whether there is dirty data in each corresponding segment of the HDD non-eliminated data. If yes, proceed to step ⑤, otherwise return to step ①; ⑤Traverse the index tree to find the data index key; ⑥Read data on the SSD according to the data index key; ⑦Write the data read from the SSD back to the HDD according to the data index key; ⑧ Determine whether the proportion of dirty data stored in the SSD obsolete partition is lower than the preset obsolete partition flushing water level proportion. If so, end the write-back, otherwise return to step ①.
6. A processing device, the processing device comprising at least a processor and a memory, the memory storing a computer program, It is characterized in that When the processor runs the computer program, the processor executes the steps of the method for optimizing the reading efficiency of distributed storage data according to any one of claims 1 to 4.
7. A computer storage medium, It is characterized in that Computer-readable instructions are stored thereon, and the computer-readable instructions can be executed by a processor to implement the steps of the distributed storage data reading efficiency optimization method according to any one of claims 1 to 4.
