A cloud database cluster online copy scheduling method and system

Through the load prediction method based on statistical algorithms and the master-slave role switching strategy, the problem of load imbalance in cloud database clusters is solved, efficient and low-cost load scheduling is achieved, and the quality and real-time performance of cloud database services are improved.

CN118394521BActive Publication Date: 2025-09-09HUAZHONG UNIV OF SCI & TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410612678.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-17
Publication Date
2025-09-09
Estimated Expiration
2044-05-17

AI Technical Summary

Technical Problem

Existing online scheduling methods for cloud database clusters have problems such as underestimated load, high training cost, poor model generalization, low adaptability to cloud-native multi-tenant database clusters, high scheduling cost and insufficient real-time performance, resulting in load imbalance and degraded service quality.

Method used

A load prediction method based on statistical algorithms is adopted, combined with exponential smoothing and the periodic burst characteristics of load. By calculating the 90th percentile of the load difference sequence as the margin, the master replica with high contribution is selected for master-slave role switching, and the load is dynamically adjusted.

Benefits of technology

It effectively avoids load overload, reduces scheduling costs, improves the accuracy and adaptability of load forecasting, improves scheduling efficiency, and reduces the overload recall rate and scheduling times.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118394521B_ABST
    Figure CN118394521B_ABST
Patent Text Reader

Abstract

The present invention discloses a cloud database cluster online replica scheduling method, comprising: determining whether the current time t is an hourly time; if so, obtaining multiple storage nodes with periodic burst characteristics from the cloud database cluster; for each storage node p in the cloud database cluster except for the storage node with periodic burst characteristics, n For example, calculate the storage node p n The 90th percentile of the first-order difference sequence of the load data #imgabs0# over the past 12 hours is used as the margin for subsequent predictions. For each storage node p in the cloud database cluster, its load at time t+1 is predicted based on its load data over the past 30 minutes #imgabs1#. Based on the predicted load value #imgabs2#, set O is set to the set consisting of all storage nodes whose predicted load values ​​at time t+1 are greater than the overload threshold. This invention improves the accuracy of storage node load prediction by adding a smooth and adaptive margin to the exponential smoothing method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of cloud databases, and more specifically, relates to a cloud database cluster online replica scheduling method and system. Background Art

[0002] Cloud database service providers such as Tencent, Amazon, Microsoft, Google, and Alibaba aim to maintain sustainable development while maintaining high-quality services while maintaining manageable operating costs. A key aspect of achieving this goal is a load balancing strategy based on online replica scheduling within cloud database clusters. Improper data replica distribution often leads to uneven node resource utilization within a cloud database cluster. In extreme cases, this can lead to excessive node load, impacting service quality. Therefore, a sound replica scheduling strategy is essential. Online data replica scheduling strategies for multi-tenant cloud database clusters must be effective, highly real-time, and cost-effective to be truly applicable in complex and ever-changing real-world scenarios and continuously optimize service quality.

[0003] Existing online scheduling methods for cloud database clusters are usually based on time series prediction technology to predict various types of loads in the cluster and perform pre-scheduling based on the prediction results. Time series prediction technology mainly includes two categories: prediction methods based on statistical algorithms and prediction methods based on machine learning algorithms. Among them, prediction methods based on statistical algorithms are the most widely used, such as moving average method and exponential smoothing method, which mainly use simple iterative formulas for prediction; prediction methods based on machine learning algorithms, such as random forest and ensemble learning, mainly train models based on large amounts of historical data and use the models for prediction.

[0004] However, existing cloud database cluster online scheduling methods based on the above two prediction technologies have some non-negligible defects:

[0005] First, existing cloud database cluster online scheduling methods based on statistical algorithm predictions tend to underestimate the load and thus cannot effectively avoid overload.

[0006] Second, existing cloud database cluster online scheduling methods based on machine learning algorithm predictions have high training costs and poor model generalization.

[0007] Third, the existing online scheduling methods for cloud database clusters based on statistical algorithm prediction and machine learning algorithm prediction are not highly adaptable to cloud-native multi-tenant database cluster scenarios and cannot fully utilize the periodic burst characteristics of load, resulting in insufficient prediction recall and poor scheduling effect.

[0008] Fourth, existing online scheduling methods for cloud database clusters based on statistical and machine learning algorithm predictions mainly focus on the placement or migration of database instances. The scheduling cost is high, the speed is slow, and the real-time performance is insufficient. Summary of the Invention

[0009] In response to the above defects or improvement needs of the prior art, the present invention provides a cloud database cluster online replica scheduling method, which aims to solve the technical problem that the existing cloud database cluster online scheduling method based on statistical algorithm prediction is prone to underestimate the load and thus cannot effectively avoid overload, and the technical problem that the existing cloud database cluster online scheduling method based on machine learning algorithm prediction has high training cost and poor model generalization, and the existing cloud database cluster online scheduling method based on statistical algorithm prediction and machine learning algorithm prediction is not highly adaptable to cloud native multi-tenant database cluster scenarios, and cannot fully utilize the characteristics of periodic bursts of load, resulting in insufficient prediction recall rate and poor scheduling effect, and the technical problem that the existing cloud database cluster online scheduling method based on statistical algorithm prediction and machine learning algorithm prediction mainly focuses on the placement or migration of database instances, has high scheduling cost, slow speed, and insufficient real-time performance.

[0010] To achieve the above objectives, according to one aspect of the present invention, a method for scheduling online replicas in a cloud database cluster is provided, comprising the following steps:

[0011] (1) Determine whether the current time t is an hour (e.g., 0:00 or 12:00). If so, proceed to step (2); otherwise, proceed to step (4).

