Data sharding balancing method and device based on distributed storage, and electronic device
By collecting and evaluating the data distribution of each logical volume in a distributed storage system, and combining standard deviation and coefficient of variation for migration optimization, the imprecision and lack of priority of existing data sharding balancing strategies are solved, achieving more efficient data sharding balancing and improving system performance and stability.
Patent Information
- Application Number
- CN202510940454.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-08
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2045-07-08
AI Technical Summary
In existing distributed storage systems, data sharding balancing strategies suffer from insufficient accuracy in assessing imbalance, lack of volume-level balancing considerations, and a lack of prioritization in migration decisions, leading to unnecessary or missed migrations that affect system performance and stability.
By collecting the data distribution and number of shards of each logical volume on each storage node in the distributed storage system, and combining the standard deviation and coefficient of variation for detailed evaluation, unbalanced logical volumes are identified, and migration loop operations are performed until the system is balanced or the preset number of migrations is reached.
It achieves more accurate assessment of imbalanced states, improves the accuracy of rebalancing decisions, optimizes migration priorities, reduces unnecessary migrations, and enhances the overall performance and stability of the system.
Smart Images

Figure CN120469813B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of distributed technology, and more specifically, to a data sharding and balancing method, apparatus, and electronic device based on distributed storage. Background Technology
[0002] Currently, distributed storage systems are widely used to provide scalable and highly available storage services. Data is typically organized into volumes and further divided into multiple shards, which are distributed across multiple physical or virtual storage nodes (Infinity Block Server Daemon, XBSD) in a cluster. With changes in cluster size (node additions, removals, and failover), data writing and deletion, or natural fluctuations in node load, the distribution of shards across different XBSD nodes can become uneven. This imbalance can lead to some nodes being overloaded, affecting the overall system performance and stability, while other nodes experience low resource utilization. Therefore, a data rebalancing mechanism is an indispensable key component of distributed storage systems, used to dynamically adjust the distribution of shards to achieve load balancing.
[0003] In related technologies, distributed storage systems generally adopt a rebalancing strategy based on the maximum-minimum difference (Max-MinDifference). Specifically: (1) Count the total number of shards currently hosted on each XBSD. (2) Find the XBSD with the most (Max) and the fewest (Min) shards in the cluster. (3) If the difference between Max and Min exceeds a preset threshold (e.g., Max-Min>1), the system is considered to be in an unbalanced state. (4) Select one or more shards from the XBSD with a large number of shards (usually above average or the most) and migrate them to the XBSD with a small number of shards (usually below average or the fewest). (5) Repeat this process until the difference in the number of shards on all XBSDs meets the balance condition.
[0004] However, the above-mentioned rebalancing strategy based on maximum-minimum difference mainly focuses on the difference in the total number of shards at the global XBSD level, and performs migration through a series of heuristic rules (such as randomly selecting the source XBSD and volume, and selecting the target XBSD with the fewest shards). This can easily lead to the following problems:
[0005] (1) The assessment of imbalance is not accurate enough: Simply comparing the maximum and minimum number of shards on the global XBSD may not fully reflect the true dispersion of the data distribution. For example, even if the difference between the maximum and minimum is not large, there may be some XBSDs with concentrated loads while other XBSDs have extremely low loads. Such subtle overall distribution unevenness is difficult to capture by simple difference.
[0006] (2) Lack of detailed consideration of volume-level balance: This method usually first considers the total number of XBSD shards, but pays insufficient attention to whether the distribution of shards within a volume is balanced across different XBSDs. Even if the distribution of shards in a volume is very uneven within its allowed XBSD range, it may be ignored because the total number of XBSD shards is within an acceptable range.
[0007] (3) Migration decisions may not be optimal: When choosing which volume and which shard to migrate, there may be a lack of clear priorities. Volumes with acceptable balance may be migrated while volumes that need more balance are overlooked. Furthermore, the selection of the target XBSD may be based solely on minimizing its current total number of shards, without fully considering the contribution of the migration to the "dispersion" of the distribution of a specific volume.
[0008] (4) May lead to unnecessary migration or omission of necessary migration: Due to the relatively coarse evaluation criteria, unnecessary migration may be performed when the overall distribution is acceptable but the local difference triggers the threshold; or when the local difference is small but the overall variance is large, the necessary migration may not be triggered.
[0009] There is currently no effective solution to the above problems. Summary of the Invention
[0010] This invention provides a data sharding balancing method, apparatus, and electronic device based on distributed storage, to at least solve the technical problem of low effectiveness in balancing distributed storage systems in related technologies.
[0011] According to one aspect of the present invention, a data sharding balancing method based on distributed storage is provided, comprising: collecting the data distribution of each logical volume on each storage node and the number of data shards on each storage node in the distributed storage system at the current moment, wherein a logical volume is a logical storage unit divided in the distributed storage system, the data in the logical volume is divided into multiple data shards, and each data shard is stored on a storage node; performing an initial balance check on the distributed storage system based on the number of data shards on each storage node to obtain a check result; if the check result indicates that the distributed storage system is unbalanced, determining the balance state of each logical volume based on the data distribution of each logical volume on each storage node; and performing a migration loop operation on the unbalanced logical volumes in the case of unbalanced logical volumes until the distributed storage system is balanced or the number of migrations reaches a preset number.
[0012] Furthermore, the step of performing an initial balance check on the distributed storage system based on the number of data shards on each storage node includes: determining the maximum and minimum number of data shards based on the number of data shards on each storage node; determining that the distributed storage system is balanced if the difference between the maximum and minimum number of data shards is less than or equal to a preset threshold; and determining that the distributed storage system is unbalanced if the difference between the maximum and minimum number of data shards is greater than the preset threshold.
[0013] Further, the data distribution includes: the number of data shards of the logical volume distributed on each storage node; and the step of determining the equilibrium state of each logical volume based on the data distribution of each logical volume on each storage node, including: for each logical volume, determining the maximum and minimum distribution numbers based on the number of data shards of the logical volume distributed on each storage node; determining that the logical volume is in a balanced state if the difference between the maximum and minimum distribution numbers is less than or equal to a preset distribution threshold; or, if the difference between the maximum and minimum distribution numbers is greater than the preset distribution threshold, determining the standard deviation and coefficient of variation of the logical volume based on the data distribution of the logical volume on each storage node; determining that the logical volume is in an unbalanced state if the standard deviation of the logical volume is greater than a preset standard deviation threshold and / or the coefficient of variation is greater than a preset variation threshold; and determining that the logical volume is in a balanced state if the standard deviation of the logical volume is less than or equal to a preset standard deviation threshold and the coefficient of variation is less than or equal to a preset variation threshold.
[0014] Furthermore, the steps of determining the standard deviation and coefficient of variation of the logical volume based on the data distribution of the logical volume on each storage node include: determining the distribution mean based on the number of data shards of the logical volume distributed on each storage node; determining the standard deviation based on the number of data shards of the logical volume distributed on each storage node and the distribution mean; and determining the coefficient of variation based on the standard deviation and the distribution mean.
[0015] Furthermore, in the case of unbalanced logical volumes, a migration loop operation is performed on the unbalanced logical volumes until the distributed storage system is balanced or the number of migrations reaches a preset number. This includes: when there are multiple unbalanced logical volumes, determining the migration score of each logical volume; identifying the logical volume with the highest migration score as the target logical volume and selecting data shards to be migrated from the target logical volume; determining the target storage center from the distributed storage system; migrating the data shards to be migrated from the source storage center to the target storage center to obtain the migration result, where the source storage center is the storage center where the data shards to be migrated were stored before the migration; if the migration result indicates successful migration, updating the data distribution of the target logical volume on each storage node and the number of data shards on each storage node, and accumulating the migration count; based on the updated data distribution of the target logical volume on each storage node and the number of data shards on each storage node, reassessing the balance of the distributed storage system until the distributed storage system is balanced or the number of migrations reaches a preset number.
[0016] Further, the step of determining the migration score for each logical volume includes: for each logical volume, if the total number of data shards in the logical volume is less than or equal to the number of storage nodes, determining the maximum storage amount of the data shards of the logical volume stored on a single storage node; determining the error value of the logical volume based on the maximum storage amount; determining the migration score of the logical volume based on the error value and the total number of data shards; if the total number of data shards in the logical volume is greater than the number of storage nodes, determining the maximum and minimum storage amounts of the data shards of the logical volume stored on a single storage node; determining the actual storage difference based on the maximum and minimum storage amounts; determining the average storage amount based on the total number of data shards and the number of nodes; and determining the migration score of the logical volume based on the actual storage difference, the ideal storage difference, and the average storage amount, wherein the ideal storage difference is determined based on the average storage amount.
[0017] Further, the step of determining the target storage center from the distributed storage system includes: selecting a storage center from the distributed storage system where the data shards of the target logical volume are not stored as a candidate storage center; selecting the candidate storage center with the smallest number of data shards from all candidate storage centers as the target storage center; if there are multiple candidate storage centers with the smallest number of data shards among all candidate storage centers, selecting one candidate storage center from the multiple candidate storage centers with the smallest number of data shards as the target storage center; or, if there is no storage center from the distributed storage system where the data shards of the target logical volume are not stored, selecting the storage center with the smallest number of data shards from all storage centers as the target storage center; if there are multiple storage centers with the smallest number of data shards among all storage centers, selecting one storage center from the multiple storage centers with the smallest number of data shards as the target storage center.
[0018] According to another aspect of the present invention, a data sharding balancing device based on distributed storage is also provided, comprising: a collection unit, configured to collect the data distribution of each logical volume on each storage node and the number of data shards on each storage node in the distributed storage system at the current moment, wherein a logical volume is a logical storage unit divided in the distributed storage system, and the data in the logical volume is divided into multiple data shards, each data shard being stored on a storage node; a checking unit, configured to perform an initial balancing check on the distributed storage system based on the number of data shards on each storage node, and obtain a check result; a judgment unit, configured to determine the balancing state of each logical volume based on the data distribution of each logical volume on each storage node when the check result indicates that the distributed storage system is unbalanced; and a migration unit, configured to perform a migration loop operation on the unbalanced logical volumes when there are unbalanced logical volumes, until the distributed storage system is balanced or the number of migrations reaches a preset number.
[0019] Furthermore, the inspection unit includes: a first determining module, used to determine the maximum number of data shards and the minimum number of data shards based on the number of data shards on each storage node; a second determining module, used to determine that the distributed storage system is balanced when the difference between the maximum number of data shards and the minimum number of data shards is less than or equal to a preset threshold; and a third determining module, used to determine that the distributed storage system is unbalanced when the difference between the maximum number of data shards and the minimum number of data shards is greater than a preset threshold.
[0020] Further, the data distribution includes: the number of data shards of the logical volume distributed on each storage node. The judgment unit includes: a fourth determining module, used to determine the maximum and minimum distribution numbers for each logical volume based on the number of data shards of the logical volume distributed on each storage node; a fifth determining module, used to determine that the logical volume is in a balanced state when the difference between the maximum and minimum distribution numbers is less than or equal to a preset distribution threshold; a sixth determining module, used to determine the standard deviation and coefficient of variation of the logical volume based on the data distribution of the logical volume on each storage node when the difference between the maximum and minimum distribution numbers is greater than a preset distribution threshold; a seventh determining module, used to determine that the logical volume is in an unbalanced state when the standard deviation of the logical volume is greater than a preset standard deviation threshold and / or the coefficient of variation is greater than a preset variation threshold; and an eighth determining module, used to determine that the logical volume is in a balanced state when the standard deviation of the logical volume is less than or equal to a preset standard deviation threshold and the coefficient of variation is less than or equal to a preset variation threshold.
[0021] Furthermore, the sixth determining module includes: a first determining submodule, used to determine the distribution mean based on the number of data shards of the logical volume distributed on each storage node; a second determining submodule, used to determine the standard deviation based on the number of data shards of the logical volume distributed on each storage node and the distribution mean; and a third determining submodule, used to determine the coefficient of variation based on the standard deviation and the distribution mean.
[0022] Further, the migration unit includes: a ninth determination module, used to determine the migration score of each logical volume when there are multiple logical volumes in an unbalanced state; a tenth determination module, used to determine the logical volume indicated by the maximum migration score as the target logical volume and select the data shards to be migrated from the target logical volume; an eleventh determination module, used to determine the target storage center from the distributed storage system; a first migration module, used to migrate the data shards to be migrated from the source storage center to the target storage center and obtain the migration result, wherein the source storage center is the storage center where the data shards to be migrated were stored before the migration; a first update module, used to update the data distribution of the target logical volume on each storage node and the number of data shards on each storage node when the migration result indicates successful migration, and to accumulate the migration count; and a first judgment module, used to re-judge the balance state of the distributed storage system based on the updated data distribution of the target logical volume on each storage node and the number of data shards on each storage node, until the distributed storage system is balanced or the migration count reaches a preset number.
[0023] Further, the ninth determining module includes: a fourth determining submodule, used for determining, for each logical volume, the maximum storage capacity of a data shard on a single storage node when the total number of data shards in the logical volume is less than or equal to the number of storage nodes; a fifth determining submodule, used for determining the error value of the logical volume based on the maximum storage capacity; a sixth determining submodule, used for determining the migration score of the logical volume based on the error value and the total number of data shards; a seventh determining submodule, used for determining the maximum and minimum storage capacity of a data shard on a single storage node when the total number of data shards in the logical volume is greater than the number of storage nodes; an eighth determining submodule, used for determining the actual storage difference based on the maximum and minimum storage capacity; a ninth determining submodule, used for determining the average storage capacity based on the total number of data shards and the number of nodes; and a tenth determining submodule, used for determining the migration score of the logical volume based on the actual storage difference, the ideal storage difference, and the average storage capacity, wherein the ideal storage difference is determined based on the average storage capacity.
[0024] Furthermore, the eleventh determining module includes: a first selection submodule, used to select a storage center from the distributed storage system where the data shards of the target logical volume are not stored as a candidate storage center; a second selection submodule, used to select the candidate storage center with the smallest number of data shards from all candidate storage centers as the target storage center; a first selection submodule, used to select any one of the candidate storage centers with the smallest number of data shards as the target storage center when there are multiple candidate storage centers with the smallest number of data shards among all candidate storage centers; a second selection submodule, used to select the storage center with the smallest number of data shards as the target storage center when there is no storage center in the distributed storage system where the data shards of the target logical volume are not stored; and a third selection submodule, used to select any one of the storage centers with the smallest number of data shards as the target storage center when there are multiple storage centers with the smallest number of data shards among all storage centers.
[0025] According to another aspect of the present invention, a computer program product is also provided, including a non-volatile computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the data sharding and balancing method based on distributed storage as described above.
[0026] According to another aspect of the present invention, an electronic device is also provided, including one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement any of the above-described data sharding and balancing methods based on distributed storage.
[0027] In this invention, the data distribution of each logical volume on each storage node and the number of data shards on each storage node in the distributed storage system at the current moment are collected. Based on the number of data shards on each storage node, an initial balance check is performed on the distributed storage system to obtain the check result. If the check result indicates that the distributed storage system is unbalanced, the balance status of each logical volume is determined based on the data distribution of each logical volume on each storage node. If there are logical volumes in an unbalanced state, a migration loop operation is performed on the unbalanced logical volumes until the distributed storage system is balanced or the number of migrations reaches a preset number. This solves the technical problem of low effectiveness in balancing distributed storage systems in related technologies.
[0028] In this invention, the data distribution of each logical volume on each storage node and the number of data shards on each storage node in the distributed storage system can be collected first. Then, a quick initial balance check is performed. If the system is found to be unbalanced, the balance status of each logical volume is evaluated in depth, the logical volumes that really need to be rebalanced are identified, and iterative shard migration operations are performed on them until the system is balanced or the preset migration limit is reached. This achieves the purpose of accurately identifying the data imbalance state, thereby realizing the technical effect of optimizing dynamic balancing of data shards, avoiding unnecessary data movement, and improving the overall performance and stability of the system. Attached Figure Description
[0029] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:
[0030] Figure 1 This is a flowchart of an optional data sharding and balancing method based on distributed storage according to an embodiment of the present invention;
[0031] Figure 2 This is a schematic diagram of an optional Shard rebalancing process according to an embodiment of the present invention;
[0032] Figure 3 This is a schematic diagram of an optional volume imbalance evaluation process according to an embodiment of the present invention;
[0033] Figure 4This is a schematic diagram of an optional Shard migration execution iteration process according to an embodiment of the present invention;
[0034] Figure 5 This is a schematic diagram of an optional data sharding and balancing device based on distributed storage according to an embodiment of the present invention;
[0035] Figure 6 This is a hardware structure block diagram of an electronic device (or mobile device) for a data sharding balancing method based on distributed storage according to an embodiment of the present invention. Detailed Implementation
[0036] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0037] It should be noted that the terms "first," "second," etc., used in this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0038] To facilitate understanding of the present invention by those skilled in the art, some terms or nouns involved in the various embodiments of the present invention are explained below:
[0039] Distributed storage system: refers to a system in which data is distributed and stored on multiple independent storage node devices.
[0040] XBSD (Infinity Block Server Daemon): A storage node or service instance in a distributed storage system.
[0041] Volume: A logical storage unit divided within a storage system; the basic unit for user data storage.
[0042] Shard: A further division of data within a volume; it is the smallest unit for data migration and distribution.
[0043] Data balancing / rebalancing: In a distributed storage system, adjusting the distribution of shards among different XBSDs to achieve a relatively uniform XBSD load (such as storage capacity, I / O (input / output) pressure).
[0044] Standard Deviation (StdDev): A statistical concept used to measure the dispersion of a set of values relative to its mean. In this invention, it refers to the standard deviation of the quantity distribution of a volume's shards across various XBSDs.
[0045] Coefficient of Variation (CV): The ratio of standard deviation to mean, it is a relative indicator of the dispersion of data. In this invention, it refers to the ratio of the standard deviation of a volume shard distribution to the average number of shards on each XBSD.
[0046] It should be noted that all related information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, and displayed data) collected and involved in this invention are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of this data comply with the relevant laws, regulations, and standards of the relevant regions, necessary confidentiality measures have been taken, and it does not violate public order and good morals. Corresponding operation entry points are provided for users to choose to authorize or refuse. For example, this system has an interface with relevant users or organizations. Before obtaining relevant information, a request to obtain the information needs to be sent to the aforementioned user or organization through the interface, and the relevant information is obtained only after receiving consent from the aforementioned user or organization.
[0047] This invention proposes a method for optimizing the distribution balance of data shards in a distributed storage system based on statistical indicators. This method achieves better load balancing by accurately assessing the dispersion of shards within each data unit across storage nodes (XBSD) and combining this with a priority strategy for iterative migration.
[0048] This invention provides a method for optimizing the data shard distribution balance in a distributed storage system based on statistical indicators, which can solve the following problems or achieve the following objectives:
[0049] (1) More accurate assessment of data imbalance: Provides a method based on statistical indicators (standard deviation and coefficient of variation) to more accurately quantify the degree of imbalance in the distribution of a single volume shard across its available XBSD nodes.
[0050] (2) Improve the accuracy of rebalancing decisions: Based on more accurate imbalance assessment, more effectively identify volumes and related :XBSD nodes that really need to be rebalanced.
[0051] (3) Optimize migration priority: Introduce a priority scoring mechanism to prioritize the processing of volumes with the most unbalanced shard distribution, thereby improving the efficiency and effectiveness of rebalancing.
[0052] (4) Reduce unnecessary shard migrations: By using more detailed equilibrium judgment conditions, unnecessary shard migrations can be avoided within the acceptable range of statistical fluctuations, thus saving system resources.
[0053] (5) Enhance the adaptability of the rebalancing strategy: make the rebalancing strategy better adaptable to complex scenarios where different volumes have different total shards and different XBSD constraints (preset lists, including: the first type of list (i.e., prohibiting the storage of a volume's shards on certain storage nodes listed in the list) and the second type of list (i.e., (if it exists and is not empty) only allowing the storage of a volume's shards on specific storage nodes listed in the list).
[0054] (6) Improve the overall uniformity and dispersion of data distribution: By comprehensively considering the statistical characteristics of the intra-volume:Shard distribution and the selection strategy of target nodes, promote a more uniform and dispersed distribution of data.
[0055] The present invention will now be described in detail with reference to various embodiments.
[0056] Example 1
[0057] According to an embodiment of the present invention, an embodiment of a data sharding and balancing method based on distributed storage is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0058] Figure 1 This is a flowchart of an optional data sharding and load balancing method based on distributed storage according to an embodiment of the present invention, such as... Figure 1 As shown, the method includes the following steps:
[0059] Step S101: Collect the data distribution of each logical volume on each storage node and the number of data shards on each storage node in the distributed storage system at the current moment. Here, a logical volume is a logical storage unit divided in the distributed storage system. The data in the logical volume is divided into multiple data shards, and each data shard is stored on a storage node.
[0060] In this embodiment of the invention, before initiating the load balancing check, it is necessary to fully understand the current data status of the distributed storage system. First, check the status and configuration of each storage node in the distributed storage system (cluster) at the current moment, i.e., the current running status of all storage nodes (XBSD) in the cluster (such as whether they are online, whether they are undergoing maintenance or upgrades, etc.). Then, statistically analyze the data distribution of each logical volume on each storage node in the distributed storage system. That is, from the perspective of each logical volume, determine which storage nodes all its shards (i.e., the multiple data shards into which the data in the logical volume is divided) are specifically distributed at the current moment, and the number on each storage node. Also, statistically analyze which logical volumes each storage node specifically carries, and the detailed information of each data shard after these logical volumes are divided, to obtain the load profile of each storage node (i.e., the number of data shards currently carried by each storage node).
[0061] Here, "current moment" refers to the real-time point at which data is collected, ensuring that the information is up-to-date and helps in making timely and accurate decisions. "Distributed storage system" refers to a storage architecture where data is partitioned and stored across multiple independent storage nodes within a cluster to improve data reliability and system scalability. A "logical volume" is the basic organizational form of user data in the system (i.e., a logical storage unit partitioned in a distributed storage system), similar to a volume in a file system, but existing in a distributed environment, where data is further divided into "data shards." These shards are distributed across different "storage nodes," each of which can be a physical server or a virtual storage entity. "Data distribution" refers to the data shard layout status of each logical volume across various storage nodes, including the number of shards and their location information. "Number of data shards" is the total number of data shards across all logical volumes on all storage nodes. Collecting the above data is necessary for subsequent load balancing checks.
[0062] In some alternative embodiments, data placement constraints of the distributed storage system can be determined, i.e., sharding placement rules for a specific logical volume. For example, a first list is set, which prohibits shards of a volume from being stored on certain storage nodes listed in the list; a second list is set, which, if it exists and is not empty, only allows shards of a volume to be stored on specific storage nodes listed in the list.
[0063] Step S102: Based on the number of data shards on each storage node, perform an initial load balancing check on the distributed storage system to obtain the check results.
[0064] In this embodiment of the invention, after collecting the number of data shards for each storage node, an initial balance check can be performed on the distributed storage system to quickly assess whether the system is in a state of significant imbalance.
[0065] Here, the "check results" provide intuitive feedback on the system's equilibrium state, used to determine whether it's necessary to proceed to a more detailed evaluation phase and data migration process. This initial check helps filter out simple cases that don't require rebalancing, saving computational resources.
[0066] Step S103: If the inspection result indicates that the distributed storage system is unbalanced, determine the balance status of each logical volume based on the data distribution of each logical volume on each storage node.
[0067] In this embodiment of the invention, when the "inspection results" indicate an overall system imbalance, it is necessary to further delve into the imbalance diagnosis at the level of each "logical volume". The balance status of the logical volumes can be determined based on the collected data distribution information of each logical volume on the storage nodes, including the number and location of shards.
[0068] Specifically, statistical analysis can be performed on the data distribution of each logical volume, calculating the standard deviation and coefficient of variation of its data shard distribution across each storage node. This serves as an indicator of the uniformity of the data distribution for that volume. If the standard deviation or coefficient of variation of the data distribution of any volume exceeds a preset "balanced state" threshold, the volume is determined to be in an unbalanced state. Because the overall dispersion of the data distribution is considered, it can more accurately identify problems where the overall differences are not significant but the local distribution is uneven.
[0069] Step S104: If there are logical volumes in an unbalanced state, perform a migration loop operation on the unbalanced logical volumes until the distributed storage system is balanced or the number of migrations reaches a preset number.
[0070] In this embodiment of the invention, if an unbalanced "logical volume" is found, a "migration loop operation" can be initiated for these volumes to improve the data distribution through the migration of data shards until the "balance" condition is met or the preset "migration count" limit is reached.
[0071] Here, the "balanced" condition can be that the difference between the maximum and minimum number of data shards on a storage node is less than or equal to 1, or that the data distribution of all volumes falls within an acceptable standard deviation and coefficient of variation threshold (i.e., the distributed storage system is balanced). Furthermore, setting a "preset number of times" can prevent infinite loops and excessive migrations, such as setting an upper limit on the number of migrations or the total number of volumes processed.
[0072] In this embodiment of the invention, during the cyclic operation, logical volumes with the highest degree of imbalance can be prioritized. The node with the largest number of shards is selected as the source node, and data shard migration is performed based on a series of optimization strategies (such as prioritizing nodes with low load that do not contain the volume as target nodes). This process is iterative, with data distribution information updated and the balance status reassessed after each migration, until balance is achieved or the number of migrations is reached. In this way, unnecessary data movement can be effectively reduced, and the shard distribution of logical volumes can be made more uniform, improving system performance and stability.
[0073] Figure 2 This is a schematic diagram of an optional shard rebalancing process according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following:
[0074] (1) Start: Rebalancing request.
[0075] (2) Initialization and data collection: Collect the number of shards of all XBSDs, the distribution of each volume on each XBSD, and the list limit.
[0076] (3) Quick balance check: The check is based on the global Max-Min difference. For example, if there is no list restriction and the maximum and minimum difference in the number of Shards among global XBSDs is less than or equal to 1, it is considered to be balanced and can be terminated directly: no rebalancing is required; if it is not balanced, further checks are required.
[0077] (4) Evaluation of imbalance per volume: StdDev / CV, that is, for each volume, the standard deviation (StdDev) and coefficient of variation (CV) are calculated based on its shard distribution on the available XBSD.
[0078] (5) Are there any volume imbalances? Determine if the StdDev or CV of any volume exceeds the preset threshold. If yes, perform Shard migration iteration; otherwise, you can end directly without rebalancing.
[0079] (6) Perform Shard migration iteration: If there is an unbalanced volume, enter the migration loop and try to move the Shard from the high-load XBSD to the low-load XBSD.
[0080] (7) Post-migration processing and result output: After the migration is completed, update the status and output the results.
[0081] In summary, we can first collect the data distribution of each logical volume on each storage node in the distributed storage system and the number of data shards on each storage node. Then, we can perform a quick initial balance check. If the system is found to be unbalanced, we can further evaluate the balance status of each logical volume, identify the logical volumes that truly need rebalancing, and perform iterative shard migration operations on them until the system is balanced or the preset migration limit is reached. This achieves the goal of accurately identifying the data imbalance state, thereby realizing the technical effect of optimizing dynamic data shard balancing, avoiding unnecessary data movement, improving the overall performance and stability of the system, and thus solving the technical problem of low effectiveness of balancing distributed storage systems in related technologies.
[0082] To achieve rapid load balancing checks on distributed storage systems, the data sharding load balancing method based on distributed storage provided in Embodiment 1 of this application determines the maximum and minimum number of data shards based on the number of data shards on each storage node. If the difference between the maximum and minimum number of data shards is less than or equal to a preset threshold, the distributed storage system is determined to be balanced. If the difference between the maximum and minimum number of data shards is greater than the preset threshold, the distributed storage system is determined to be unbalanced.
[0083] In this embodiment of the invention, the "maximum number of data shards" and "minimum number of data shards" can be determined based on the number of data shards on each storage node. The "maximum number of data shards" refers to the maximum number of shards a node can support, and the "minimum number of data shards" refers to the minimum number of shards a node can support. Then, a quick and intuitive method can be used to determine whether the entire distributed storage system is in a balanced state, i.e., comparing whether the difference between the "maximum number of data shards" and the "minimum number of data shards" is "less than or equal to a preset threshold." This threshold can be set based on system design goals and actual operating experience, and is generally a small positive integer, such as 1. If the difference meets this condition, it can be preliminarily determined that the system has achieved balance, and no further data rebalancing operation is needed. Conversely, if the "difference is greater than the preset threshold," it indicates that the system has an uneven load problem, requiring further analysis and adjustment.
[0084] In this embodiment, the difference between the "maximum number of data shards" and the "minimum number of data shards" is used to quickly identify significantly unbalanced situations. Combined with subsequent, more in-depth logical volume imbalance assessment, this not only reduces the computational complexity of the system evaluation but also ensures accurate identification of the imbalance state. Thus, while avoiding unnecessary data migration, it efficiently identifies and resolves load imbalance issues within the storage system, thereby improving the uniformity of data distribution across the entire system, reducing I / O pressure, and ultimately achieving the goal of improving the performance and stability of the distributed storage system. Furthermore, by flexibly utilizing "preset quantity thresholds," the system can adjust the sensitivity of rebalancing based on real-time load changes and business needs, enhancing the adaptability and controllability of the strategy.
[0085] Optionally, the data distribution includes the number of data shards of the logical volume distributed across each storage node. To improve the accuracy of determining the balance state of each logical volume, in the data shard balancing method based on distributed storage provided in Embodiment 1 of this application, for each logical volume, the maximum and minimum distribution numbers are determined based on the number of data shards of the logical volume distributed across each storage node; if the difference between the maximum and minimum distribution numbers is less than or equal to a preset distribution threshold, the logical volume is determined to be in a balanced state; or, if the difference between the maximum and minimum distribution numbers is greater than the preset distribution threshold, the standard deviation and coefficient of variation of the logical volume are determined based on the data distribution of the logical volume across each storage node; if the standard deviation of the logical volume is greater than a preset standard deviation threshold, and / or the coefficient of variation is greater than a preset variation threshold, the logical volume is determined to be in an unbalanced state; if the standard deviation of the logical volume is less than or equal to a preset standard deviation threshold and the coefficient of variation is less than or equal to a preset variation threshold, the logical volume is determined to be in a balanced state.
[0086] In this embodiment of the invention, for each logical volume in the system, the distribution of its data shards across various storage nodes (XBSD) can be analyzed first to obtain the specific distribution of the shards of that logical volume across different nodes, providing basic data for subsequent balance determination. By analyzing the distribution of the data shards of the logical volume across each storage node, the maximum and minimum distribution numbers can be determined. The "maximum distribution number" and "minimum distribution number" refer to the distribution number carried by the node with the most shards of the logical volume and the distribution number carried by the node with the fewest shards of the logical volume, respectively, among all relevant storage nodes.
[0087] Then, after obtaining the number of shards for each logical volume, a quick balance assessment can be performed. This assessment is based on whether the difference between the "maximum number of shards" and the "minimum number of shards" is less than or equal to a preset "distribution threshold." If the difference meets the condition—that is, the difference is less than or equal to the "distribution threshold"—then the shard distribution of that logical volume is preliminarily determined to be balanced. This allows for the rapid elimination of logical volumes with minimal shard distribution differences that do not actually require large-scale rebalancing operations, saving computational resources.
[0088] If the difference between the "maximum number of shards" and the "minimum number of shards" exceeds the "distribution threshold," it cannot be simply assumed that the shard distribution of that volume is balanced. In this case, a more refined evaluation is needed, based on the "standard deviation" and "coefficient of variation" to further determine whether the logical volume is truly unbalanced. The standard deviation represents the dispersion of the number of shards relative to the mean, while the "coefficient of variation" is the ratio of the standard deviation to the mean, used to measure relative dispersion. Only when the logical volume's "standard deviation" is greater than the "preset standard deviation threshold" and / or its "coefficient of variation" is greater than the "preset coefficient of variation threshold" can it be confirmed that the logical volume's shard distribution is unbalanced. This dual standard makes the judgment more accurate, enabling the identification of logical volumes that appear balanced on the surface but actually have excessively dispersed shard distributions.
[0089] If the standard deviation of the data shard distribution of a logical volume is less than or equal to the preset standard deviation threshold, and the coefficient of variation is less than or equal to the preset coefficient of variation threshold, then the logical volume is determined to be in equilibrium. This ensures that even with minor differences, as long as the overall distribution is relatively uniform, data migration operations will not be triggered, thus avoiding unnecessary system load and resource waste.
[0090] In this embodiment, a multi-level equilibrium evaluation mechanism is introduced to improve the intelligence and efficiency of the rebalancing strategy in the distributed storage system. Compared to evaluation methods that rely solely on maximum and minimum differences, this approach can more accurately diagnose logical volumes that truly require rebalancing. It also effectively avoids excessive processing of already balanced or nearly balanced volumes, thereby reducing unnecessary data migrations, network traffic, and I / O pressure, ultimately improving the overall performance and resource utilization of the storage system. Furthermore, by using standard deviation and coefficient of variation as evaluation criteria, this method is more adaptable to different business needs and constraints (such as preset lists), enabling precise data sharding distribution adjustments in various complex scenarios.
[0091] To improve the accuracy of determining the standard deviation and coefficient of variation of logical volumes, in the data sharding balancing method based on distributed storage provided in Embodiment 1 of this application, the average distribution value is determined based on the number of data shards of a logical volume distributed on each storage node; the standard deviation is determined based on the number of data shards of a logical volume distributed on each storage node and the average distribution value; and the coefficient of variation is determined based on the standard deviation and the average distribution value.
[0092] In this embodiment of the invention, the distribution average can be calculated based on the number of data shards of the logical volume distributed across each storage node and the number of storage nodes. The distribution average refers to the average number of shards of the logical volume distributed across all relevant storage nodes. By summing the number of shards distributed across all nodes and then dividing by the total number of nodes, a value reflecting the central trend of shard distribution (i.e., the distribution average) can be obtained. The calculation formula is as follows:
[0093] ;
[0094] in, This represents the number of data shards of the logical volume distributed on the i-th storage node, where n represents the number of storage nodes on which the data shards of the logical volume are distributed.
[0095] After determining the distribution mean, the "standard deviation" can be calculated based on the number of data shards distributed across each storage node of the logical volume and the distribution mean. Standard deviation is a statistical metric used to measure the dispersion of a set of values relative to its mean. In this embodiment, the standard deviation indicates the magnitude of fluctuation in the number of shards distributed across each storage node relative to the distribution mean. It can be calculated by summing the squares of the deviations between the number of shards on each node and the distribution mean, then averaging them, and finally taking the square root. A larger standard deviation indicates a more uneven shard distribution, and vice versa. This metric can be used to identify logical volumes that appear balanced but actually exhibit significant fluctuations in shard distribution. The calculation formula is as follows:
[0096] ;
[0097] Then, the coefficient of variation (CV) can be calculated using the standard deviation and the mean. The CV is the ratio of the standard deviation to the mean, providing a relative measure of the dispersion of the shard distribution. In some cases, the absolute standard deviation may appear large or small due to the size of the cardinality (mean). The CV eliminates the influence of the cardinality, thus allowing for a more impartial comparison of the uniformity of the shard distribution across different logical volumes. A high CV suggests greater relative volatility, indicating a more severe imbalance in the shard distribution, requiring higher priority for data rebalancing. The formula for calculating the CV is as follows:
[0098] ;
[0099] In this embodiment, logical volumes that actually require rebalancing can be quickly identified. Furthermore, by using the coefficient of variation, a relative indicator, the degree of shard unevenness can be more accurately assessed. This is especially important for volumes with a large total number of shards, where the absolute standard deviation may not be sufficient to reflect the unevenness of their distribution. Therefore, this embodiment can make more intelligent data migration decisions when dealing with complex storage environments, avoiding unnecessary shard movements, improving the efficiency of rebalancing operations, and reducing system overhead during data migration. This plays a positive role in improving the overall performance and stability of the distributed storage system.
[0100] Figure 3 This is a schematic diagram of an optional volume imbalance evaluation process according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following:
[0101] (1) Start: Initiate an imbalance assessment for a specific volume, i.e., a single logical volume.
[0102] (2) Obtain the shard distribution of the volume on all available XBSDs, that is, count the number of data shards of this volume on each valid storage node.
[0103] (3) Max-Min difference ≤ 1, that is, to determine whether the difference between the maximum number of shards (Max) and the minimum number of shards (Min) at each node of this volume is less than or equal to 1.
[0104] (4) If the difference is less than or equal to 1, the volume is considered to be locally balanced and the volume evaluation is completed directly.
[0105] (5) If the difference is greater than 1, calculate the StdDev and CV of the Shard distribution, that is, calculate the standard deviation (StdDev) and coefficient of variation (CV) of the Shard distribution of this volume.
[0106] (6) Determine whether StdDev or CV exceeds the preset threshold.
[0107] (7) If neither StdDev nor CV exceeds the preset threshold, then this Volume is considered balanced and the Volume evaluation is completed directly.
[0108] (8) If either StdDev or CV exceeds the preset threshold, this Volume is marked as unbalanced, and the migration priority score of the Volume is calculated to complete the Volume evaluation.
[0109] In this embodiment, after all logical volumes have completed the imbalance assessment, all volumes marked as "imbalanced" and their corresponding priority scores can be summarized. The imbalanced volumes can be sorted from high to low according to their priority scores, and the volume with the highest score in the sorting results can be selected as the preferred target for the migration operation.
[0110] To achieve accurate migration of unbalanced logical volumes, the data sharding balancing method based on distributed storage provided in Embodiment 1 of this application, when there are multiple unbalanced logical volumes, determines the migration score of each logical volume; identifies the logical volume with the highest migration score as the target logical volume, and selects data shards to be migrated from the target logical volume; determines the target storage center from the distributed storage system; migrates the data shards to be migrated from the source storage center to the target storage center, obtaining the migration result, wherein the source storage center is the storage center where the data shards to be migrated were stored before the migration; if the migration result indicates successful migration, updates the data distribution of the target logical volume on each storage node and the number of data shards on each storage node, and accumulates the migration count; based on the updated data distribution of the target logical volume on each storage node and the number of data shards on each storage node, re-evaluates the balance state of the distributed storage system until the distributed storage system is balanced or the migration count reaches a preset number.
[0111] In this embodiment of the invention, when multiple logical volumes are detected to be in an unbalanced state, a "migration score" can be calculated for each volume. The migration score is a comprehensive metric determined based on the characteristics of each volume (such as the total number of shards, the number of available storage nodes, the maximum and minimum differences in the current shard distribution, and the degree of deviation from the ideal average distribution), used to quantify the urgency of shard migration for each volume. By comprehensively considering the current state of each logical volume and the system environment, this score can guide the system to prioritize the volumes that most need rebalancing, improving the targeting and efficiency of the rebalancing operation.
[0112] In this embodiment of the invention, after calculating the migration scores of all unbalanced logical volumes, the logical volume indicated by the "maximum migration score" can be selected as the "target logical volume." This means prioritizing shard migration of the volume with the highest migration score to achieve the greatest balance improvement. Then, a "shard to be migrated" is selected from the target logical volumes. The current distribution status of the shard and the load of the storage nodes can be considered to ensure that the migration of the selected shard brings substantial optimization to the distribution of the target logical volume. For example, the shard of the storage node with the highest load can be selected as the shard to be migrated.
[0113] In this embodiment of the invention, the "target storage center" refers to the storage node in the distributed storage system that receives the shard to be migrated. The target storage center can be automatically filtered and determined based on factors such as the node's current load and whether it belongs to a preset list. If the target storage center is determined, a "data migration" operation will be performed to move the shard to be migrated from the source storage center to the target storage center. The source storage center is the storage node where the shard to be migrated resided before the migration.
[0114] If the "Migration Result" indicates a successful migration, the "Data Distribution" of the target logical volume on each storage node and the "Number of Data Shards" on each storage node can be updated to ensure the real-time nature and accuracy of system information, providing the latest data for subsequent balance status assessment. Furthermore, the "Migration Count" is accumulated to track the number of migration operations completed since the self-balancing process began, preventing over-migration. Based on the updated data distribution and number of shards, the balance status of the distributed storage system will be reassessed to check whether all volumes are balanced or whether the "Preset Number of Migrations" limit has been reached.
[0115] In this embodiment, by introducing a migration score mechanism and a target logical volume selection strategy, the intelligence and efficiency of shard rebalancing operations are improved. This ensures that the rebalancing decision not only considers the global imbalance but also meticulously analyzes the shard distribution characteristics within each logical volume. This allows for prioritizing volumes that have the greatest impact on the overall system balance, reducing unnecessary data movement, and maintaining good adaptability even under complex pre-defined list constraints. Thus, while ensuring uniform data distribution, system overhead is effectively reduced, and the performance and reliability of the distributed storage system are improved.
[0116] To improve the accuracy of determining the migration score of a logical volume, in the data sharding balancing method based on distributed storage provided in Embodiment 1 of this application, for each logical volume, if the total number of data shards in the logical volume is less than or equal to the number of storage nodes, the maximum storage capacity of the data shards of the logical volume stored on a single storage node is determined; based on the maximum storage capacity, the error value of the logical volume is determined; based on the error value and the total number of data shards, the migration score of the logical volume is determined; if the total number of data shards in the logical volume is greater than the number of storage nodes, the maximum and minimum storage capacity of the data shards of the logical volume stored on a single storage node are determined; based on the maximum and minimum storage capacity, the actual storage difference is determined; based on the total number of data shards and the number of nodes, the average storage capacity is determined; based on the actual storage difference, the ideal storage difference, and the average storage capacity, the migration score of the logical volume is determined, wherein the ideal storage difference is determined based on the average storage capacity.
[0117] In this embodiment of the invention, when the total number of data shards (total_shards) of a logical volume is less than or equal to the number of storage nodes (available_count), ideally each shard has a dedicated XBSD, or at most one shard of that volume on each XBSD. The number of shards of that volume on all XBSDs is either 0 or 1. If the number of shards of that volume on a certain XBSD is greater than 1, it means that shards that could have been more distributed are piled up together. Therefore, we can first determine the maximum amount of storage space on a storage node for the data shards of the logical volume (i.e., determine which node stores the most data shards of the volume and determine the number of data shards of the volume on that node), and then subtract the ideal value (i.e., 1) from the maximum storage space to obtain the error value of the volume. This error value directly measures the "redundant" pile-up and directly reflects the absolute degree of imbalance (how many shards are in the "wrong" position). For example, if there are 3 shards of that volume on an XBSD, they should be distributed, but now there are 2 redundant ones piled up. Next, the ratio between the error value and the total number of data shards is calculated to obtain the migration score of the logical volume. For example, a volume with a total of 2 shards, where both are stacked on one XBSD, is clearly more unbalanced than a volume with a total of 10 shards, where both are stacked on one XBSD.
[0118] In this embodiment of the invention, if the total number of shards in a logical volume is greater than the number of storage nodes, ideally, the shards should be distributed as evenly as possible across all available XBSDs. Ideally, the number of shards for the volume on all XBSDs should be either exactly equal or differ by at most 1. Therefore, ideal_max_min_gap (the ideal maximum-minimum difference, i.e., the ideal storage difference) is either 0 (i.e., divisible by the total number of data shards and the number of nodes) or 1 (i.e., not divisible by the total number of data shards and the number of nodes). If the actual max_min_gap (the difference between the actual maximum number of shards (i.e., the maximum storage capacity) and the minimum number of shards (i.e., the minimum storage capacity) is much greater than ideal_max_min_gap, it indicates an uneven distribution. Therefore, the maximum and minimum storage capacity of data shards of the logical volume stored on a single storage node can be determined first (i.e., determine which node stores the fewest data shards of the volume and determine the number of data shards of the volume on that node). Then, based on the difference between the maximum and minimum storage quantities, the actual storage gap (max_min_gap) is determined, and the difference between the actual storage gap (max_min_gap) and the ideal storage gap (ideal_max_min_gap) is also determined. This value represents the "gap magnitude" by which the actual distribution deviates from the ideal uniform distribution. The larger the value, the greater the gap between the most "crowded" XBSD and the most "idle" XBSD is compared to the ideal state. Next, the ratio between the total number of data shards and the number of nodes is calculated to obtain the average storage quantity. Finally, the difference between the actual storage gap and the ideal storage gap is divided by the average storage quantity to obtain the migration score of the logical volume. For example, if the gap exceeds the ideal by 2 shards, the impact is relatively small if each XBSD should support an average of 10 shards; however, if it should only support an average of 3 shards, then the gap becomes much larger. Therefore, this migration score measures the proportion of this "gap magnitude" relative to the "average load".
[0119] In this embodiment, by introducing the concepts of error values and storage differences, and a mechanism for calculating migration scores based on these values, a more accurate and efficient data rebalancing strategy is provided for distributed storage systems. This strategy not only distinguishes the actual storage needs and current distribution status of different logical volumes, but also considers the number of storage nodes and the theory of average distribution, ensuring that the rebalancing operation avoids unnecessary data movement and effectively addresses the problem of uneven data distribution.
[0120] To improve the accuracy of determining the target storage center, in the data sharding balancing method based on distributed storage provided in Embodiment 1 of this application, the following steps are taken: 1) Select a storage center from the distributed storage system where the data shards of the target logical volume are not stored as a candidate storage center; 2) Select the candidate storage center with the smallest number of data shards from all candidate storage centers as the target storage center; 3) If there are multiple candidate storage centers with the smallest number of data shards among all candidate storage centers, randomly select one of these multiple candidate storage centers as the target storage center; 4) If there is no storage center in the distributed storage system where the data shards of the target logical volume are not stored, select the storage center with the smallest number of data shards from all storage centers as the target storage center; 5) If there are multiple storage centers with the smallest number of data shards among all storage centers, randomly select one of these multiple storage centers as the target storage center.
[0121] In this embodiment of the invention, when selecting a logical volume for shard migration, a "candidate storage center" can be selected first. Here, a "candidate storage center" refers to a storage node (XBSD) that currently does not store any shards of that logical volume. This allows shards to be distributed across different nodes, avoiding excessive data concentration, thereby improving data dispersion and system redundancy, and enhancing the overall robustness and reliability of the system.
[0122] After obtaining all "candidate storage centers", the most suitable candidate storage center can be determined based on the "number of data shards". Specifically, the "candidate storage center with the smallest number of data shards" can be selected as the target storage center, that is, the node currently carrying the fewest shards. In this way, shards are migrated to the node with the lowest load, balancing the storage pressure of each node and optimizing the utilization of storage resources.
[0123] If multiple nodes in the candidate storage center have the smallest number of data shards, i.e., there are multiple "candidate storage centers with the smallest number of data shards", then a node will be randomly selected as the "target storage center".
[0124] In this embodiment of the invention, if there are no "storage centers where data shards are not stored" in the distributed storage system, meaning all nodes have already stored the shards of the target logical volume, the "storage center with the smallest number of data shards" can be selected as the target from "all storage centers". If there are multiple "storage centers with the smallest number of data shards", one of them will be randomly selected as the target storage center.
[0125] In some alternative embodiments, when the number of shards of storage nodes is the same, the node with the smallest node ID (i.e., the number pre-configured for the node) can be selected as the target storage center.
[0126] In this embodiment, by prioritizing nodes that do not store target logical volume shards and considering node load during selection, the aim is to achieve broad data distribution and load balancing among storage nodes. This avoids data redundancy, optimizes shard distribution, reduces the formation of hotspot nodes, and improves overall system performance and stability.
[0127] Figure 4 This is a schematic diagram of an optional shard migration execution iteration process according to an embodiment of the present invention, such as... Figure 4 As shown, the process includes the following:
[0128] (1) Start iteration: Try to migrate a Shard, that is, start an iterative process of trying to migrate a data shard.
[0129] (2) Determine if there are still attempts or migration slots, i.e., check if the preset total number of iterations, the total number of Shards or Volumes allowed to migrate in this round have been reached.
[0130] (3) If not, end the iteration: the limit is reached (i.e., if any limit has been reached, the current migration iteration ends); if yes, select the source XBSD with the most shards from the current highest priority volume (i.e., if the limit is not reached, select the storage node (XBSD) with the most shards of the current pending, highest priority volume as the migration source).
[0131] (4) Select a specific shard from the source XBSD to be migrated. That is, on the selected source XBSD, select a specific data shard for the target volume to prepare for migration.
[0132] (5) Determine whether a shard that can be migrated has been successfully found.
[0133] (6) If not, try the next volume or end the migration. That is, if no shard is selected (e.g., there is no shard to migrate from the source XBSD, or all have been tried), the next priority volume may be processed, or the entire migration may end if there are no other volumes.
[0134] (7) If so, a target XBSD is selected for the Shard. That is, if the source Shard is successfully selected, a suitable target XBSD is found for it. A distribution strategy will be applied during the selection (such as prioritizing XBSDs that do not have this volume and have low total load).
[0135] (8) Determine whether the Shard to be migrated has found a valid target XBSD that conforms to the strategy.
[0136] (9) If not, mark this Shard as having failed in this round of migration and re-evaluate whether there are still attempts or migration slots; if yes, perform the migration: move the Shard from the source to the target. That is, if no suitable target is found, mark this Shard migration attempt as having failed and prepare for the next iteration. If a target is found, perform the actual Shard migration operation and move it from the source XBSD to the target XBSD.
[0137] (10) Update the global Shard count and distribution map. That is, after the migration is successful, update the shard count statistics and location mapping information of all relevant Shards in the system.
[0138] (11) Record the details of this migration and increment the relevant migration counter.
[0139] (12) Determine whether the Max-Min difference is ≤1, that is, check whether the maximum and minimum difference between the total number of Shards on all XBSDs in the current cluster has reached the ideal equilibrium state (the difference is less than or equal to 1).
[0140] (13) If so, end the iteration: reach ideal equilibrium, that is, if ideal equilibrium has been reached, end the current migration iteration in advance.
[0141] (14) If not, then re-evaluate whether there are still attempts or migration slots. That is, if the ideal equilibrium is not reached, return to the beginning of the loop and continue the next iteration.
[0142] In this embodiment of the invention, imbalance diagnosis can be performed more accurately: by introducing two statistical indicators, standard deviation and coefficient of variation, to measure the shard distribution of each volume, the dispersion and imbalance of the data distribution can be reflected more comprehensively and accurately, rather than relying solely on a simple comparison of extreme values (maximum / minimum). Furthermore, a more intelligent migration decision is provided: by prioritizing imbalanced volumes, the "most imbalanced" volume can be identified, allowing the system to prioritize the volumes most in need of adjustment, thereby improving the overall efficiency and effectiveness of rebalancing. When selecting a target XBSD, nodes that do not yet host the volume are given priority, which promotes a wider distribution of data within the volume and avoids concentrating shards on a few nodes that already contain the volume. Simultaneously, unnecessary migrations are reduced: judgments based on statistical thresholds can avoid unnecessary migrations triggered by temporary, local maximum / minimum differences that do not affect the overall distribution. For example, even if a volume has one more shard than another on one XBSD, if its overall standard deviation and coefficient of variation are small, it means that the distribution is still fairly uniform. In this case, migration may not be necessary, and volumes with the maximum number of shards and the minimum number of shards on the nodes are directly regarded as balanced. This also avoids unnecessary calculations and migration attempts on volumes that are already well balanced.
[0143] Furthermore, performing independent statistical analysis on each volume allows for better handling of potentially significant differences in the total number of shards, importance, and access patterns across volumes within the system. Even with complex constraints such as pre-defined lists, effective statistical evaluation and decision-making can still be made based on the allowed range of nodes. Moreover, through more precise and less unnecessary migration, network bandwidth consumption, I / O load, and computational overhead associated with data migration can be reduced, thereby improving overall system performance and resource utilization.
[0144] In this embodiment of the invention, compared to current algorithms based on maximum-minimum difference, this embodiment can identify potential, subtle data distribution imbalances earlier in some scenarios. During rebalancing triggered by simulating XBSD node failure recovery or the addition of new nodes, this embodiment tends to prioritize statistically more discrete volumes, helping the system recover from severe imbalances more quickly. Furthermore, by adjusting the thresholds for standard deviation and coefficient of variation, the sensitivity and migration amount of the rebalancing can be effectively controlled. In some cases, this embodiment can achieve better global balancing with fewer shard migrations (e.g., smaller differences in the total number of shards across all XBSDs, or a more uniform distribution of shards on critical business volumes).
[0145] The following is a detailed description with reference to another embodiment.
[0146] Example 2
[0147] The data sharding and balancing device based on distributed storage provided in this embodiment includes multiple implementation units, each of which corresponds to a specific implementation step in Embodiment 1 above.
[0148] Figure 5 This is a schematic diagram of an optional data sharding and balancing device based on distributed storage according to an embodiment of the present invention, such as... Figure 5 As shown, the data sharding and equalization device may include: acquisition unit 50, inspection unit 51, judgment unit 52, and migration unit 53.
[0149] The acquisition unit 50 is used to acquire the data distribution of each logical volume on each storage node and the number of data shards on each storage node in the distributed storage system at the current moment. The logical volume is a logical storage unit divided in the distributed storage system. The data in the logical volume is divided into multiple data shards, and each data shard is stored on a storage node.
[0150] The inspection unit 51 is used to perform an initial balance check on the distributed storage system based on the number of data shards in each storage node and obtain the inspection results.
[0151] The judgment unit 52 is used to determine the balance status of each logical volume based on the data distribution of each logical volume on each storage node when the inspection result indicates that the distributed storage system is unbalanced.
[0152] Migration unit 53 is used to perform a migration loop operation on the logical volumes that are in an unbalanced state when there are such volumes, until the distributed storage system is balanced or the number of migrations reaches a preset number.
[0153] The aforementioned data sharding balancing device can collect the data distribution of each logical volume on each storage node in the distributed storage system and the number of data shards on each storage node. Then, it performs a quick initial balancing check. If system imbalance is found, it further evaluates the balancing status of each logical volume, identifies the logical volumes that truly need rebalancing, and performs iterative shard migration operations on them until the system is balanced or the preset migration limit is reached. This achieves the goal of accurately identifying data imbalance, thereby realizing the technical effect of optimizing dynamic data sharding balancing, avoiding unnecessary data movement, improving the overall performance and stability of the system, and thus solving the technical problem of low effectiveness in balancing distributed storage systems in related technologies.
[0154] Optionally, the checking unit includes: a first determining module, used to determine the maximum number of data shards and the minimum number of data shards based on the number of data shards on each storage node; a second determining module, used to determine that the distributed storage system is balanced when the difference between the maximum number of data shards and the minimum number of data shards is less than or equal to a preset threshold; and a third determining module, used to determine that the distributed storage system is unbalanced when the difference between the maximum number of data shards and the minimum number of data shards is greater than a preset threshold.
[0155] Optionally, the data distribution includes: the number of data shards of the logical volume distributed on each storage node, and the judgment unit includes: a fourth determining module, used to determine the maximum and minimum distribution numbers for each logical volume based on the number of data shards of the logical volume distributed on each storage node; a fifth determining module, used to determine that the logical volume is in a balanced state when the difference between the maximum and minimum distribution numbers is less than or equal to a preset distribution threshold; a sixth determining module, used to determine the standard deviation and coefficient of variation of the logical volume based on the data distribution of the logical volume on each storage node when the difference between the maximum and minimum distribution numbers is greater than a preset distribution threshold; a seventh determining module, used to determine that the logical volume is in an unbalanced state when the standard deviation of the logical volume is greater than a preset standard deviation threshold and / or the coefficient of variation is greater than a preset variation threshold; and an eighth determining module, used to determine that the logical volume is in a balanced state when the standard deviation of the logical volume is less than or equal to a preset standard deviation threshold and the coefficient of variation is less than or equal to a preset variation threshold.
[0156] Optionally, the sixth determining module includes: a first determining submodule, used to determine the distribution mean based on the number of data shards of the logical volume distributed on each storage node; a second determining submodule, used to determine the standard deviation based on the number of data shards of the logical volume distributed on each storage node and the distribution mean; and a third determining submodule, used to determine the coefficient of variation based on the standard deviation and the distribution mean.
[0157] Optionally, the migration unit includes: a ninth determining module, used to determine the migration score of each logical volume when there are multiple logical volumes in an unbalanced state; a tenth determining module, used to determine the logical volume indicated by the maximum migration score as the target logical volume and select the data shards to be migrated from the target logical volume; an eleventh determining module, used to determine the target storage center from the distributed storage system; a first migration module, used to migrate the data shards to be migrated from the source storage center to the target storage center and obtain the migration result, wherein the source storage center is the storage center where the data shards to be migrated were stored before the migration; a first updating module, used to update the data distribution of the target logical volume on each storage node and the number of data shards on each storage node when the migration result indicates successful migration, and to accumulate the migration count; and a first judging module, used to re-judge the balance state of the distributed storage system based on the updated data distribution of the target logical volume on each storage node and the number of data shards on each storage node, until the distributed storage system is balanced or the migration count reaches a preset number.
[0158] Optionally, the ninth determining module includes: a fourth determining submodule, used to determine, for each logical volume, the maximum storage capacity of a data shard on a single storage node when the total number of data shards in the logical volume is less than or equal to the number of storage nodes; a fifth determining submodule, used to determine the error value of the logical volume based on the maximum storage capacity; a sixth determining submodule, used to determine the migration score of the logical volume based on the error value and the total number of data shards; a seventh determining submodule, used to determine the maximum and minimum storage capacity of a data shard on a single storage node when the total number of data shards in the logical volume is greater than the number of storage nodes; an eighth determining submodule, used to determine the actual storage difference based on the maximum and minimum storage capacity; a ninth determining submodule, used to determine the average storage capacity based on the total number of data shards and the number of nodes; and a tenth determining submodule, used to determine the migration score of the logical volume based on the actual storage difference, the ideal storage difference, and the average storage capacity, wherein the ideal storage difference is determined based on the average storage capacity.
[0159] Optionally, the eleventh determining module includes: a first selection submodule, used to select a storage center from the distributed storage system where the data shards of the target logical volume are not stored as a candidate storage center; a second selection submodule, used to select a candidate storage center with the smallest number of data shards from all candidate storage centers as the target storage center; a first selection submodule, used to select any one of the multiple candidate storage centers with the smallest number of data shards as the target storage center when there are multiple candidate storage centers with the smallest number of data shards; a second selection submodule, used to select the storage center with the smallest number of data shards as the target storage center when there is no storage center in the distributed storage system where the data shards of the target logical volume are not stored; and a third selection submodule, used to select any one of the multiple storage centers with the smallest number of data shards as the target storage center when there are multiple storage centers with the smallest number of data shards.
[0160] The aforementioned data sharding equalization device may also include a processor and a memory. The aforementioned acquisition unit 50, inspection unit 51, judgment unit 52, migration unit 53, etc., are all stored in the memory as program units, and the processor executes the aforementioned program units stored in the memory to realize the corresponding functions.
[0161] The aforementioned processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and by adjusting kernel parameters, in the event of unbalanced logical volumes, a migration loop can be performed on the unbalanced logical volumes until the distributed storage system is balanced or the preset number of migrations is reached.
[0162] The aforementioned memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0163] This invention also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program with the following method steps: collecting the data distribution of each logical volume on each storage node and the number of data shards on each storage node in the distributed storage system at the current moment; performing an initial balance check on the distributed storage system based on the number of data shards on each storage node to obtain the check result; if the check result indicates that the distributed storage system is unbalanced, determining the balance state of each logical volume based on the data distribution of each logical volume on each storage node; and performing a migration loop operation on the unbalanced logical volumes if there are any unbalanced logical volumes, until the distributed storage system is balanced or the migration count reaches a preset number.
[0164] According to another aspect of the present invention, a computer program product is also provided, including a non-volatile computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the data sharding and balancing method based on distributed storage as described above.
[0165] According to another aspect of the present invention, an electronic device is also provided, including one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the above-described data sharding and balancing method based on distributed storage.
[0166] Figure 6 This is a hardware structure block diagram of an electronic device (or mobile device) for a data sharding and balancing method based on distributed storage according to an embodiment of the present invention. Figure 6 As shown, an electronic device may include one or more processors (e.g., Figure 6 The processors 602a, 602b, ..., 602n, etc., may include, but are not limited to, processing devices such as microprocessors (MCUs) or programmable logic devices (FPGAs), and a memory 604 for storing data. In addition, it may include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a keyboard, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 6 The structure shown is for illustrative purposes only and does not limit the structure of the electronic device described above. For example, the electronic device may also include components that are more... Figure 6 The more or fewer components shown, or having the same Figure 6 The different configurations shown.
[0167] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0168] The embodiments or examples disclosed herein are not exhaustive, but merely illustrative of some embodiments or examples, and are not intended to limit the scope of protection of this disclosure. Unless otherwise specified, each step in a particular embodiment or example can be implemented as an independent embodiment, and the steps can be arbitrarily combined. For example, a solution after removing some steps in a particular embodiment or example can also be implemented as an independent embodiment, and the order of the steps in a particular embodiment or example can be arbitrarily interchanged. Furthermore, optional methods or examples in a particular embodiment or example can be arbitrarily combined; moreover, embodiments or examples can be arbitrarily combined. For example, some or all steps of different embodiments or examples can be arbitrarily combined, and a particular embodiment or example can be arbitrarily combined with optional methods or examples of other embodiments or examples.
[0169] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0170] In the several embodiments provided by this invention, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection can be through some interfaces; the indirect coupling or communication connection of units or modules can be electrical or other forms.
[0171] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0172] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0173] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0174] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.
Claims
1. A data sharding and load balancing method based on distributed storage, characterized in that, include: The system collects the data distribution of each logical volume on each storage node and the number of data shards on each storage node in the distributed storage system at the current moment. The logical volume is a logical storage unit divided in the distributed storage system, and the data in the logical volume is divided into multiple data shards, with each data shard stored on the storage node. Based on the number of data shards in each storage node, an initial load balancing check is performed on the distributed storage system to obtain the check results; If the inspection results indicate that the distributed storage system is unbalanced, the balance status of each logical volume is determined based on the data distribution of each logical volume on each storage node. In the case of an unbalanced logical volume, a migration loop operation is performed on the unbalanced logical volume until the distributed storage system is balanced or the number of migrations reaches a preset number. The data distribution includes: the number of data shards of the logical volume distributed on each storage node; determining the balance state of each logical volume based on the data distribution of each logical volume on each storage node includes: for each logical volume, determining the maximum and minimum distribution numbers based on the number of data shards of the logical volume distributed on each storage node; determining that the logical volume is in a balanced state if the difference between the maximum and minimum distribution numbers is less than or equal to a preset distribution threshold; or, if the difference between the maximum and minimum distribution numbers is greater than the preset distribution threshold, determining the standard deviation and coefficient of variation of the logical volume based on the data distribution of the logical volume on each storage node; determining that the logical volume is in an unbalanced state if the standard deviation of the logical volume is greater than a preset standard deviation threshold and / or the coefficient of variation is greater than a preset variation threshold; and determining that the logical volume is in a balanced state if the standard deviation of the logical volume is less than or equal to the preset standard deviation threshold and the coefficient of variation is less than or equal to the preset variation threshold.
2. The data sharding and load balancing method according to claim 1, characterized in that, The steps for performing an initial load balancing check on the distributed storage system based on the number of data shards for each storage node include: Based on the number of data shards for each of the storage nodes, determine the maximum number of data shards and the minimum number of data shards; If the difference between the maximum number of data shards and the minimum number of data shards is less than or equal to a preset threshold, the distributed storage system is determined to be in equilibrium. If the difference between the maximum number of data shards and the minimum number of data shards is greater than the preset threshold, the distributed storage system is determined to be unbalanced.
3. The data sharding and load balancing method according to claim 1, characterized in that, The steps of determining the standard deviation and coefficient of variation of the logical volume based on the data distribution of the logical volume on each of the storage nodes include: The average distribution value is determined based on the number of data shards distributed across each storage node in the logical volume; The standard deviation is determined based on the number of data shards of the logical volume distributed on each storage node and the average value of the distribution; The coefficient of variation is determined based on the standard deviation and the distribution mean.
4. The data sharding and load balancing method according to claim 1, characterized in that, In the case of an unbalanced logical volume, the step of performing a migration loop operation on the unbalanced logical volume until the distributed storage system is balanced or the number of migrations reaches a preset number includes: In the case that there are multiple logical volumes in an unbalanced state, determine the migration score of each logical volume; The logical volume indicated by the maximum migration score is identified as the target logical volume, and data shards to be migrated are selected from the target logical volume; Determine the target storage center from the distributed storage system; The data shard to be migrated is migrated from the source storage center to the target storage center to obtain the migration result, wherein the source storage center is the storage center where the data shard to be migrated was stored before the migration; If the migration result indicates that the migration was successful, update the data distribution of the target logical volume on each storage node and the number of data shards on each storage node, and increment the migration count; Based on the updated data distribution of the target logical volume on each storage node and the number of data shards on each storage node, the balance state of the distributed storage system is reassessed until the distributed storage system is balanced or the number of migrations reaches the preset number.
5. The data sharding and load balancing method according to claim 4, characterized in that, The steps for determining the migration score for each of the logical volumes include: For each logical volume, if the total number of data shards in the logical volume is less than or equal to the number of storage nodes, determine the maximum storage capacity of the data shards of the logical volume stored on one storage node. The error value of the logical volume is determined based on the maximum storage capacity; Based on the error value and the total number of data shards, the migration score of the logical volume is determined; If the total number of data shards in the logical volume is greater than the number of storage nodes, determine the maximum and minimum storage size of the data shards of the logical volume stored on a single storage node. The actual storage difference is determined based on the maximum storage quantity and the minimum storage quantity; The average storage requirement is determined based on the total number of data shards and the number of nodes. The migration score of the logical volume is determined based on the actual storage difference, the ideal storage difference, and the average storage quantity, wherein the ideal storage difference is determined based on the average storage quantity.
6. The data sharding and load balancing method according to claim 4, characterized in that, The steps for determining the target storage center from the distributed storage system include: Select the storage center in the distributed storage system where the data shard of the target logical volume is not stored as a candidate storage center; Select the candidate storage center with the smallest number of data shards from all the candidate storage centers as the target storage center; If multiple candidate storage centers with the minimum number of data shards exist among all the candidate storage centers, one of these candidate storage centers with the minimum number of data shards may be selected as the target storage center; or... If there is no storage center in the distributed storage system where the data shard of the target logical volume is not stored, the storage center with the smallest number of data shards among all the storage centers shall be selected as the target storage center. If there are multiple storage centers with the minimum number of data shards among all the storage centers, one of the storage centers with the minimum number of data shards shall be selected as the target storage center.
7. A data sharding and load balancing device based on distributed storage, characterized in that, include: The acquisition unit is used to acquire the data distribution of each logical volume on each storage node and the number of data shards on each storage node in the distributed storage system at the current moment. The logical volume is a logical storage unit divided in the distributed storage system, and the data in the logical volume is divided into multiple data shards, with each data shard stored on the storage node. The inspection unit is used to perform an initial load balancing check on the distributed storage system based on the number of data shards in each of the storage nodes, and obtain the inspection result. The judgment unit is used to determine the balance status of each logical volume based on the data distribution of each logical volume on each storage node when the inspection result indicates that the distributed storage system is unbalanced; The migration unit is used to perform a migration loop operation on the logical volumes that are in an unbalanced state when there are such logical volumes, until the distributed storage system is balanced or the number of migrations reaches a preset number. Data distribution includes the number of data shards of a logical volume distributed across each storage node. The judgment unit includes: a fourth determination module, used to determine the maximum and minimum distribution numbers for each logical volume based on the number of data shards distributed across each storage node; a fifth determination module, used to determine that the logical volume is in a balanced state when the difference between the maximum and minimum distribution numbers is less than or equal to a preset distribution threshold; a sixth determination module, used to determine the standard deviation and coefficient of variation of the logical volume based on the data distribution of the logical volume across each storage node when the difference between the maximum and minimum distribution numbers is greater than a preset distribution threshold; a seventh determination module, used to determine that the logical volume is in an unbalanced state when the standard deviation of the logical volume is greater than a preset standard deviation threshold and / or the coefficient of variation is greater than a preset variation threshold; and an eighth determination module, used to determine that the logical volume is in a balanced state when the standard deviation of the logical volume is less than or equal to a preset standard deviation threshold and the coefficient of variation is less than or equal to a preset variation threshold.
8. A computer program product, characterized in that, The method includes a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the data sharding and balancing method based on distributed storage as described in any one of claims 1 to 6.
9. An electronic device, characterized in that, It includes one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors cause the one or more processors to implement the data sharding and balancing method based on distributed storage as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method of analyzing performance in a storage system
US20080216086A1
Distributed storage system and volume management method
US20230021806A1