Balancing database workloads through migration
View Patent ↗A method for balancing database workloads among a plurality of database servers includes when a new server is available, selecting a set of master and slave databases to be migrated to the new server; and migrating the selected databases to result in a balanced new workload among all servers while minimizing migration cost; and during operation, if workload unbalance is detected in real time from a workload change in a certain database, iteratively selecting one database at a time to migrate to a different server to balance the workload.
1. A method for balancing database workloads among a plurality of database servers, the method comprising:
when a new server is available, selecting a set of master and slave databases to be migrated to the new server and migrating the selected databases to result in a balanced new workload among all servers while minimizing migration cost;
during operation, if a workload unbalance is detected in real-time from a workload change, iteratively selecting one database at a time to migrate to a different server to balance the workload; and
determining a metric for a given database configuration including a mean and a variance, wherein the variance is determined as:
σ 2 =c mem ·σ memCap 2 +c cpu σ cpuCap ,
where c mem and c cpu are parameters for calibrating different units between memory and a CPU.
2. The method of claim 1 , comprising applying a metric to measure a goodness of a given database configuration.
3. The method of claim 2 , wherein the metric comprises system resources including processor (CPU) usage and memory usage.
4. The method of claim 2 , wherein the metric comprises different factors in a unified way through a weighting strategy and a vector norm.
5. The method of claim 1 , wherein the selecting a set of master databases and slave databases for migration further comprises considering one or more factors including (a) the expect cost reduction after the migration, (b) the master-to-slave ratio at each of the server after migration, and (c) the migration cost that is related to the size of each database.
6. The method of claim 1 , comprising choosing an optimal order of migration to minimize impact on the system during migration.
7. The method of claim 1 , comprising iteratively selecting a next database to migrate and a corresponding target database server to eliminate a hot spot.
8. The method of claim 1 , comprising iteratively migrating one database at a time until all hot spots are eliminated.
9. The method of claim 1 , comprising setting
c
mem
=
1
μ
memCap
2
and
c
cpu
=
1
μ
cpuCap
2
.
10. A system for balancing database workloads among a plurality of database servers, the system comprising:
a processor;
code executable by the processor when a new server is available, including instructions for selecting a set of master and slave databases to be migrated to the new server; and migrating the selected databases to result in a balanced new workload among all servers while minimizing migration cost; and
code executable by the processor during operation, including instructions for detecting if workload unbalance is detected in real time and iteratively selecting one database at a time to migrate to a different server to balance the workload; and
code for determining a metric for a given database configuration including a mean and a variance, wherein the variance is determined as:
σ 2 =c mem ·σ memCap 2 +c cpu ·σ cpuCap 2 ,
where c mem and c cpu are parameters for calibrating different units between memory and a CPU.
11. The system of claim 10 , comprising code for applying a metric to measure a goodness of a given database configuration.
12. The system of claim 11 , wherein the metric comprises system resources including processor (CPU) usage and memory usage.
13. The system of claim 10 , wherein the metric combines different factors in a unified way through a weighting strategy and a vector norm.
14. The system of claim 10 , wherein the code for selecting a set of master databases and slave databases for migration further comprises considering one or more factors including (a) the expect cost reduction after the migration, (b) the master-to-slave ratio at each of the server after migration, and (c) the migration cost that is related to the size of each database.
15. The system of claim 10 , comprising code for choosing an optimal order of migration to minimize impact on the system during migration.
16. The system of claim 10 , comprising code for iteratively selecting a next database to migrate and a corresponding target database server to eliminate a hot spot.
17. The system of claim 10 , comprising code for iteratively migrating one database at a time until all hot spots are eliminated.
18. The system of claim 10 , comprising code for setting
c
mem
=
1
μ
memCap
2
and
c
cpu
=
1
μ
cpuCap
2
.