[0012] (2) Obtain multiple storage nodes with periodic load burst characteristics from the cloud database cluster.

[0013] (3) For all storage nodes in the cloud database cluster except the storage node with load periodic burst characteristics obtained in step (2), each storage node p n For example, calculate the storage node p n Load data for the past 12 hours The 90th percentile of the first-order difference series is used as the margin for subsequent forecasts:

[0014] (4) For each storage node p in the cloud database cluster, the load of the storage node p at time t+1 is predicted based on its load data in the past 30 minutes.

[0015] (5) The load prediction value of each storage node p at time t+1 obtained according to step (4) Set set O to be the set of all storage nodes whose load prediction values ​​at time t+1 are greater than the overload threshold, and determine whether set O is empty. If so, the process ends, otherwise proceed to step (6);

[0016] (6) For each storage node p in the set O obtained in step (5) i ∈O, select multiple primary copies with the top R contribution in the primary copy set as storage nodes p i Candidate replica queue

[0017] (7) The load prediction value of each storage node p at time t+1 obtained according to step (4) And the set O obtained in step (5), all storage nodes in the set O are arranged in descending order according to the load prediction values ​​of all storage nodes at time t+1 obtained in step (4), so as to obtain the storage node queue P.

[0018] (8) For each storage node p in the storage node queue P obtained in step (7) m For example, the corresponding candidate replica queue The master copy in the system selects the appropriate slave copy to switch the master-slave role until p m The predicted value of the load at time t+1 Until it is lower than the overload threshold.

[0019] Preferably, step (2) is specifically as follows: first, for each storage node p in the cloud database cluster, obtain the load data of the storage node p in the past 12 hours in minute granularity from the monitoring system.

[0020] Then, load the data p Perform STL decomposition to obtain the following load data load p :

[0021] load p =S p +T p +R p

[0022] Among them S p 、T p 、R p They are the seasonal term, trend-cycle term and residual term of storage node p respectively;

[0023] Finally, the seasonal term S of the storage node p pPerform a fast Fourier transform. If the transformation result shows that the seasonal term has an obvious period and the ratio of the maximum value to the mean value of the seasonal term in each period exceeds a given threshold, it means that the storage node p is a storage node with periodic burst characteristics of load.

[0024] Preferably, step (3) is performed using the following formula:

[0025]

[0026] Where percentile(a,b) represents the b quantile of set a.

[0027] Preferably, step (4) is to calculate the load periodic burst characteristics of each storage node p obtained in step (2). y For example, predict the storage node p y Load at time t+1 For all storage nodes in the cloud database cluster, except for the storage node with load periodic burst characteristics obtained in step (2), each storage node p n For example, predict the storage node p n Load at time t+1

[0028] Preferably, step (4) includes the following sub-steps:

[0029] (4-1) Obtain the load data of each storage node p in the past 30 minutes from the monitoring system

[0030] (4-2) The load data load of each storage node p in the past 30 minutes obtained according to step (4-1) p , and use the exponential smoothing method to predict the load of the storage node p at time t+1

[0031] (4-3) The load data of each storage node p in the past 30 minutes obtained according to step (4-1) p , and use the following formula to calculate the margin scaling factor of the storage node p

[0032]

[0033] in:

[0034]

[0035]

[0036] The coefficient γ∈[0,1] is used to scale The coefficient β∈[0,1] is used to t <0, the margin scaling factor Decrease in an exponentially smooth manner.

[0037] (4-4) For each storage node p with load periodic burst characteristics obtained in step (2), y For example, the storage node p obtained in step (4-2) y Exponential smoothing forecast results at time t+1 And the storage node p obtained in step (4-3) y Margin scaling factor And calculate the storage node p according to the following formula y The predicted value of the load at time t+1

[0038]

[0039] in For storage node p y Load data in the time period [t-60, t-60+k1] The 90th percentile of the first-order difference sequence of , that is:

[0040]

[0041] Where k1 is the reference time window size for the previous load cycle during prediction, and 8≤k1≤15;

[0042] (4-5) For all storage nodes in the cloud database cluster, except for the storage node with load periodic burst characteristics obtained in step (2), each storage node p n For example, the storage node p obtained in step (4-2) n Exponential smoothing forecast results The storage node p obtained in step (4-3) n Margin scaling factor And the storage node p obtained in step (3) n Margins And calculate the storage node p according to the following formula n The predicted value of the load at time t+1

[0043]

[0044] Preferably, step (6) includes the following sub-steps:

[0045] (6-1) Set counter j = 0;

[0046] (6-2) Get the storage node p at time tj i The primary and secondary replica sets C1 with the top k2 positions in the medium load ranking are as follows; the value of k2 ranges from 5 to 20;

[0047] (6-3) For each master replica r∈C1 in the set C1 obtained in step (6-2), the contribution of the master replica r at time t is and the load of the primary replica r at time tj Add them together as the contribution of the primary replica r at time t The contribution of the primary replica r at time t is The initial value of is 0;

[0048] (6-4) Set j = j + 1 and determine whether j is less than the preset time window size W. If so, return to step (6-2); otherwise, go to step (6-5);

[0049] (6-5) Arrange the contribution of all the master copies obtained from large to small, and select the master copies with the first R positions in the arrangement result as storage nodes p i Candidate replica queue

[0050] Preferably, step (8) includes the following sub-steps:

[0051] (8-1) Set counter q = 1;

[0052] (8-2) For each storage node p in the storage node queue P obtained in step (7) m For example, get the corresponding candidate replica queue The set F of all slave replicas corresponding to the qth master replica leader;

