Multi-thread-based time sequence database dynamic capacity expansion method
By adopting a method of multi-thread distribution and synchronization of virtual node data in the time series database, the problems of slow load balancing and inaccessible database in the existing technology are solved, efficient dynamic expansion and database availability are achieved, and the expansion performance and performance are significantly improved. reliability.
Patent Information
- Application Number
- CN202410836532.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-09-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The load balancing speed of the existing time series database is slow during dynamic expansion, and the database cannot be accessed when distributing data files, which affects business use.
A multi-thread-based method is used to dynamically expand the time series database. By creating multiple threads to distribute virtual node data and synchronize incremental data, the dynamic expansion process of copying first and then merging is realized.
It significantly improves the load balancing rate, shortens the node expansion time, keeps the database available during the expansion process, and achieves imperceptible dynamic expansion.
Smart Images

Figure CN118673000A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database node expansion, and in particular to a multi-threaded based time series database dynamic expansion method. Background Art
[0002] In the existing technical solution, when using a time series database for dynamic expansion, the steps are: (1) Sending SQL to add a new node will add a new node based on the original cluster, and there will be no data in the new node; (2) Perform load balancing and evenly distribute the vnode data files in the original cluster to the newly added nodes to achieve load balancing.
[0003] There are several defects in the dynamic expansion of this existing technical solution: (1) Load balancing is slow. Since load balancing uses a single thread to distribute the original database data files to the newly added nodes, when the data files are too large, it takes a lot of time for load balancing to distribute the data files.
[0004] (2) The database cannot be accessed during the load balancing process. When the load balancing system distributes data files to new nodes, the data files are inaccessible, resulting in the inability to access the database during the load balancing process, thus affecting business use.
[0005] Therefore, when the amount of data in the database is too large, such as when a time series database needs to expand its nodes, since load balancing uses a single thread, it takes a long time to distribute files, and the database cannot be accessed during the load balancing process. Therefore, node expansion will affect the business for a long time. Summary of the invention
[0006] Based on the above technical problems, the present invention proposes a dynamic expansion method of a time series database based on multi-threading, improves the single-thread method of the existing technology, and realizes the dynamic expansion of the time series database. The specific technical solution is as follows.
[0007] The multi-threaded dynamic expansion method of a time series database includes the following steps: Step S1: sequentially obtain a time series database new node request and a load balancing request; Step S2: Determine whether the node is online. If not, return an error message and re-acquire the load balancing request. Step S3: If the node is online, directly obtain the vnode virtual node ID that needs to be distributed to other newly added nodes; Step S4: Create multiple threads, distribute vnode virtual nodes to newly added nodes, and synchronize incremental data at the same time; Step S5: merge the data files, delete the node virtual node data files distributed by the original database cluster to the newly added nodes, and complete the dynamic expansion of the cluster.
[0008] Specifically, the acquisition of the newly added node request in step S1 is as follows: the user sends a SQL structured query language to acquire the newly added node request, and adds the newly added node information to the cluster.
[0009] Specifically, the step S1 of acquiring the load balancing request is as follows: the user sends the SQL structured query language to acquire the load balancing request, and verifies the status of the newly added node.
[0010] Specifically, the acquisition of the vnode virtual node ID of the newly added node in step S1 specifically includes: obtaining the vnode virtual node ID that needs to be distributed to the newly added node, taking one vnode virtual node ID from each node in the original cluster at a time as the vnode virtual node distributed to the newly added node, until the number of vnode virtual nodes of all nodes remains basically equal.
[0011] Specifically, the distribution of the vnode virtual node in step S4 specifically includes: Create a thread for each vnode virtual node that needs to be distributed, and one thread is responsible for a corresponding vnode virtual node; Each thread copies a copy of its corresponding vnode virtual node to the same-level directory, and after the copy is completed, the copied vnode virtual node is distributed to the newly added node.
[0012] Specifically, the synchronization of incremental data in step S4 specifically includes: synchronizing data during load balancing, creating corresponding data incremental files in the newly added nodes, and synchronizing data of the corresponding vnode virtual node during load balancing to the newly added files.
[0013] Specifically, the data file merging in step S5 includes the full copy files in the node distribution process and the incremental files during the synchronous load balancing period.
[0014] Beneficial effects of the invention: The invention proposes a method for dynamic expansion of a time series database based on multithreading, which uses multithreading to perform dynamic expansion by first copying, then moving, and finally merging. This method has a huge improvement in performance and does not affect business use. Based on one thread being responsible for one vnode data file, the load balancing rate can be faster, thereby shortening the time consumed by node expansion. The method adopts the process from copying to moving and finally merging, so as to expand the node without affecting the original data, so that the database is in an available state during the expansion, and there is no perception of dynamic expansion. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a flow chart of the architecture of the method for dynamic expansion of a time series database based on multithreading of the present invention. DETAILED DESCRIPTION
[0016] In order to have a clearer understanding of the technical features, purposes and effects of the present invention, specific embodiments of the present invention are now described with reference to the accompanying drawings.
[0017] The present invention proposes a method for dynamic expansion of a time series database based on multithreading, and its architecture is as follows: Figure 1 As shown, the multi-threaded time series database dynamic expansion method includes the following steps: Step S1: sequentially obtain a time series database new node request and a load balancing request; Step S2: Determine whether the node is online. If not, return an error message and re-acquire the load balancing request. Step S3: If the node is online, directly obtain the vnode virtual node ID that needs to be distributed to other newly added nodes; Step S4: Create multiple threads, distribute vnode virtual nodes to newly added nodes, and synchronize incremental data at the same time; Step S5: merge the data files, delete the node virtual node data files distributed by the original database cluster to the newly added nodes, and complete the dynamic expansion of the cluster.
[0018] In this embodiment, the acquisition of the newly added node request in step S1 is specifically as follows: the user sends a SQL structured query language to acquire the newly added node request, and adds the newly added node information to the cluster.
[0019] In this embodiment, the step S1 of acquiring the load balancing request specifically includes: the user sends the SQL structured query language to acquire the load balancing request, and verifies the status of the newly added node.
[0020] In this embodiment, step S1 of obtaining the vnode virtual node ID of the newly added node specifically includes: obtaining the vnode virtual node ID that needs to be distributed to the newly added node, taking one vnode virtual node ID from each node in the original cluster at a time as the vnode virtual node distributed to the newly added node, until the number of vnode virtual nodes of all nodes remains basically equal.
[0021] In this embodiment, step S4 of distributing vnode virtual nodes specifically includes: Create a thread for each vnode virtual node that needs to be distributed, and one thread is responsible for a corresponding vnode virtual node; Each thread copies a copy of its corresponding vnode virtual node to the same-level directory, and after the copy is completed, the copied vnode virtual node is distributed to the newly added node.
[0022] In this embodiment, the synchronization of incremental data in step S4 specifically includes: synchronizing data during load balancing, creating corresponding data incremental files in the newly added nodes, and synchronizing data of the corresponding vnode virtual node during load balancing to the newly added files.
[0023] In this embodiment, the data file merging in step S5 includes the full copy files in the node distribution process and the incremental files during the synchronous load balancing period.
[0024] In one embodiment, in view of the problem that the database expansion of the prior art solution is implemented by moving vnode data files in a single thread, during which the user cannot access the database, affecting normal use, the present invention adopts a multi-threaded form to perform dynamic expansion by first copying, then moving, and finally merging. This method has a huge improvement in performance and does not affect business use, including the following steps: 1. Get a new node request. The user sends SQL to get a new node request and add the new node information to the cluster.
[0025] 2. Obtain load balancing request. Obtain load balancing request through SQL sent by the user, and verify the status of the newly added node. If the node is not online, return an error message to the user. If the node is online, execute the subsequent process.
[0026] 3. Get vnodeID. Get the vnodeID that needs to be distributed to the newly added node, and take one vnodeID from each node in the original cluster at a time as the vnode distributed to the newly added node until the number of vnodes on all nodes remains basically equal.
[0027] 4. Distribute vnodes to newly added nodes. Create a thread for each vnode that needs to be distributed, that is, one thread is responsible for a corresponding vnode. Each thread copies a copy of its corresponding vnode to the same-level directory. After the copy is completed, the copied vnode is distributed to the newly added nodes.
[0028] 5. Synchronize incremental data. Synchronize the data during load balancing, create incremental files on the newly added nodes, and synchronize the data of the corresponding vnode during the load evolution period to the newly added files.
[0029] 6. Merge data files. After the full copy is completed, merge it with the incremental file.
[0030] 7. Delete the vnode data files distributed by the original database cluster to the newly added nodes. At this point, the dynamic expansion of the cluster is complete.
[0031] The technical solution of the present invention has the following technical improvements: Performance improvement: One thread is responsible for one vnode data file, which can make the load balancing rate faster and shorten the time consumed by node expansion.
[0032] Improved reliability: This method uses a process from copying to moving and finally merging to expand the node without affecting the original data, so that the database is available during the expansion and the dynamic expansion is imperceptible.
[0033] The present invention has shown and described the basic principles and main features of the present invention and the advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A multi-threaded time series database dynamic expansion method, characterized in that: The following steps are involved: Step S1: sequentially obtain a time series database new node request and a load balancing request; Step S2: Determine whether the node is online. If not, return an error message and re-acquire the load balancing request. Step S3: If the node is online, directly obtain the vnode virtual node ID that needs to be distributed to other newly added nodes; Step S4: Create multiple threads, distribute vnode virtual nodes to newly added nodes, and synchronize incremental data at the same time; Step S5: merge the data files, delete the node virtual node data files distributed by the original database cluster to the newly added nodes, and complete the dynamic expansion of the cluster.
2. According to the multi-threaded time series database dynamic expansion method according to claim 1, it is characterized in that: The step S1 of acquiring the request for adding a new node specifically includes: the user sends a SQL structured query language to acquire the request for adding a new node, and adds the information of the new node to the cluster.
3. According to the multi-threaded time series database dynamic expansion method according to claim 1, it is characterized in that: The step S1 of acquiring the load balancing request specifically includes: the user sends the SQL structured query language to acquire the load balancing request, and verifies the status of the newly added node.
4. The multi-threaded time series database dynamic expansion method according to claim 1, characterized in that: The step S1 of obtaining the vnode virtual node ID of the newly added node specifically includes: obtaining the vnode virtual node ID that needs to be distributed to the newly added node, taking one vnode virtual node ID from each node in the original cluster at a time as the vnode virtual node distributed to the newly added node, until the number of vnode virtual nodes of all nodes remains basically equal.
5. The multi-threaded time series database dynamic expansion method according to claim 1 is characterized in that: The distribution of the vnode virtual node in step S4 specifically includes: Create a thread for each vnode virtual node that needs to be distributed, and one thread is responsible for a corresponding vnode virtual node; Each thread copies a copy of its corresponding vnode virtual node to the same-level directory, and after the copy is completed, the copied vnode virtual node is distributed to the newly added node.
6. The multi-threaded time series database dynamic expansion method according to claim 5 is characterized in that: The synchronization of incremental data in step S4 specifically includes: synchronizing data during load balancing, creating corresponding data incremental files in the newly added nodes, and synchronizing data of the corresponding vnode virtual node during load balancing to the newly added files.
7. The multi-threaded time series database dynamic expansion method according to claim 6 is characterized in that: The data file merging in step S5 includes the full copy files in the node distribution process and the incremental files during the synchronous load balancing period.
Citation Information
Patent Citations
Database cluster data migration method and device and electronic equipment
CN111324596A
Data backup method and device, equipment and storage medium
CN114237974A
Capacity expansion method and device of storage node
CN115268777A
Database capacity expansion method and device, electronic equipment and storage medium
CN116069763A
Time sequence database system and management method and device thereof, node equipment and storage medium
CN116226226A
