A database scheduling method and apparatus
By calculating the latency, resource, and failure rate scores of candidate scheduling nodes in Kubernetes, the node selection for MySQL services is optimized, solving the problem of insufficient node selection in existing technologies and improving the performance and high availability of the database cluster.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD
- Filing Date
- 2022-07-26
- Publication Date
- 2026-06-16
AI Technical Summary
Existing K8s containerized MySQL service scheduling solutions have shortcomings in node selection and high availability, resulting in a high failure rate for database instance startup and failing to effectively consider latency requirements, thus affecting cluster performance.
By calculating the latency and resource scores of candidate scheduling nodes and combining them with the failure rate, a priority score is determined, and node selection is optimized to improve the success rate and performance of database instances.
It improves the performance and availability of the database cluster, reduces the node failure rate, and ensures the high availability and latency requirements of the MySQL cluster.
Smart Images

Figure CN116263698B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, specifically to a database scheduling method and apparatus, a computing device, and a computer storage medium. Background Technology
[0002] With the popularization of open-source technologies and the continuous advancement of cloud computing technologies, the public cloud market is growing rapidly. As a representative of open-source relational databases, MySQL, with its ease of use and high performance, is increasingly being used in systems such as blogs, websites, and data warehouses. Therefore, providing MySQL services on the public cloud has become an increasingly urgent need. Currently, there are two ways to provide MySQL services on the public cloud: one is to provide database services as virtual machines based on OpenStack VMs, and the other is to provide database services in a containerized form based on Kubernetes (K8s). Containerization, with its advantages of fast startup and minimal resource waste, has become a common method for database cloudification. Therefore, how to quickly and efficiently start containerized MySQL services on a K8s cluster while minimizing the burden on operations and maintenance personnel is becoming an increasingly pressing need.
[0003] There are three main existing solutions for providing database scheduling in a containerized form based on Kubernetes:
[0004] The first type is the general scheduling strategy of Kubernetes (K8s). The general scheduling strategy of K8s mainly considers the following aspects: node selection. Based on the constraints of the current database instance's operation, a suitable set of nodes is selected. These constraints generally refer to characteristics such as CPU, memory, node labels, taints, node affinity, and node anti-affinity. Based on these selected node sets, the K8s scheduler will score these nodes. The scheduling priority of each node depends on the score. The scheduler will schedule the database instance to start on the node with the highest priority.
[0005] The second approach is an availability zone-based MySQL scheduling strategy. This strategy proposes the concept of a high-availability MySQL cluster, achieving high availability by having the master and slave nodes located in different availability zones within a Kubernetes cluster. This strategy first obtains the availability zone information for each worker node in the scheduler cluster and then distributes the master and slave nodes of the high-availability MySQL cluster across multiple scheduler clusters in different availability zones, thereby ensuring the availability of the high-availability MySQL cluster.
[0006] The third approach is a scheduling strategy based on master-slave balancing scores. The master-slave balancing score is calculated by dividing the number of MySQL master nodes in the candidate scheduling cluster by the total number of MySQL nodes in that cluster. This strategy ensures that MySQL services are evenly distributed across different Kubernetes clusters. Furthermore, since these clusters are located in different regions, high availability for the entire cluster is guaranteed.
[0007] However, the three database scheduling schemes mentioned above each have the following drawbacks:
[0008] For the first approach, the process is divided into node filtering and node scoring. The node filtering strategy is relatively simple, only filtering some basic machine metrics, such as node tags, currently available CPU and memory resources, etc. The node scoring is also based on these fixed metrics. This approach simply filters nodes according to these metrics. Once a node is selected for scheduling, database instances will be scheduled to that node. According to this strategy, even if a large number of database instances fail to start on that node within a certain period of time, i.e., the node experiences an unknown anomaly, as long as the node has sufficient resources, Kubernetes will still prioritize scheduling newly created database instances to that node, and the node's scheduling priority will not change.
[0009] For Solutions 2 and 3, while ensuring high availability of the MySQL cluster, their core design principle is to distribute the MySQL master-slave instances in the cluster to different Kubernetes clusters in different regions, taking into account load balancing across different Kubernetes clusters during the allocation process. However, when delving into the node selection for each Kubernetes cluster, the default Kubernetes scheduling strategy is still used, which leads to the same problems as Solution 1. Furthermore, a MySQL cluster is not a simple web system; the integrity of data on each MySQL node in the cluster is achieved through master-slave transaction synchronization. Whether using master-slave replication or master-slave semi-synchronous replication, the latency requirements are very high. When the master database performs an operation on a transaction, it will wait for at least one slave database to return an acknowledgment character; otherwise, the master database will be stuck on that transaction until the transaction times out. Summary of the Invention
[0010] In view of the above problems, the present invention is proposed to provide a database scheduling method and apparatus, computing device and computer storage medium that overcomes or at least partially solves the above problems.
[0011] According to one aspect of the present invention, a database scheduling method is provided, comprising the following steps:
[0012] Receives a request to create a database instance;
[0013] Based on the creation request, a preliminary set of candidate scheduling nodes is selected;
[0014] For any candidate scheduling node in the candidate scheduling node set, calculate the latency score and resource score of the candidate scheduling node; and calculate the priority score of the candidate scheduling node based on the latency score and resource score of the candidate scheduling node.
[0015] The target scheduling node is determined based on the priority scores of the candidate scheduling nodes, and the database instance is created on the target scheduling node.
[0016] Furthermore, after initially selecting a set of candidate scheduling nodes based on the creation request, the method further includes:
[0017] Determine whether the database instance requested to be created is the first instance in the candidate scheduling node set;
[0018] If it is determined that the database instance requested to be created is the first instance in the candidate scheduling node set, then for any candidate scheduling node in the candidate scheduling node set, the resource score of the candidate scheduling node is calculated; and the priority score of the candidate scheduling node is calculated based on the resource score of the candidate scheduling node.
[0019] The specific steps for calculating the latency score and resource score of any candidate scheduling node in the candidate scheduling node set, and for calculating the priority score of the candidate scheduling node based on its latency score and resource score, are as follows:
[0020] If it is determined that the database instance to be created is not the first instance in the candidate scheduling node set, then for any candidate scheduling node in the candidate scheduling node set, the latency score and resource score of the candidate scheduling node are calculated; and the priority score of the candidate scheduling node is calculated based on the latency score and resource score of the candidate scheduling node.
[0021] Furthermore, the step of calculating the latency score of any candidate scheduling node in the candidate scheduling node set further includes:
[0022] If it is determined that the database instance to be created is not the first instance in the candidate scheduling node set, the scheduling node k corresponding to the created instance in the candidate scheduling node set is determined, and the delay matrix composed of the delay between the scheduling node k and other candidate scheduling nodes in the candidate scheduling node set is read from the meta database.
[0023] The average delay of the candidate scheduling node set is calculated based on the delay matrix.
[0024] For any candidate scheduling node j in the candidate scheduling node set, when the delay between candidate scheduling node j and node k is not 0, the delay score of the candidate scheduling node is calculated based on the average delay and the delay between candidate scheduling node j and node k; when the delay between candidate scheduling node j and node k is 0, the minimum non-zero delay between any candidate scheduling node in the candidate scheduling node set and other candidate scheduling nodes is read from the metadata database, and the delay score of the candidate scheduling node is calculated based on the average delay and the minimum non-zero delay.
[0025] Furthermore, before calculating the latency score and resource score of any candidate scheduling node in the candidate scheduling node set, and before calculating the priority score of the candidate scheduling node based on the latency score and resource score, the method further includes:
[0026] Calculate the time delay between any candidate scheduling node in the candidate scheduling node set and other candidate scheduling nodes;
[0027] The calculation results are written into the metadata database.
[0028] Furthermore, the specific steps for calculating the resource score of any candidate scheduling node in the candidate scheduling node set are as follows:
[0029] For any candidate scheduling node in the candidate scheduling node set, the failure rate of the candidate scheduling node is calculated based on the number of instances that have been successfully scheduled and are running normally on the candidate scheduling node and the number of instances that have been scheduled on the candidate scheduling node.
[0030] Based on the relationship between the failure rate and the preset failure threshold, combined with the resource score of the candidate scheduling node, the resource score of the candidate scheduling node is calculated. When the failure rate is greater than the preset failure threshold, the resource score of the candidate scheduling node is set to 0. When the failure rate is less than or equal to the preset failure threshold, the resource score of the candidate scheduling node is the product of the difference between 1 and the failure rate and the resource score of the candidate scheduling node.
[0031] Furthermore, after determining the target scheduling node based on the priority scores of the candidate scheduling nodes and creating the database instance on the target scheduling node, the method further includes:
[0032] Determine whether the database instance created after creation was successful and can run normally;
[0033] The judgment result is written to the metadata database for calculating the failure rate based on the judgment result.
[0034] Furthermore, the step of calculating the priority score of the candidate scheduling node based on the latency score and resource score of the candidate scheduling node further includes:
[0035] For any candidate scheduling node in the candidate scheduling node set, the node resource weight and latency weight of the candidate scheduling node are preset.
[0036] The calculated latency score of the candidate scheduling node is multiplied by the preset latency weight, and the calculated resource score of the candidate scheduling node is multiplied by the preset node resource weight. The sum of the products is the priority score of the candidate scheduling node.
[0037] According to another aspect of the present invention, a database scheduling apparatus is provided, comprising:
[0038] The request receiving module is used to receive requests to create database instances;
[0039] The initial screening module is used to initially screen out a set of candidate scheduling nodes based on the creation request;
[0040] The calculation module is used to calculate the latency score and resource score of any candidate scheduling node in the candidate scheduling node set; and to calculate the priority score of the candidate scheduling node based on the latency score and resource score of the candidate scheduling node.
[0041] The execution module is used to determine the target scheduling node based on the priority score of the candidate scheduling nodes, and to create the database instance on the target scheduling node.
[0042] According to another aspect of the present invention, a computing device is provided, comprising: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other via the communication bus;
[0043] The memory is used to store at least one executable instruction, which causes the processor to perform an operation corresponding to any of the database scheduling methods described above.
[0044] According to another aspect of the present invention, a computer storage medium is provided, the storage medium storing at least one executable instruction that causes a processor to perform an operation corresponding to a database scheduling method as described in any of the preceding claims.
[0045] According to the database scheduling method of the present invention, the following advantages are achieved:
[0046] Taking into account the latency of candidate scheduling nodes, a latency scoring option was added during scheduling. A priority score was obtained based on the latency score and resource score, and the target scheduling node was determined based on the priority score, which greatly ensured the performance of the database cluster.
[0047] The above description is merely an overview of the technical solution of the present invention. In order to better understand the technical means of the present invention and to implement it in accordance with the contents of the specification, and in order to make the above and other objects, features and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0048] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0049] Figure 1 A schematic flowchart of a database scheduling method provided by an embodiment of the present invention is shown;
[0050] Figure 2 The diagram illustrates a flowchart of a database scheduling method according to a specific embodiment of the present invention.
[0051] Figure 3 A flowchart illustrating the calculation of the time delay matrix is shown;
[0052] Figure 4 This diagram illustrates the structure of a database scheduling device according to an embodiment of the present invention.
[0053] Figure 5 A schematic diagram of the structure of a computing device provided in an embodiment of the present invention is shown. Detailed Implementation
[0054] Exemplary embodiments of the invention will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this invention will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
[0055] Figure 1-2A flowchart of a database scheduling method according to an embodiment of the present invention is shown, which is applied in a computing device. The computing device includes a processor, a memory, a communication interface, and a communication bus. The processor, the memory, and the communication interface communicate with each other through the communication bus. The memory stores at least one executable instruction, which causes the processor to perform an operation corresponding to the database scheduling method. Figure 1-2 As shown, the method includes the following steps:
[0056] Step 110: Receive the database instance creation request;
[0057] Step 120: Based on the creation request, initially select a set of candidate scheduling nodes;
[0058] Step 130: For any candidate scheduling node in the candidate scheduling node set, calculate the latency score and resource score of the candidate scheduling node; and calculate the priority score of the candidate scheduling node based on the latency score and resource score of the candidate scheduling node.
[0059] Step 140: Determine the target scheduling node based on the priority scores of the candidate scheduling nodes, and create the database instance on the target scheduling node. The target scheduling node determined in this step is the node with the higher priority score.
[0060] In this method, after receiving a request to create a MySQL database instance, the scheduler will use the default strategy of K8s to pre-screen a set of candidate scheduling nodes that meet the conditions, that is, to execute the operation in step 120. If the pre-screened set of candidate scheduling nodes is empty, it means that the MySQL database resources are insufficient and the request to create a database instance cannot be executed, so the scheduling fails and the process ends; otherwise, the request to create a database instance can be executed, and steps 130 to 140 can be executed.
[0061] In an alternative approach, after step 120: initially selecting a set of candidate scheduling nodes based on the creation request, the database scheduling method further includes the following steps:
[0062] Determine whether the database instance requested to be created is the first instance in the candidate scheduling node set;
[0063] If it is determined that the database instance requested to be created is the first instance in the candidate scheduling node set, then for any candidate scheduling node in the candidate scheduling node set, the resource score of the candidate scheduling node is calculated; and the priority score of the candidate scheduling node is calculated based on the resource score of the candidate scheduling node.
[0064] In step 130, for any candidate scheduling node in the candidate scheduling node set, the latency score and resource score of the candidate scheduling node are calculated; and the priority score of the candidate scheduling node is calculated based on the latency score and resource score of the candidate scheduling node, specifically as follows:
[0065] If it is determined that the database instance to be created is not the first instance in the candidate scheduling node set, then for any candidate scheduling node in the candidate scheduling node set, the latency score and resource score of the candidate scheduling node are calculated; and the priority score of the candidate scheduling node is calculated based on the latency score and resource score of the candidate scheduling node.
[0066] In this optional approach, if the database instance to be created is the first instance in the candidate scheduling node set, it means that no instance was created on the candidate scheduling node set before creating this instance. In this case, it is only necessary to calculate the resource score of each candidate scheduling node and determine the priority score of the candidate scheduling node based on the resource score of each candidate scheduling node. If the database instance to be created is not the first instance in the candidate scheduling node set, it is necessary to consider the latency when the database instance is scheduled from one candidate scheduling node to another. In this case, when determining the priority score, it is necessary to comprehensively consider the latency score and the resource score.
[0067] In an optional approach, calculating the latency score of any candidate scheduling node in the candidate scheduling node set further includes:
[0068] If it is determined that the database instance requested for creation is not the first instance in the candidate scheduling node set, the scheduling node k corresponding to the created instance in the candidate scheduling node set is determined. The delay matrix composed of the delays between scheduling node k and other candidate scheduling nodes in the candidate scheduling node set is read from the metadata database. The created instance corresponding to scheduling node k is the primary instance, and the delay matrix composed of the delays between scheduling node k corresponding to the primary instance and other candidate scheduling nodes in the candidate scheduling node set is: delay k =(delay) nk ...delay mk ), where n≤m, and (n, ...,m) is the set of candidate scheduling nodes that meet the conditions pre-screened using the default strategy of K8s;
[0069] The average delay of the candidate scheduling node set is calculated based on the delay matrix. The specific average delay is represented by avg(delay).
[0070] For any candidate scheduling node j in the candidate scheduling node set, when the delay between candidate scheduling node j and node k is not zero, the delay score of the candidate scheduling node is calculated based on the average delay and the delay between candidate scheduling node j and node k; when the delay between candidate scheduling node j and node k is zero, the minimum non-zero delay between any candidate scheduling node in the candidate scheduling node set and other candidate scheduling nodes is read from the metadata database, and the delay score of the candidate scheduling node is calculated based on the average delay and the minimum non-zero delay. Specifically, the delay between candidate scheduling node j and node k is represented by the delay function. jk The delay score is indicated by the time delay. The following formula is used to calculate:
[0071]
[0072] In the above formula, delay x For (delay) nx ...delay mx The non-zero minimum value in ), where x is any node in the candidate scheduling node set (n, ..., m), if delay x If there is no non-zero minimum value, then set delay. x =1; delay jk The delay represents the time delay between candidate scheduling node j and candidate scheduling node k. jk and delay x All data is read from the metadata database.
[0073] In this optional approach, if the delay matrix consisting of the delays between the scheduling node k and other candidate scheduling nodes in the candidate scheduling node set cannot be read from the metadata database, then... k If the latency of the nodes is considered to be consistent, then from the perspective of latency, there is no difference between the candidate scheduling nodes.
[0074] In an optional embodiment, before calculating the latency score and resource score of any candidate scheduling node in the candidate scheduling node set, and before calculating the priority score of the candidate scheduling node based on the latency score and resource score, the method further includes:
[0075] Calculate the time delay between any candidate scheduling node in the candidate scheduling node set and other candidate scheduling nodes;
[0076] The calculation results are written into the metadata database.
[0077] In this optional approach, calculating the latency between any candidate scheduling node and other candidate scheduling nodes facilitates the reading of relevant parameters from the metadata database when calculating latency scores. For example... Figure 3 As shown, each candidate scheduling node has an indicator acquisition module. This module calculates the latency between the candidate scheduling node and other candidate scheduling nodes on a timely basis and saves the calculated latency to the metadata database. Specifically, the indicator acquisition module first obtains the information of the candidate scheduling nodes. If successful, it calculates the latency and writes the result to the metadata database. If the indicator acquisition module cannot obtain the information of the candidate scheduling nodes, it checks whether it has received an exit command. If it does, it exits the calculation; otherwise, it tries to obtain the candidate scheduling node information again. Furthermore, after the indicator acquisition module writes the calculation result to the metadata database, regardless of whether the writing to the metadata database is successful, it checks whether it has received an exit command after the write command is executed.
[0078] In one alternative approach, the specific steps for calculating the resource score of any candidate scheduling node in the candidate scheduling node set are as follows:
[0079] For any candidate scheduling node in the candidate scheduling node set, the failure rate of the candidate scheduling node is calculated based on the number of instances successfully scheduled and running normally on the candidate scheduling node and the number of instances already scheduled on the candidate scheduling node; specifically, for any candidate scheduling node j, the failure rate is... Where N total N represents the number of instances that have been scheduled on candidate scheduling node j. suc This indicates the number of instances that were successfully scheduled and are running normally on the candidate scheduling node;
[0080] Based on the relationship between the failure rate and the preset failure threshold, combined with the resource score of the candidate scheduling node, the resource score of the candidate scheduling node is calculated. When the failure rate is greater than the preset failure threshold, the resource score of the candidate scheduling node is set to 0. When the failure rate is less than or equal to the preset failure threshold, the resource score of the candidate scheduling node is the product of the difference between 1 and the failure rate and the resource score of the candidate scheduling node.
[0081] Specifically, the resource score of the candidate scheduling node. The following formula is used to calculate:
[0082]
[0083] In the above formula, p is the preset fault threshold, and resScore is... jresScore represents the resource score of a node. j Calculated using the default scoring rules of Kubernetes.
[0084] In this optional approach, if the failure rates of all candidate scheduling nodes are consistent, it means that there is no difference between the candidate scheduling nodes in terms of failure rate.
[0085] In an optional approach, calculating the priority score of the candidate scheduling node based on its latency score and resource score further includes:
[0086] For any candidate scheduling node in the candidate scheduling node set, a preset node resource weight is assigned to the candidate scheduling node. res and delay weight delay ;
[0087] The calculated latency scores of the candidate scheduling nodes and preset latency weight delay Multiply by the calculated resource scores of the candidate scheduling nodes. and preset node resource weights res Multiply them, and the sum of the products is the priority score of the candidate scheduling node. j , that is:
[0088]
[0089] In one alternative approach, after determining the target scheduling node based on the priority scores of the candidate scheduling nodes and creating the database instance on the target scheduling node, the method further includes:
[0090] Determine whether the database instance created after creation was successful and can run normally;
[0091] The judgment result is written to the metadata database for calculating the failure rate based on the judgment result.
[0092] In this optional approach, writing the judgment result into the metadata database makes it easier to calculate the failure rate of the candidate scheduling node based on the judgment result.
[0093] This invention provides a database scheduling method that incorporates the concept of failure rate into the node scoring stage of the Kubernetes scheduling model. The resource score of a node can be calculated based on the relationship between the failure rate and a preset failure threshold. By using the failure rate, MySQL instances can be avoided from being scheduled to nodes that frequently experience failures, thus improving the success rate of instance operation. Simultaneously, the failure rate is modified in real-time according to the scheduling situation, ensuring its effectiveness. Furthermore, considering the latency requirements of the MySQL master-slave cluster, a latency scoring option is added during scheduling. Compared to the second and third solutions in the prior art, this invention's database scheduling method takes latency into account, which can greatly guarantee the performance of the MySQL cluster.
[0094] Figure 4 A schematic diagram of an embodiment of a database scheduling device according to the present invention is shown. Figure 4 As shown, the device includes:
[0095] The request receiving module 210 is used to receive requests for creating a database instance;
[0096] The initial screening module 220 is used to initially screen out a set of candidate scheduling nodes based on the creation request;
[0097] The calculation module 230 is used to calculate the latency score and resource score of any candidate scheduling node in the candidate scheduling node set; and to calculate the priority score of the candidate scheduling node based on the latency score and resource score of the candidate scheduling node.
[0098] The execution module 240 is used to determine the target scheduling node based on the priority score of the candidate scheduling nodes, and to create the database instance on the target scheduling node.
[0099] In this method, after the scheduler receives the creation request from the receiving request module 210, it will trigger the initial screening module 220 to pre-screen the candidate scheduling nodes that meet the conditions using the default strategy of K8s. If the pre-screened candidate scheduling node set is empty, it means that the MySQL database resources are insufficient and the request to create a database instance cannot be executed, and the scheduling fails; otherwise, the request to create a database instance can be executed, triggering the calculation module 230 to calculate the priority score and triggering the execution module 240 to execute the creation instruction.
[0100] In an optional approach, a judgment module is also included. After the initial screening module 220 initially selects a set of candidate scheduling nodes based on the creation request, the judgment module is triggered to determine whether the database instance created by the request is the first instance of the set of candidate scheduling nodes.
[0101] If the judgment module determines that the database instance requested to be created is the first instance in the candidate scheduling node set, then for any candidate scheduling node in the candidate scheduling node set, the resource score of the candidate scheduling node is calculated; and the priority score of the candidate scheduling node is calculated based on the resource score of the candidate scheduling node.
[0102] The calculation module 230 calculates the latency score and resource score of any candidate scheduling node in the candidate scheduling node set; and calculates the priority score of the candidate scheduling node based on the latency score and resource score of the candidate scheduling node, specifically as follows:
[0103] If the judgment module determines that the database instance requested to be created is not the first instance in the candidate scheduling node set, then the calculation module 230 is triggered to calculate the latency score and resource score of any candidate scheduling node in the candidate scheduling node set; and to calculate the priority score of the candidate scheduling node based on the latency score and resource score of the candidate scheduling node.
[0104] In an optional manner, the calculation module 230, for any candidate scheduling node in the candidate scheduling node set, calculates the latency score of the candidate scheduling node, which further includes:
[0105] If it is determined that the database instance requested for creation is not the first instance in the candidate scheduling node set, the calculation module 230 determines the scheduling node k corresponding to the created instance in the candidate scheduling node set, and reads the delay matrix composed of the delay between the scheduling node k and other candidate scheduling nodes in the candidate scheduling node set from the metadata database. The created instance corresponding to scheduling node k is the primary instance, and the delay matrix composed of the delay between the scheduling node k corresponding to the primary instance and other candidate scheduling nodes in the candidate scheduling node set is: delay k =(delay) nk ...delay mk ), where n≤m, and (n, ...,m) is the set of candidate scheduling nodes that meet the conditions pre-screened using the default strategy of K8s;
[0106] The calculation module 230 calculates the average delay of the candidate scheduling node set based on the delay matrix. The specific average delay is represented by avg(delay).
[0107] For any candidate scheduling node j in the candidate scheduling node set, if the delay between candidate scheduling node j and node k is not zero, the calculation module 230 is triggered to calculate the delay score of the candidate scheduling node based on the average delay and the delay between candidate scheduling node j and node k; if the delay between candidate scheduling node j and node k is zero, the calculation module 230 is triggered to read the minimum non-zero delay between any candidate scheduling node in the candidate scheduling node set and other nodes in the candidate scheduling node set from the metadata database, and calculate the delay score of the candidate scheduling node based on the average delay and the minimum non-zero delay. Specifically, the delay between candidate scheduling node j and node k is represented by the delay function. jk The delay score is indicated by the time delay. The following formula is used to calculate:
[0108]
[0109] In the above formula, delay x For (delay) nx ...delay mx The non-zero minimum value in ), where x is any candidate scheduling node in the set of candidate scheduling nodes (n, ..., m), if delay x If there is no non-zero minimum value, then set delay. x =1; delay jk The delay represents the time delay between candidate scheduling node j and candidate scheduling node k. jk and delay x All data is read from the metadata database.
[0110] In this optional approach, if the calculation module 230 cannot read the delay matrix (delay) composed of the delays between the scheduling node k and other candidate scheduling nodes in the candidate scheduling node set from the metadata database, k If the latency of the nodes is considered to be consistent, then from the perspective of latency, there is no difference between the candidate scheduling nodes.
[0111] In an alternative approach, before the calculation module 230 calculates the latency score and resource score of any candidate scheduling node in the candidate scheduling node set, and before calculating the priority score of the candidate scheduling node based on the latency score and resource score, the calculation module 230 further performs the following operations:
[0112] The calculation module 230 calculates the time delay between any candidate scheduling node in the candidate scheduling node set and other candidate scheduling nodes;
[0113] The calculation module 230 writes the calculation results to the metadata database so that relevant parameters can be read from the metadata database when calculating the latency score.
[0114] In an alternative approach, the calculation module 230 calculates the resource score of any candidate scheduling node in the candidate scheduling node set using the following specific steps:
[0115] For any candidate scheduling node in the candidate scheduling node set, the calculation module 230 calculates the failure rate of the candidate scheduling node based on the number of instances successfully scheduled and running normally on the candidate scheduling node and the number of instances already scheduled on the candidate scheduling node; specifically, for any candidate scheduling node j, the failure rate is... Where N total N represents the number of instances that have been scheduled on candidate scheduling node j. suc This indicates the number of instances that were successfully scheduled and are running normally on the candidate scheduling node;
[0116] The calculation module 230 calculates the resource score of the candidate scheduling node based on the relationship between the failure rate and the preset failure threshold and the resource score of the candidate scheduling node. When the failure rate is greater than the preset failure threshold, the resource score of the candidate scheduling node is set to 0. When the failure rate is less than or equal to the preset failure threshold, the resource score of the candidate scheduling node is the product of the difference between 1 and the failure rate and the resource score of the candidate scheduling node.
[0117] Specifically, the resource score of the candidate scheduling node. The following formula is used to calculate:
[0118]
[0119] In the above formula, p is the preset fault threshold, and resScore is... j The resource score of the node is calculated using the default scoring rules of Kubernetes.
[0120] In this optional approach, if the failure rates of all candidate scheduling nodes are consistent, it means that there is no difference between the candidate scheduling nodes in terms of failure rate.
[0121] In an optional manner, the calculation module 230 calculates the priority score of the candidate scheduling node based on the latency score and resource score of the candidate scheduling node, further including:
[0122] Preset node resource weights in the database cluster res and delay weight delay ;
[0123] The calculation module 230 calculates the latency score of the candidate scheduling node. and preset latency weight delay Multiply by the calculated resource scores of the candidate scheduling nodes. and preset node resource weights res Multiply them, and the sum of the products is the priority score of the candidate scheduling node. j , that is:
[0124]
[0125] In one alternative approach, after the execution module 240 determines the target scheduling node based on the priority scores of the candidate scheduling nodes and creates the database instance on the target scheduling node, the determination module further performs the following operations:
[0126] The judgment module determines whether the database instance created after creation is successful and can run normally;
[0127] The judgment module writes the judgment result to the metadata database for calculating the failure rate based on the judgment result.
[0128] In this optional approach, the judgment module writes the judgment result into the metadata database, which facilitates the calculation module 230 to calculate the failure rate of the candidate scheduling node based on the judgment result.
[0129] The resource score of a node can be calculated based on the relationship between the failure rate and the preset failure threshold. By using the failure rate, MySQL instances can be avoided from being scheduled to nodes that frequently fail, thus improving the success rate of instance operation. At the same time, the failure rate is also modified in real time according to the scheduling situation to ensure its effectiveness. Considering the latency requirements of the MySQL master-slave cluster, a latency scoring option is added during scheduling. Compared with the second and third solutions of the existing technology, the database scheduling method of this embodiment takes into account the latency situation, which can greatly guarantee the performance of the MySQL cluster.
[0130] This invention provides a non-volatile computer storage medium storing at least one executable instruction that can execute a database scheduling method in any of the above method embodiments.
[0131] Figure 5 The diagram shows a structural schematic of an embodiment of a computing device according to the present invention. The specific embodiments of the present invention do not limit the specific implementation of the computing device.
[0132] like Figure 5As shown, the computing device may include: a processor 402, a communications interface 404, a memory 406, and a communications bus 408.
[0133] The processor 402, communication interface 404, and memory 406 communicate with each other via communication bus 408. Communication interface 404 is used to communicate with other network elements such as clients or other servers. The processor 402 executes program 410, specifically performing the relevant steps in the above-described embodiment of a database scheduling method for computing devices.
[0134] Specifically, program 410 may include program code that includes computer operation instructions.
[0135] Processor 402 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention. The database scheduling device includes one or more processors, which may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0136] Memory 406 is used to store program 410. Memory 406 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.
[0137] Specifically, program 410 can be used to cause processor 402 to execute a database scheduling method in any of the above method embodiments.
[0138] The algorithms or displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, the embodiments of the present invention are not directed to any particular programming language. It should be understood that the content of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0139] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0140] Similarly, it should be understood that, in order to simplify the invention and aid in understanding one or more of the various inventive aspects, features of the embodiments of the invention are sometimes grouped together in a single embodiment, figure, or description thereof in the above description of exemplary embodiments of the invention. However, this disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.
[0141] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0142] Furthermore, those skilled in the art will understand that although some embodiments herein include certain features included in other embodiments but not others, combinations of features from different embodiments are intended to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.
[0143] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components according to the embodiments of the present invention. The present invention can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such programs implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0144] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be construed as limiting the order of execution.
Claims
1. A database scheduling method, characterized in that, Includes the following steps: Receives a request to create a database instance; Based on the creation request, a preliminary set of candidate scheduling nodes is selected; Determine whether the database instance requested to be created is the first instance in the candidate scheduling node set; If it is determined that the database instance requested to be created is the first instance in the candidate scheduling node set, then for any candidate scheduling node in the candidate scheduling node set, the resource score of the candidate scheduling node is calculated. And the priority score of the candidate scheduling node is calculated based on the resource score of the candidate scheduling node; If it is determined that the database instance requested to be created is not the first instance in the candidate scheduling node set, then for any candidate scheduling node in the candidate scheduling node set, the latency score and resource score of the candidate scheduling node are calculated. And the priority score of the candidate scheduling node is calculated based on the latency score and resource score of the candidate scheduling node; The target scheduling node is determined based on the priority scores of the candidate scheduling nodes, and the database instance is created on the target scheduling node; For any candidate scheduling node in the set of candidate scheduling nodes, calculating the latency score of the candidate scheduling node further includes: Determine the scheduling node k corresponding to the created instance on the candidate scheduling node set, and read the delay matrix composed of the delay between the scheduling node k and other candidate scheduling nodes in the candidate scheduling node set from the metadata database; The average delay of the candidate scheduling node set is calculated based on the delay matrix. For any candidate scheduling node j in the candidate scheduling node set, when the delay between candidate scheduling node j and node k is not 0, the delay score of the candidate scheduling node is calculated based on the average delay and the delay between candidate scheduling node j and node k; when the delay between candidate scheduling node j and node k is 0, the minimum non-zero delay between any candidate scheduling node in the candidate scheduling node set and other candidate scheduling nodes is read from the metadata database, and the delay score of the candidate scheduling node is calculated based on the average delay and the minimum non-zero delay.
2. The method according to claim 1, characterized in that, For any candidate scheduling node in the set of candidate scheduling nodes, the latency score and resource score of the candidate scheduling node are calculated. Before calculating the priority score of the candidate scheduling node based on its latency score and resource score, the method further includes: Calculate the time delay between any candidate scheduling node in the candidate scheduling node set and other candidate scheduling nodes; The calculation results are written to the metadata database.
3. The method according to claim 1, characterized in that, For any candidate scheduling node in the set of candidate scheduling nodes, calculating the resource score of the candidate scheduling node further includes: For any candidate scheduling node in the candidate scheduling node set, the failure rate of the candidate scheduling node is calculated based on the number of instances that have been successfully scheduled and are running normally on the candidate scheduling node and the number of instances that have been scheduled on the candidate scheduling node. Based on the relationship between the failure rate and the preset failure threshold, combined with the resource score of the candidate scheduling node, the resource score of the candidate scheduling node is calculated. When the failure rate is greater than the preset failure threshold, the resource score of the candidate scheduling node is set to 0. When the failure rate is less than or equal to the preset failure threshold, the resource score of the candidate scheduling node is the product of the difference between 1 and the failure rate and the resource score of the candidate scheduling node.
4. The method according to claim 1, characterized in that, After determining the target scheduling node based on the priority scores of the candidate scheduling nodes and creating the database instance on the target scheduling node, the method further includes: Determine whether the database instance created after creation was successful and can run normally; The judgment result is written to the metadata database so that the failure rate can be calculated based on the judgment result.
5. The method according to claim 1, characterized in that, The step of calculating the priority score of the candidate scheduling node based on the latency score and resource score of the candidate scheduling node further includes: For any candidate scheduling node in the candidate scheduling node set, the node resource weight and latency weight of the candidate scheduling node are preset. The calculated latency score of the candidate scheduling node is multiplied by the preset latency weight, and the calculated resource score of the candidate scheduling node is multiplied by the preset node resource weight. The sum of the products is the priority score of the candidate scheduling node.
6. A database scheduling device, characterized in that, include: The request receiving module is used to receive requests to create database instances; The initial screening module is used to initially screen out a set of candidate scheduling nodes based on the creation request; The judgment module is used to determine whether the database instance requested to be created is the first instance in the candidate scheduling node set; If the judgment module determines that the database instance requested to be created is the first instance in the candidate scheduling node set, then for any candidate scheduling node in the candidate scheduling node set, the resource score of the candidate scheduling node is calculated. And the priority score of the candidate scheduling node is calculated based on the resource score of the candidate scheduling node; The calculation module is used to calculate the latency score and resource score of any candidate scheduling node in the candidate scheduling node set when the judgment module determines that the database instance to be created is not the first instance in the candidate scheduling node set. And the priority score of the candidate scheduling node is calculated based on the latency score and resource score of the candidate scheduling node; An execution module is used to determine a target scheduling node based on the priority scores of the candidate scheduling nodes, and to create the database instance on the target scheduling node; The calculation module calculates the latency score of any candidate scheduling node in the candidate scheduling node set, which further includes: The calculation module determines the scheduling node k corresponding to the created instance on the candidate scheduling node set, and reads the delay matrix composed of the delay between the scheduling node k and other candidate scheduling nodes in the candidate scheduling node set from the metadata database. The calculation module calculates the average latency of the candidate scheduling node set based on the latency matrix; For any candidate scheduling node j in the candidate scheduling node set, when the delay between candidate scheduling node j and node k is not 0, the calculation module calculates the delay score of the candidate scheduling node based on the average delay and the delay between candidate scheduling node j and node k; when the delay between candidate scheduling node j and node k is 0, the calculation module reads the minimum non-zero delay between any candidate scheduling node in the candidate scheduling node set and other candidate scheduling nodes from the metadata database, and calculates the delay score of the candidate scheduling node based on the average delay and the minimum non-zero delay.
7. A computing device, comprising: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction, which causes the processor to perform an operation corresponding to a database scheduling method as described in any one of claims 1-5.
8. A computer storage medium storing at least one executable instruction that causes a processor to perform an operation corresponding to a database scheduling method as described in any one of claims 1-5.