[0053] (8-3) Set counter k=1;

[0054] (8-4) For the kth replica follower in the replica set F obtained in step (8-2), calculate its storage node p follower The ratio of the number of primary replicas to the number of all replicas is determined to determine whether the ratio is greater than a given threshold. If so, proceed to step (8-9), otherwise proceed to step (8-5);

[0055] (8-5) Obtain the load data of the qth master replica leader and its corresponding kth slave replica follower in the time period (t-30, t] from the monitoring system, calculate the load data difference between the two at each moment in the time period, and compare these load data differences with the storage node p where the kth slave replica follower is located. follower The load data at the corresponding moments in this time period are added together, and the multiple results obtained constitute the load sequence of the kth replica follower in the time period (t-30, t]

[0056] (8-6) The load sequence of the kth slave follower obtained in step (8-5) during the time period (t-30, t] And use the same process as step (4) to predict the kth slave replica follower at time t+1 when the master replica leader and the slave replica follower switch the master-slave role follower Load

[0057] (8-7) Determine the kth replica follower obtained in step (8-6) at time t+1 p follower Load Is it less than a given threshold? If so, go to step (8-8), otherwise go to step (8-9);

[0058] (8-8) Set the score of the kth slave replica follower to the load obtained in step (8-7) Then go to steps (8-10);

[0059] (8-9) Set the score of the kth replica follower to positive infinity, and then go to step (8-10);

[0060] (8-10) Set k = k + 1 and determine whether k is greater than the candidate copy queue The total number of slave replicas corresponding to the leader of the qth master replica. If yes, go to step (8-11), otherwise return to step (8-4);

[0061] (8-11) Obtain the bestFollower slave replica with the lowest score from the scores of all slave replicas in the obtained replica set F;

[0062] (8-12) According to the bestFollower slave obtained in step (8-11), obtain the load data of the qth master replica leader and the bestFollower slave in the time period (t-30, t] from the monitoring system, calculate the load data difference between the leader and the bestFollower at each moment in the time period (t-30, t], and use p bestFollower The load data at each moment in the time period is added to the load data difference at the corresponding moment, and the multiple results obtained constitute the load data from the replica p bestFollower Load sequence in the time period (t-30, t] And store node p m The load data at each moment in the time period is subtracted from the load data difference at the corresponding moment, and the multiple results obtained constitute the storage node p m Load sequence in the time period (t-30, t] And send the master-slave role switch instruction to the cloud database for the master replica leader and the slave replica bestFollower;

[0063] (8-13) Storage node p obtained according to step (8-12) m In the time period (t-30, t] p m Load And use the same method as step (4) to predict the time p at time t+1 after the master-slave role switch between the primary replica leader and the slave replica bestFollower m Load

[0064] (8-14) Determine the time p at time t+1 after the master-slave role switch between the master replica leader and the slave replica bestFollower predicted in step (8-13) m Load Is it less than the overload threshold? If so, the process ends; otherwise, go to step (8-15);

[0065] (8-15) Set q = q + 1 and determine whether q is greater than the storage node p m Candidate replica queue If yes, the process ends, otherwise returns to step (8-2).

[0066] According to another aspect of the present invention, a method for scheduling online replicas of a cloud database cluster is provided, comprising:

[0067] The first module is used to determine whether the current time t is an hour, if so, it goes to the second module, otherwise it goes to the fourth module.

[0068] The second module is used to obtain multiple storage nodes with periodic load burst characteristics from the cloud database cluster.

[0069] The third module is used to calculate the load periodic burst characteristics of each storage node p in all storage nodes of the cloud database cluster except the storage node with the load periodic burst characteristics obtained by the second module. n For example, calculate the storage node p n Load data for the past 12 hours The 90th percentile of the first-order difference series is used as the margin for subsequent forecasts:

[0070] The fourth module is used to predict the load of each storage node p in the cloud database cluster at time t+1 based on its load data in the past 30 minutes.

[0071] The fifth module is used to calculate the load prediction value of each storage node p at time t+1 obtained by the fourth module. Set set O to be the set consisting of all storage nodes whose load prediction values ​​at time t+1 are greater than the overload threshold, and determine whether set O is empty. If so, the process ends, otherwise it goes to the sixth module;

[0072] The sixth module is used for each storage node p in the set O obtained by the fifth module. i ∈O, select multiple primary copies with the top R contribution in the primary copy set as storage nodes p i Candidate replica queue

[0073] The seventh module is used to calculate the load prediction value of each storage node p at time t+1 obtained by the fourth module. And the set O obtained by the fifth module, all storage nodes in the set O are arranged in descending order according to the load prediction values ​​of all storage nodes at time t+1 obtained by the fourth module, so as to obtain the storage node queue P.

[0074] The eighth module is used for each storage node p in the storage node queue P obtained by the seventh module m For example, the corresponding candidate replica queue The master copy in the system selects the appropriate slave copy to switch the master-slave role until p m The predicted value of the load at time t+1 Until it is lower than the overload threshold.

[0075] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects compared with the prior art:

[0076] (1) The present invention adds a margin to the prediction result of the exponential smoothing method when predicting the cloud database cluster storage node load in step (4), making a conservative prediction, thereby greatly reducing the underestimation of the load. Therefore, overload can be effectively avoided through scheduling;

[0077] (2) Since the present invention adopts a prediction method based on statistical algorithms when predicting the cloud database cluster storage node load in step (4), there is no need to train a machine learning model, so the cost is low and the adaptability to the load is strong;

[0078] (3) The present invention considers the periodic burst characteristics of the node load when predicting the cloud database cluster storage node load in step (4), and dynamically sets the margin by referring to the load changes in the corresponding time period of the previous cycle. Therefore, when the load bursts periodically, the addition of the margin ensures that the prediction result can "keep up" with the burst, and timely predicts the overload in the early stage of the burst, solving the problem of the existing method having a low recall rate. At the end of the burst, compared with the existing method, the prediction value can be appropriately reduced faster, avoiding some overestimation of the load, thereby reducing the cost of scheduling.

[0079] (4) The present invention adopts step (6) to select the primary replica that has the highest contribution to the overload of the storage node predicted to be overloaded. This is based on the characteristics of the load composition of the storage nodes in the cloud database cluster, that is, the sum of the loads of a small number of replicas accounts for the majority of the load of the storage node. Therefore, in theory, switching the master and slave roles of these primary replicas with appropriate slave replicas can effectively avoid storage node overload, help improve the efficiency of online scheduling, and reduce scheduling costs;

[0080] (5) The present invention adopts step (8) and, based on step (6), designs an algorithm for selecting a suitable slave copy for master-slave role switching for the candidate master copy of the storage node that is predicted to be overloaded. The algorithm can avoid all overloads under perfect prediction conditions and can avoid more than 90% of overloads when combined with the load prediction algorithm designed in step (4) to evaluate the benefits of master-slave role switching. BRIEF DESCRIPTION OF THE DRAWINGS

[0081] Figure 1 It is a flow chart of the online replica scheduling method of the cloud database cluster of the present invention;

[0082] Figure 2 This is the comparison result of the scheduling effect of the present invention and the existing method on the actual cloud database historical load data set. DETAILED DESCRIPTION

[0083] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely for the purpose of explaining the present invention and are not intended to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.

[0084] From top to bottom, user resources in a cloud database generally include accounts, databases, tables, data shards, and data replicas. Generally speaking, an account holds several databases and tables. Tables often have large amounts of data and are typically divided into several data shards based on a specific mapping method. Each data shard consists of several replicas with identical data, including a master replica and several slave replicas. Under different read-write strategies, the load on the master and slave replicas varies considerably. Master and slave replicas can switch roles to adjust the load on storage nodes. The storage layer of a cloud database cluster consists of multiple storage nodes, each of which stores multiple copies of data from different users. The cloud database monitoring system stores the load of the storage nodes and data replicas in the cluster over time. The load on a storage node is equal to the sum of the loads of all the data replicas it stores.

[0085] The present invention is based on the exponential smoothing method and the changing characteristics and composition characteristics of the cloud database cluster storage node load. It improves the accuracy of storage node load prediction by adding a smooth and adaptive margin to the exponential smoothing method. By selecting the master replica with the largest load contribution to perform master-slave role switching, it effectively transfers the load of overloaded storage nodes while reducing the scheduling cost.

[0086] like Figure 1 As shown, the present invention provides a cloud database cluster online replica scheduling method, comprising the following steps:

[0087] (1) Determine whether the current time t is an hour (e.g., 0:00 or 12:00). If so, proceed to step (2); otherwise, proceed to step (4).

[0088] (2) Obtain multiple storage nodes with periodic load burst characteristics from the cloud database cluster.

[0089] Specifically, for each storage node p in the cloud database cluster, obtain the load data of the storage node p in the past 12 hours in minute granularity from the monitoring system.

[0090] Then, load the data pPerform STL decomposition (Seasonal and Trend decomposition using Loess) to obtain the following load data load p (The STL decomposition is implemented using the statsmodels library in Python, and the seasonal period parameter period is set to 60):

[0091] load p =S p +T p +R p

[0092] Among them S p 、T p 、R p They are the seasonal term, trend-cycle term and residual term of storage node p respectively;

[0093] Finally, the seasonal term S of the storage node p p Perform a fast Fourier transform. If the transformation result shows that the seasonal term has a clear period (for example, 60 minutes) and the ratio of the maximum value to the mean value of the seasonal term in each period exceeds a given threshold (the given threshold ranges from 1.2 to positive infinity, preferably 1.3), then it indicates that the storage node p is a storage node with periodic burst load characteristics.

[0094] (3) For all storage nodes in the cloud database cluster except the storage node with load periodic burst characteristics obtained in step (2), each storage node p n For example, calculate the storage node p n Load data for the past 12 hours The 90th percentile of the first-order difference series is used as the margin for subsequent forecasts:

[0095]

[0096] Where percentile(a,b) represents the b quantile of set a;

[0097] (4) For each storage node p in the cloud database cluster, the load of the storage node p at time t+1 is predicted based on its load data in the past 30 minutes.

[0098] Specifically, this step is to calculate the load periodic burst characteristics of each storage node p obtained in step (2). y For example, predict the storage node p y Load at time t+1 For all storage nodes in the cloud database cluster, except for the storage node with load periodic burst characteristics obtained in step (2), each storage node p n For example, predict the storage node p n Load at time t+1

[0099] Specifically, this step includes the following sub-steps:

[0100] (4-1) Obtain the load data of each storage node p in the past 30 minutes from the monitoring system

[0101] (4-2) The load data load of each storage node p in the past 30 minutes obtained according to step (4-1) p , and use the exponential smoothing method to predict the load of the storage node p at time t+1

[0102] (4-3) The load data of each storage node p in the past 30 minutes obtained according to step (4-1) p , and use the following formula to calculate the margin scaling factor of the storage node p

[0103]

[0104] in:

[0105]

[0106]

[0107] The coefficient γ∈[0,1] is used to scale The coefficient β∈[0,1] is used to t '<0, the margin scaling factor Decrease in an exponentially smooth manner.

[0108] (4-4) For each storage node p with load periodic burst characteristics obtained in step (2), y For example, the storage node p obtained in step (4-2) y Exponential smoothing forecast results at time t+1 And the storage node p obtained in step (4-3) y Margin scaling factor And calculate the storage node p according to the following formula y The predicted value of the load at time t+1

[0109]

[0110] in For storage node p y Load data in the time period [t-60, t-60+k1] The 90th percentile of the first-order difference sequence of , that is:

[0111]

[0112] Where k1 is the reference time window size for the previous load cycle during prediction, and 8≤k1≤15, preferably 10;

[0113] The advantage of this step is that it takes into account the periodic burst characteristics of the load of the cloud database storage node and dynamically sets the margin based on the changes in the load in the corresponding time period of the previous cycle, thereby ensuring that the prediction results can "keep up" with the burst, predict overload in a timely manner, and avoid overestimation of the load at the end of the burst, thereby reducing the scheduling cost.

[0114] (4-5) For all storage nodes in the cloud database cluster, except for the storage node with load periodic burst characteristics obtained in step (2), each storage node p n For example, the storage node p obtained in step (4-2) n Exponential smoothing forecast results The storage node p obtained in step (4-3) n Margin scaling factor And the storage node p obtained in step (3) n Margins And calculate the storage node p according to the following formula n The predicted value of the load at time t+1

[0115]

[0116] The advantage of the above steps (4-4) to (4-5) is that the underestimation of the load is greatly reduced through conservative prediction, so overload can be effectively avoided through scheduling.

[0117] The advantage of this step (4) is that it uses a prediction method based on statistical algorithms to predict the load of the cloud database cluster storage nodes. This method is low-cost and highly adaptable to the load.

[0118] (5) The load prediction value of each storage node p at time t+1 obtained according to step (4) Set O to be the set of all storage nodes whose load prediction values ​​at time t+1 are greater than the overload threshold (the overload threshold ranges from 60% to 100% of the upper limit of the storage node load, preferably 70% of the upper limit of the storage node load), and determine whether the set O is empty. If so, the process ends, otherwise proceed to step (6);

[0119] (6) For each storage node p in the set O obtained in step (5) i ∈O, select multiple primary replicas with the top R (R range is 10 to 30, preferably 20) contribution rankings in the primary replica set stored as storage nodes p i Candidate replica queue (It is used for master-slave role switching).

[0120] Specifically, this step includes the following sub-steps:

[0121] (6-1) Set counter j = 0;

[0122] (6-2) Get the storage node p at time tj i The primary and secondary replica sets C1 with the top k2 positions in the medium load ranking are as follows; the value of k2 ranges from 5 to 20, preferably 10;

[0123] (6-3) For each master replica r∈C1 in the set C1 obtained in step (6-2), the contribution of the master replica r at time t is (which is initially 0) and the load of the primary replica r at time tj Add them together as the contribution of the primary replica r at time t

[0124] (6-4) Set j = j + 1 and determine whether j is less than the preset time window size W (the value range of W is 3 to 8, preferably 5). If so, return to step (6-2); otherwise, go to step (6-5);

[0125] (6-5) Arrange the contribution of all the master copies obtained from large to small, and select the master copies with the first R positions in the arrangement result as storage nodes p i Candidate replica queue

[0126] The advantage of this step is that, based on the characteristics of the load composition of the cloud database cluster storage nodes (that is, the sum of the loads of a small number of replicas accounts for the majority of the load of the storage node), the master replicas that have a high load contribution to the overloaded storage node are selected as candidate replicas. In theory, switching the master-slave roles of these master replicas with appropriate slave replicas can effectively avoid storage node overload, improve the efficiency of online scheduling, and reduce the cost of scheduling.

[0127] (7) The load prediction value of each storage node p at time t+1 obtained according to step (4) and the set O obtained in step (5), arranging all storage nodes in the set O in descending order according to the load prediction values ​​of all storage nodes at time t+1 obtained in step (4), thereby obtaining a storage node queue P;

[0128] (8) For each storage node p in the storage node queue P obtained in step (7) m For example, the corresponding candidate replica queue The master copy in the system selects the appropriate slave copy to switch the master-slave role until p m The predicted value of the load at time t+1 until it is less than an overload threshold (the overload threshold ranges from 60% to 100% of the upper limit of the storage node load, preferably 70% of the upper limit of the storage node load);

[0129] Specifically, this step includes the following sub-steps:

[0130] (8-1) Set counter q = 1;

[0131] (8-2) For each storage node p in the storage node queue P obtained in step (7) m For example, get the corresponding candidate replica queue The set F of all slave replicas corresponding to the qth master replica leader;

[0132] (8-3) Set counter k=1;

[0133] (8-4) For the kth replica follower in the replica set F obtained in step (8-2), calculate its storage node p follower The ratio of the number of primary replicas to the number of all replicas is determined to determine whether the ratio is greater than a given threshold (the range of the given threshold is 0.4 to 0.5, preferably 0.45). If so, proceed to step (8-9); otherwise, proceed to step (8-5);

[0134] (8-5) Obtain the load data of the qth master replica leader and its corresponding kth slave replica follower in the time period (t-30, t] from the monitoring system, calculate the load data difference between the two at each moment in the time period, and compare these load data differences with the storage node p where the kth slave replica follower is located. follower The load data at the corresponding moments in this time period are added together, and the multiple results obtained constitute the load sequence of the kth replica follower in the time period (t-30, t]

[0135] (8-6) The load sequence of the kth slave follower obtained in step (8-5) during the time period (t-30, t] And use the same process as step (4) to predict the kth slave replica follower at time t+1 when the master replica leader and the slave replica follower switch the master-slave role follower Load

[0136] (8-7) Determine the kth replica follower obtained in step (8-6) at time t+1 p follower Load Is it less than a given threshold (in this embodiment, the threshold is 60% of the upper limit of the storage node load), if so, proceed to step (8-8), otherwise proceed to step (8-9);

[0137] (8-8) Set the score of the kth slave replica follower to the load obtained in step (8-7) Then go to steps (8-10);

[0138] (8-9) Set the score of the kth replica follower to positive infinity, and then go to step (8-10);

[0139] (8-10) Set k = k + 1 and determine whether k is greater than the candidate copy queue The total number of slave replicas corresponding to the leader of the qth master replica. If yes, go to step (8-11), otherwise return to step (8-4);

[0140] (8-11) Get the slave replica bestFollower with the lowest score from the scores of all slave replicas in the obtained replica set F (which represents the master-slave role switch between the master replica leader and the slave replica bestFollower, triggering the storage node p where the slave replica bestFollower is located). bestFollower The probability of overload is minimized);

[0141] (8-12) According to the bestFollower slave obtained in step (8-11), obtain the load data of the qth master replica leader and the bestFollower slave in the time period (t-30, t] from the monitoring system, calculate the load data difference between the leader and the bestFollower at each moment in the time period (t-30, t], and use p bestFollower The load data at each moment in the time period is added to the load data difference at the corresponding moment, and the multiple results obtained constitute the load data from the replica p bestFollower Load sequence in the time period (t-30, t] And store node p m The load data at each moment in the time period is subtracted from the load data difference at the corresponding moment, and the multiple results obtained constitute the storage node p m Load sequence in the time period (t-30, t] And send the master-slave role switch instruction to the cloud database for the master replica leader and the slave replica bestFollower;

[0142] (8-13) Storage node p obtained according to step (8-12) m In the time period (t-30, t] p m Load And use the same method as step (4) to predict the time p at time t+1 after the master-slave role switch between the primary replica leader and the slave replica bestFollower m Load

[0143] (8-14) Determine the time p at time t+1 after the master-slave role switch between the master replica leader and the slave replica bestFollower predicted in step (8-13) m Load Is it less than the overload threshold? If so, the process ends; otherwise, go to step (8-15);

[0144] (8-15) Set q = q + 1 and determine whether q is greater than the storage node p m Candidate replica queue If yes, the process ends, otherwise returns to step (8-2);

[0145] The advantage of this step (8) is that an algorithm is designed to select a slave copy from the candidate copy queue of the overloaded node to switch the master-slave role. This algorithm can avoid all overloads under perfect prediction conditions, and combined with the prediction algorithm of step (4), it can avoid more than 90% of overloads.

[0146] Experimental results

[0147] The experimental environment of the present invention is as follows: the CPU is Intel(R) Core(TM) i7-8700 CPU@3.20GHz 3.19GHz, the memory is 16GB DDR4, the hard disk capacity is 1TB, the operating system is Windows 11 Professional Edition 21H2, and Python 3.8 and Golang 1.16 are used to implement the system of the present invention, wherein Python 3.8 is used to implement burst cycle detection of storage node load, and Golang 1.16 is used to implement other functions. These two parts communicate through Google Remote Procedure Call (gRPC).

[0148] The data set used in the experiment of this invention is the historical load of the real production environment of a cluster of Tencent's self-developed cloud database X-Stor, involving 27 storage nodes, 99,237 data copies, and each storage node is mounted with a 4TB NVMe SSD hard drive. X-Stor has a model for measuring the resource consumption of requests, called request units, which includes four resource dimensions: CPU, memory, network bandwidth, and disk I / O. This data set contains the load data of these storage nodes and data copies in a minute granularity within 24 hours. The load here refers to the CPU dimension in the request unit, which can reflect the actual CPU consumption. The upper limit of the load of the storage node in this data set is 1,200,000.

[0149] This experiment will compare several common statistical forecasting methods, including Moving Average (MA), Exponential Smoothing (ES), Autoregressive (AR) model, Autoregressive Integrated Moving Average (ARIMA) model, and the load forecasting method in the paper "Eigen: End-to-end Resource Optimization for Large-Scale Databases on the Cloud (VLDB2023)" (hereinafter referred to as Eigen). The relevant parameters are shown in Table 1.

[0150] Table 1 Comparison of prediction algorithm parameters

[0151]

[0152] The relevant parameters in the method of the present invention are shown in Table 2

[0153] Table 2 Prediction algorithm parameters of the present invention

[0154]

[0155]

[0156] In order to illustrate the advantages of the present invention over existing methods, the present invention tested the recall and precision of the load prediction method of the present invention and other methods in predicting overload on the X-Stor dataset, as well as the avoidance of overload of storage nodes and the number of master-slave switches after master-slave switching under these prediction methods. Table 3 shows the comparison of the recall and precision of load prediction. As can be seen from Table 3, the solution of the present invention can more accurately predict overload in advance, with the recall rate reaching the highest 97.55%, and the precision rate as high as 99.6%, and it rarely predicts normal load as overload. The precision of the algorithm of the present invention is only 0.35% lower than the best case, which is negligible.

[0157] Table 3-4 Prediction algorithm performance

[0158]

[0159] Figure 2 The figure shows the ratio of overloads avoided by online scheduling under different load prediction methods to the total number of overloads, as well as the number of master-slave switches for each method. As can be seen from the figure, the avoidance ratio under the algorithm of the present invention is 3.9% higher than that of the best Eigen, and the number of master-slave switches is 21% less, which optimizes the scheduling effect while also reducing costs. This proves that the margin used in the present invention, which combines the periodic burst characteristics of the load, can not only more accurately predict overloads in advance, but also reduce the predicted value more promptly after the burst ends, avoiding unnecessary master-slave switches caused by overestimation of the load.

[0160] It will be easily understood by those skilled in the art that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A cloud database cluster online replica scheduling method, characterized in that: The following steps are involved: (1) Determine whether the current time t is the hour, if so, proceed to step (2), otherwise proceed to step (4); (2) Obtain multiple storage nodes with periodic burst load characteristics from the cloud database cluster; (3) For all storage nodes in the cloud database cluster except the storage node with load periodic burst characteristics obtained in step (2), each storage node p n For example, calculate the storage node p n Load data for the past 12 hours The 90th percentile of the first-order difference series is used as the margin for subsequent forecasts (4) For each storage node p in the cloud database cluster, the load of the storage node p at time t+1 is predicted based on its load data in the past 30 minutes. (5) The load prediction value of each storage node p at time t+1 obtained according to step (4) Set set O to be the set of all storage nodes whose load prediction values ​​at time t+1 are greater than the overload threshold, and determine whether set O is empty. If so, the process ends, otherwise proceed to step (6); (6) For each storage node p in the set O obtained in step (5) i ∈O, select multiple primary copies with the top R contribution in the primary copy set as storage nodes p i Candidate replica queue (7) The load prediction value of each storage node p at time t+1 obtained according to step (4) and the set O obtained in step (5), arranging all storage nodes in the set O in descending order according to the load prediction values ​​of all storage nodes at time t+1 obtained in step (4), thereby obtaining a storage node queue P; (8) For each storage node p in the storage node queue P obtained in step (7) m For example, the corresponding candidate replica queue The master copy in the system selects the appropriate slave copy to switch the master-slave role until p m The predicted value of the load at time t+1 Until it is lower than the overload threshold.

2. The cloud database cluster online replica scheduling method according to claim 1, characterized in that: Step (2) is as follows: first, for each storage node p in the cloud database cluster, obtain the load data of the storage node p in the past 12 hours in minute granularity from the monitoring system. Then, load the data p Perform STL decomposition to obtain the following load data load p : load p =S p +T p +R p Among them S p 、T p 、R p They are the seasonal term, trend-cycle term and residual term of storage node p respectively; Finally, the seasonal term S of the storage node p p Perform a fast Fourier transform. If the transformation result shows that the seasonal term has an obvious period and the ratio of the maximum value to the mean value of the seasonal term in each period exceeds a given threshold, it means that the storage node p is a storage node with periodic burst characteristics of load.

3. The cloud database cluster online replica scheduling method according to claim 1 or 2, characterized in that: Step (3) uses the following formula: Where percentile(a,b) represents the b quantile of set a.

4. The cloud database cluster online replica scheduling method according to claim 3, characterized in that: Step (4) is to calculate the load periodic burst characteristics of each storage node p obtained in step (2). y For example, predict the storage node p y Load at time t+1 For all storage nodes in the cloud database cluster, except for the storage node with load periodic burst characteristics obtained in step (2), each storage node p n For example, predict the storage node p n Load at time t+1 5. The cloud database cluster online replica scheduling method according to claim 4, characterized in that: Step (4) includes the following sub-steps: (4-1) Obtain the load data of each storage node p in the past 30 minutes from the monitoring system (4-2) The load data load of each storage node p in the past 30 minutes obtained according to step (4-1) p , and use the exponential smoothing method to predict the load of the storage node p at time t+1 (4-3) The load data of each storage node p in the past 30 minutes obtained according to step (4-1) p , and use the following formula to calculate the margin scaling factor of the storage node p in: The coefficient γ∈[0,1] is used to scale The coefficient β∈[0,1] is used to t <0, the margin scaling factor Decrease in an exponentially smooth manner; (4-4) For each storage node p with load periodic burst characteristics obtained in step (2), y For example, the storage node p obtained in step (4-2) y Exponential smoothing forecast results at time t+1 And the storage node p obtained in step (4-3) y Margin scaling factor And calculate the storage node p according to the following formula y The predicted value of the load at time t+1 in For storage node p y Load data in the time period [t-60, t-60+k1] The 90th percentile of the first-order difference sequence of , that is: Where k1 is the reference time window size for the previous load cycle during prediction, and 8≤k1≤15; (4-5) For all storage nodes in the cloud database cluster, except for the storage node with load periodic burst characteristics obtained in step (2), each storage node p n For example, the storage node p obtained in step (4-2) n Exponential smoothing forecast results The storage node p obtained in step (4-3) n Margin scaling factor And the storage node p obtained in step (3) n Margins And calculate the storage node p according to the following formula n The predicted value of the load at time t+1 6. The cloud database cluster online replica scheduling method according to claim 5, characterized in that: Step (6) includes the following sub-steps: (6-1) Set counter j = 0; (6-2) Get the storage node p at time tj i The primary and secondary replica sets C1 with the top k2 positions in the medium load ranking are as follows; the value of k2 ranges from 5 to 20; (6-3) For each master replica r∈C1 in the set C1 obtained in step (6-2), the contribution of the master replica r at time t is and the load of the primary replica r at time tj Add them together as the contribution of the primary replica r at time t The contribution of the primary replica r at time t is The initial value of is 0; (6-4) Set j = j + 1 and determine whether j is less than the preset time window size W. If so, return to step (6-2); otherwise, go to step (6-5); (6-5) Arrange the contribution of all the master copies obtained from large to small, and select the master copies with the first R positions in the arrangement result as storage nodes p i Candidate replica queue 7. The cloud database cluster online replica scheduling method according to claim 6, characterized in that: Step (8) includes the following sub-steps: (8-1) Set counter q = 1; (8-2) For each storage node p in the storage node queue P obtained in step (7) m For example, get the corresponding candidate replica queue The set F of all slave replicas corresponding to the qth master replica leader; (8-3) Set counter k=1; (8-4) For the kth replica follower in the replica set F obtained in step (8-2), calculate its storage node p follower The ratio of the number of primary replicas to the number of all replicas is determined to determine whether the ratio is greater than a given threshold. If so, proceed to step (8-9), otherwise proceed to step (8-5); (8-5) Obtain the load data of the qth master replica leader and its corresponding kth slave replica follower in the time period (t-30, t] from the monitoring system, calculate the load data difference between the two at each moment in the time period, and compare these load data differences with the storage node p where the kth slave replica follower is located. follower The load data at the corresponding moments in this time period are added together, and the multiple results obtained constitute the load sequence of the kth replica follower in the time period (t-30, t] (8-6) The load sequence of the kth slave follower obtained in step (8-5) during the time period (t-30, t] And use the same process as step (4) to predict the kth slave replica follower at time t+1 when the master replica leader and the slave replica follower switch the master-slave role follower Load (8-7) Determine the kth replica follower obtained in step (8-6) at time t+1 p follower Load Is it less than a given threshold? If so, go to step (8-8), otherwise go to step (8-9); (8-8) Set the score of the kth slave replica follower to the load obtained in step (8-7) Then go to steps (8-10); (8-9) Set the score of the kth replica follower to positive infinity, and then go to step (8-10); (8-10) Set k = k + 1 and determine whether k is greater than the candidate copy queue The total number of slave replicas corresponding to the leader of the qth master replica. If yes, go to step (8-11), otherwise return to step (8-4); (8-11) Obtain the bestFollower slave replica with the lowest score from the scores of all slave replicas in the obtained replica set F; (8-12) According to the bestFollower slave obtained in step (8-11), obtain the load data of the qth master replica leader and the bestFollower slave in the time period (t-30, t] from the monitoring system, calculate the load data difference between the leader and the bestFollower at each moment in the time period (t-30, t], and use p bestFollower The load data at each moment in the time period is added to the load data difference at the corresponding moment, and the multiple results obtained constitute the load data from the replica p bestFollower Load sequence in the time period (t-30, t] And store node p m The load data at each moment in the time period is subtracted from the load data difference at the corresponding moment, and the multiple results obtained constitute the storage node p m Load sequence in the time period (t-30, t] And send the master-slave role switch instruction to the cloud database for the master replica leader and the slave replica bestFollower; (8-13) Storage node p obtained according to step (8-12) m In the time period (t-30, t] p m Load And use the same method as step (4) to predict the time p at time t+1 after the master-slave role switch between the primary replica leader and the slave replica bestFollower m Load (8-14) Determine the time p at time t+1 after the master-slave role switch between the master replica leader and the slave replica bestFollower predicted in step (8-13) m Load Is it less than the overload threshold? If so, the process ends; otherwise, go to step (8-15); (8-15) Set q = q + 1 and determine whether q is greater than the storage node p m Candidate replica queue If yes, the process ends, otherwise returns to step (8-2).

8. A cloud database cluster online copy scheduling method, characterized in that: include: The first module is used to determine whether the current time t is an hour, if so, it will go to the second module, otherwise it will go to the fourth module; The second module is used to obtain multiple storage nodes with periodic burst load characteristics from the cloud database cluster; The third module is used to calculate the load periodic burst characteristics of each storage node p in all storage nodes of the cloud database cluster except the storage node with the load periodic burst characteristics obtained by the second module. n For example, calculate the storage node p n Load data for the past 12 hours The 90th percentile of the first-order difference series is used as the margin for subsequent forecasts The fourth module is used to predict the load of each storage node p in the cloud database cluster at time t+1 based on its load data in the past 30 minutes. The fifth module is used to calculate the load prediction value of each storage node p at time t+1 obtained by the fourth module. Set set O to be the set consisting of all storage nodes whose load prediction values ​​at time t+1 are greater than the overload threshold, and determine whether set O is empty. If so, the process ends, otherwise it goes to the sixth module; The sixth module is used for each storage node p in the set O obtained by the fifth module. i ∈O, select multiple primary copies with the top R contribution in the primary copy set as storage nodes p i Candidate replica queue The seventh module is used to calculate the load prediction value of each storage node p at time t+1 obtained by the fourth module. and the set O obtained by the fifth module, arranging all storage nodes in the set O in descending order according to the load prediction values ​​of all storage nodes at time t+1 obtained by the fourth module, thereby obtaining a storage node queue P; The eighth module is used for each storage node p in the storage node queue P obtained by the seventh module m For example, the corresponding candidate replica queue The master copy in the system selects the appropriate slave copy to switch the master-slave role until p m The predicted value of the load at time t+1 Until it is lower than the overload threshold.

Citation Information

Patent Citations

  • Load balancing method and system for distributed database system

    CN117215767A

  • Resource load balancing control method and cluster scheduler

    US20190253490A1