A node selection method and device in a cluster, electronic equipment and medium
By obtaining node load metrics from the OLAP engine cluster and performing clustering, suitable nodes are selected to handle database business, solving the latency problem caused by insufficient node processing capacity, achieving load balancing and efficient resource utilization, and improving system stability and performance.
Patent Information
- Application Number
- CN202510688813.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-27
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2045-05-27
AI Technical Summary
In OLAP engine clusters, the limited processing capacity of nodes leads to business processing delays.
By acquiring the load metrics of nodes, clustering is performed to determine the load type. Based on preset load values, appropriate nodes are selected to handle database business. Fuzzy clustering algorithms are used to improve node distinguishability and selection accuracy, thereby achieving balanced load distribution.
It alleviated the business processing delays caused by insufficient node processing capacity, improved system stability and resource utilization efficiency, reduced manual intervention, and achieved automated and intelligent resource management.
Smart Images

Figure CN120610976B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of query engine technology, and in particular to a method, apparatus, electronic device and medium for selecting nodes in a cluster. Background Technology
[0002] With the explosive growth of information in today's society, the speed and scale of data generation have far exceeded the processing capabilities of traditional databases. Data volume across all industries is expanding exponentially, with information constantly emerging from various channels such as social media, the Internet of Things, and e-commerce. Traditional relational databases are gradually proving inadequate in the face of this massive and complex data. To cope with this data deluge, OLAP (Online Analytical Processing) query engines have emerged, gradually replacing traditional databases as the dominant force in complex data analysis due to their efficiency and flexibility in multidimensional data analysis.
[0003] In an OLAP engine, multiple nodes are operated to handle database operations; these nodes form a cluster. During operation, there may be situations where a large number of transactions need to be processed, but the processing capacity of each node is limited. This can easily lead to a backlog of transactions at the nodes, causing processing delays. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and medium for selecting nodes in a cluster. It determines which node to process data from among multiple nodes that process database services based on the node's load, thereby alleviating the problem of service processing delays caused by node processing capacity limitations.
[0005] In a first aspect, embodiments of the present invention provide a method for selecting database service processing nodes in a cluster, including:
[0006] Obtain load metrics that reflect the impact of multiple nodes used to process database operations on the load size.
[0007] Based on the load metrics of multiple nodes, clustering is performed on multiple nodes to obtain various types of clusters; wherein, the type of cluster is determined according to the load type.
[0008] The load values of multiple nodes are determined based on the preset load values corresponding to the types of multiple clusters.
[0009] From multiple nodes, a node that meets the first preset load value is determined, and the database service is assigned to the determined node so that the determined node can process the database service.
[0010] The above method can determine the load value of each node by using load indicators that affect the load size of the node, and determine the node to process database services based on the load value among multiple nodes. The present invention aims to determine the node to process database services while taking load into account, thereby alleviating the problem of service processing delay caused by node processing capacity issues.
[0011] In one possible implementation, multiple nodes are clustered based on their load metrics to obtain various types of clusters, including:
[0012] Determine the correlation between the load metrics of multiple nodes and the reference values of multiple virtual nodes corresponding to each load metric;
[0013] The correlation degree between each node and each load type is determined based on the correlation degree between at least some load metrics of each node and reference values of multiple virtual nodes corresponding to at least some load metrics; wherein the type of the virtual node is the same as the load type.
[0014] The absolute load matrix for each node is determined based on the correlation between each node and each load type and the weight corresponding to each load type; where the weight of each element is determined according to the type of the virtual node corresponding to each element.
[0015] Fuzzy clustering is performed on the absolute load matrices of multiple nodes to obtain various types of clusters.
[0016] The above method can use the absolute load matrix of each node to perform fuzzy clustering to obtain the cluster to which each node belongs. Since fuzzy clustering allows a node to belong to multiple clusters, nodes with similar load conditions are distinguished by the degree to which they belong to different clusters, which improves the distinguishability of nodes and further facilitates the selection of nodes to process business.
[0017] In one possible implementation, determining the correlation between load metrics of multiple nodes and reference values of multiple virtual nodes corresponding to each load metric includes:
[0018] Determine the difference between the load metrics of multiple nodes and the reference values of multiple virtual nodes corresponding to each load metric;
[0019] For the difference between each load value and each reference value, the correlation between the load index of multiple nodes and the reference value of multiple virtual nodes corresponding to each load index is determined based on the maximum and minimum values of the differences between the load index of multiple nodes and the reference value of multiple virtual nodes corresponding to each load index, and the difference itself.
[0020] The above method uses the difference between the load index of each node and the reference value of the virtual node corresponding to each load index to indicate the correlation between each load index and the virtual node, thereby initially forming the load value of each node and improving the accuracy of subsequent clustering.
[0021] In one possible implementation, the correlation between each node and each load type is determined based on the correlation between at least a portion of the load metric of each node and reference values of multiple virtual nodes corresponding to the at least a portion of the load metric, including:
[0022] The correlation between each node and each virtual node is determined based on the correlation between at least some of the load metrics of each node and the reference values of multiple virtual nodes corresponding to at least some of the load metrics.
[0023] The correlation between each node and each load type is determined based on the correlation between each node and each type of virtual node.
[0024] In the above method, since the virtual node type is the same as the load type, the present invention determines the correlation between multiple load types and multiple nodes, and then performs clustering based on the correlation of each node, thereby improving the accuracy of subsequent clustering.
[0025] In one possible implementation, the load values of multiple nodes are determined based on preset load values corresponding to the types to which multiple clusters belong, including:
[0026] The load values of multiple nodes are determined based on the preset load values corresponding to the types to which multiple clusters belong, and the product of the membership degrees of multiple nodes with multiple types of clusters.
[0027] Specifically, for any node and any type of cluster, the membership degree between the node and the cluster is determined in the following way:
[0028] Determine multiple first distances for the node; wherein any one of the first distances is the distance from each element in the absolute load matrix of the node to the cluster center of any type of cluster.
[0029] The membership degree of a node to a cluster is determined based on the ratio between a plurality of first distances of the node and a second distance of the node; wherein the second distance is the distance from each element in the absolute load matrix of the node to the cluster center of the cluster.
[0030] The above method can determine the membership degree of each node to each cluster based on the distance of each element in the absolute load matrix of each node to the cluster center of any type of cluster. The membership degree, that is, the degree to which a node belongs to each type of cluster, is used as a weight to calculate the weighted preset load value, thereby determining the load value of each node. This makes it clearer to distinguish the load values of nodes, thus improving the accuracy of subsequent node selection.
[0031] In one possible implementation, determining the node that meets the load value of a first preset requirement from a plurality of nodes includes:
[0032] If the node is a first node used to receive user requests and allocate database services, then the first preset requirement is the first node with the smallest load value;
[0033] If the node is a second node used to execute database services, and the database services are query services, then the first preset requirement is the second node in the cluster that executes the query services submitted by the user.
[0034] If the node is a second node used to execute database business, and the database business is an import business, then the first preset requirement is that the target second node with the largest load value among at least one target second node; wherein, the target second node is the second node in the cluster that executes the query business submitted by the user.
[0035] The above method can select the first node with the least load and select the second node according to different business needs, thereby ensuring the efficient use of system resources and the balanced distribution of load, resulting in more efficient and stable system response and performance assurance.
[0036] In one possible implementation, the method further includes:
[0037] If the database service is a query service, then when the resource limit required by the user submitting the database service, the resource limit configured for the user by the cluster, and the resource size of at least one target second node that meets the second preset condition are the smallest, the resource limit of the user itself will be modified to a preset value determined based on the resource size of the target second node that meets the second preset condition.
[0038] If the database service is an import service, and the user's own resource limit exceeds the resource limit configured for the user by the cluster, and the load value of at least one target second node meets the third preset condition, then the user's own resource limit will be modified to a preset value determined based on the resource size of the second node with the largest load value among at least one target second node.
[0039] The above method, based on the user-configured resource limit, the execution database business rules, the resource size of the second node, and the load value of the second node, performs a comprehensive evaluation from multiple dimensions and then accurately corrects the imported or queried resources. This ensures the stability and efficiency of the import business while significantly reducing the reliance on manual intervention, realizing automated and intelligent resource management, demonstrating the flexibility and efficiency of dynamic resource allocation, and improving the stability and overall performance of the system.
[0040] Secondly, embodiments of the present invention provide a database service processing node selection device in a cluster, comprising:
[0041] The acquisition module is used to acquire load metrics that affect the load size of multiple nodes used to process database business.
[0042] The clustering module is used to cluster multiple nodes based on their load metrics to obtain various types of clusters; wherein the type of the cluster is determined according to the load type.
[0043] The determination module is used to determine the load values of multiple nodes based on the preset load values corresponding to the types to which multiple clusters belong.
[0044] The selection module is used to determine, from multiple nodes, a node that meets a first preset load value, and to assign the database service to the determined node so that the determined node can process the database service.
[0045] Thirdly, embodiments of the present invention provide an electronic device, comprising:
[0046] processor;
[0047] A processor for executing a computer program or instructions in the memory, such that the cluster database service processing node selection method as described in any of the first aspects is executed.
[0048] Fourthly, embodiments of the present invention provide a computer-readable storage medium, wherein when instructions in the storage medium are executed by a processor, the processor is able to execute the cluster database service processing node selection method as described in any of the first aspects.
[0049] Fifthly, embodiments of the present invention provide a computer program product, the computer program product comprising: computer program code, which, when run on a computer, causes the computer to execute the cluster database business processing node selection method as described in any of the first aspects.
[0050] Furthermore, the technical effects of any of the implementation methods in the second to fifth aspects can be found in the technical effects of different implementation methods in the first aspect, and will not be repeated here.
[0051] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description
[0052] Figure 1 A schematic diagram of a device for cluster-based database service processing is provided in an embodiment of the present invention;
[0053] Figure 2 This is a flowchart illustrating a method for selecting database service processing nodes in a cluster, as provided in an embodiment of the present invention.
[0054] Figure 3 This is a schematic diagram of a process for clustering multiple load metrics provided in an embodiment of the present invention;
[0055] Figure 4 This is a schematic diagram illustrating a method for determining node load values based on multiple load indicators, provided by an embodiment of the present invention.
[0056] Figure 5 A schematic diagram of a judgment matrix provided in an embodiment of the present invention;
[0057] Figure 6 A flowchart illustrating another method for selecting database service processing nodes in a cluster, provided by an embodiment of the present invention;
[0058] Figure 7 This is a structural diagram of a database service processing node selection device in a cluster provided by an embodiment of the present invention;
[0059] Figure 8 This is a structural diagram of a database service processing node selection device in a cluster provided by an embodiment of the present invention;
[0060] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0061] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this invention, and not all of them. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0062] In the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0063] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
[0064] Definitions:
[0065] Online Analytical Processing (OLAP) is a high-performance data analysis technique widely used in business intelligence and data warehousing. Through multidimensional data models, OLAP organizes massive amounts of data according to different dimensions, enabling users to quickly query and conduct in-depth analysis. With pre-computation and optimized storage strategies, OLAP achieves efficient query response, supports flexible operations such as slicing and drill-down, and provides accurate analytical results in a very short time.
[0066] Load balancing: In the database field, load balancing refers to distributing database query or operation requests across multiple database servers to ensure a balanced workload on each server, thereby improving the overall performance and reliability of the system. This technique helps prevent a single database server from becoming a bottleneck due to handling too many requests, thus improving system response speed, availability, and scalability.
[0067] With the explosive growth of information in today's society, most data is stored in databases, giving rise to database query and import operations. Servers that process these queries and imports are clustered together. Figure 1 As shown, this embodiment of the invention provides a cluster including first nodes 1 to n and second nodes 1 to m. The first nodes are also called FE nodes. EF nodes, depending on their function, can be FE-Flower (EF node - follower), FE-Leader (EF node - leader), or FE-Observer (FE node - observer). The second nodes are also called BE nodes. The first nodes are used to receive user requests and allocate database services, etc., while the second nodes are used to execute database services, etc. The second nodes 1 to m are connected to the database 100, and the user's terminal is connected to the first nodes 1 to n. Specifically, after receiving a user request, the first node parses the database service from the user request and sends the database service to the second node, which then executes the database service.
[0068] For example, OLAP data systems based on StarRocks (a type of cluster) often balance the load on FE nodes through database connection interfaces (such as JDBC Connector) and MySQL middleware (ProxySql). JDBC Connector uses an algorithm to randomly establish connections, while ProxySql routes queries based on the query content, user, and source IP. However, neither of these methods considers the hardware resources of the FE nodes, such as CPU (Central Processing Unit), GPU (Graphics Processing Unit), memory, disk, and network card, as well as software resources such as internal service metrics. In high-concurrency scenarios, these methods can easily lead to uneven use of hardware resources among FE nodes, causing a bottleneck effect in the StarRocks cluster and resulting in slow database processing.
[0069] In OLAP systems, the dynamic parameters of cluster resources (CPU and memory of a single task, CPU and memory of a single import task) are specified by the user when submitting the request. After receiving the database business, the FE node checks the user's resource request. If it is within the set range, it will submit it to the BE node for querying. When the BE node is in a peak query period and the overall resources are insufficient, the query will fail. At this time, manually modifying the user's resource request to ensure that the query is correct will slow down the business processing. Moreover, this process lacks flexibility and dynamic adaptability, and is complex and difficult to maintain.
[0070] Based on this, embodiments of the present invention provide a method, apparatus, electronic device, and medium for selecting database service processing nodes in a cluster, which aims to determine the nodes for processing database services while taking load into account, thereby alleviating the problem of service processing delays caused by node processing capacity issues.
[0071] The present invention will be described in detail below with reference to the accompanying drawings:
[0072] Combination Figure 2 As shown, this embodiment of the invention provides a method for selecting database service processing nodes in a cluster, including:
[0073] S210: Obtain load metrics that measure the impact of multiple nodes used to process database operations on the load size.
[0074] The load metrics include metrics that characterize the hardware usage of nodes and metrics that characterize the service performance of nodes.
[0075] For example, load metrics can be obtained by collecting node metrics using the open-source tool Prometheus. The nodes proposed in this embodiment of the invention include a first node and a second node.
[0076] Combination Figure 1 As shown, software for collecting data from nodes is deployed on the nodes of the StarRocks cluster. This software periodically (with controllable frequency) collects metrics of hardware such as CPU, GPU, memory, disk, network card, motherboard, heatsink, and power supply, and stores them in TSDB (Time Series Database). For example, TSDB can store nearly 30 days of data. The hardware metrics of each node are shown in Table 1 below.
[0077] Table 1
[0078]
[0079] Regarding the collection of service status metrics: Configure the IP (Internet Protocol) and HTTP (Hypertext Transfer Protocol) port of each FE node and BE node in the open-source tool Prometheus, and set periodic (frequency controllable) collection. The open-source tool Prometheus will periodically pull the service status metrics of FE nodes and BE nodes into TSDB. The service status metrics of FE nodes and BE nodes are shown in Table 2 below.
[0080] Table 2
[0081]
[0082] The process of obtaining the load metrics of the nodes in step 110 includes obtaining the load metrics of the first node and obtaining the load metrics of the second node.
[0083] The load metrics for the first node include, for example, CPU utilization, CPU instruction execution speed, CPU hyper-threading utilization, CPU temperature, GPU utilization, GPU memory usage, GPU performance status, GPU temperature, memory utilization, memory swapping, disk I / O per second (IOPS), disk throughput, disk utilization, disk read / write speed, disk temperature, network card latency, network card bandwidth, network card temperature, FE JVM (Java Virtual Machine) information, FE RPS (Requests Per Second), FE QPS (Queries per Second), FE connections, and FE Avg response latency.
[0084] The load metrics for the second node include, for example, CPU utilization, CPU instruction execution speed, CPU hyper-threading utilization, CPU temperature, GPU utilization, GPU memory usage, GPU performance status, GPU temperature, memory utilization, memory swap, disk I / O per second (IOPS), disk throughput, disk utilization, disk read / write speed, disk temperature, network card latency, network card bandwidth, network card temperature, BE Compacition Core, and BE read / write speed.
[0085] S220: Based on the load indicators of multiple nodes, clustering is performed on multiple nodes to obtain various types of clusters.
[0086] The type of cluster is determined according to the load type.
[0087] For example, if the load type is low load, low-medium load, medium load, medium-high load, and high load, then the cluster types are divided into low load, low-medium load, medium load, medium-high load, and high load. In this embodiment of the invention, multiple nodes can be divided into these five clusters: low load, low-medium load, medium load, medium-high load, and high load.
[0088] S230: Determine the load values of multiple nodes based on the preset load values corresponding to the types to which multiple clusters belong.
[0089] For example, the preset load value for low-load clusters is 0, the preset load value for low-medium load clusters is 1, the preset load value for medium-load clusters is 2, the preset load value for medium-high load clusters is 3, and the preset load value for high-load clusters is 4.
[0090] In detail, the load value of each node is determined by considering the preset load value corresponding to the type of the cluster to which each node belongs.
[0091] S240: From multiple nodes, determine the node that meets the first preset load value, and assign the database service to the determined node so that the determined node can process the database service.
[0092] The embodiments of the present invention can determine the load value of each node by load indicators that affect the load size of the node, and determine the node to process database services based on the node load among multiple nodes. The present invention aims to determine the node to process database services while taking load into account, thereby alleviating the problem of service processing delay caused by the node's processing capacity.
[0093] Figure 2 The nodes in the list can be the first node and the second node.
[0094] For example, embodiments of the present invention can also combine existing node selection methods with the node selection methods provided by the present invention to select a first node from multiple first nodes in the cluster.
[0095] For example, load balancing of FE nodes can be achieved through database connection interfaces (such as JDBC Connector) or ProxySql, a middleware of the relational database management system MySQL. ProxySql determines FE nodes based on conditions such as query content, user, and source IP, as well as multiple load indicators (as provided in this embodiment of the invention). The determined FE nodes continue to parse the business and send the business to BE nodes, which then execute the business.
[0096] It should be noted that clustering clusters and iterative clusters have the same properties. Clustering clusters are the clusters that are obtained after the clustering process is completed, while iterative clusters are the clusters obtained after each iteration during the clustering process.
[0097] Among them, clustering processing can be fuzzy clustering processing.
[0098] Fuzzy clustering uses the Fuzzy C-Means (FCM) algorithm for clustering. The FCM algorithm allows each data point to belong to multiple cluster centers and calculates a membership degree for each data point. The membership degree of each node represents the degree to which it belongs to a particular cluster at that stage.
[0099] In some embodiments, multiple nodes are clustered according to their load metrics to obtain various types of clusters, i.e., the implementation of step 220 may include a variety of methods.
[0100] In some embodiments, combined with Figure 3As shown, one implementation method may include:
[0101] S300: Determine the correlation between the load metrics of multiple nodes and the reference values of multiple virtual nodes corresponding to each load metric.
[0102] The virtual nodes are pre-defined, and the reference value of the virtual node corresponding to each load metric can be determined based on historical data.
[0103] Optionally, step 300 specifically includes:
[0104] Determine the difference between the load metrics of multiple nodes and the reference values of multiple virtual nodes corresponding to each load metric;
[0105] For the difference between each load value and each reference value, the correlation between the load index of multiple nodes and the reference value of multiple virtual nodes corresponding to each load index is determined based on the maximum and minimum values of the differences between the load index of multiple nodes and the reference value of multiple virtual nodes corresponding to each load index, as well as the difference itself.
[0106] For example, the correlation between a load metric and a reference value of a virtual node corresponding to that load metric can be determined using the following formula:
[0107]
[0108] Where, γ ij (k) represents the correlation between the i-th load metric and the reference value of the j-th virtual node corresponding to the i-th load metric; ρ is the resolution coefficient, typically set to 0.5; Δ ij (k)=|x′ i (k)-y′ j (k)|,x′ i (k) represents the i-th load metric, y′ j (k) represents the reference value of the j-th virtual node corresponding to the i-th load metric, Δ ij (k) is the difference between the i-th load metric and the reference value of the j-th virtual node corresponding to the i-th load metric; Δ min The minimum difference between all load metrics and the reference values of all virtual nodes. For example, when the difference between the load metric 1 of node 1 and the reference value of virtual node V4 is the minimum, then Δ... min Δ is the difference between the load metric 1 of node 1 and the reference value of virtual node V4. max Δ is the maximum difference between all load metrics and the reference values of all virtual nodes. For example, when the difference between load metric 1 of node 1 and the reference value of virtual node V10 is the largest, Δ... maxThis is the difference between the load index 1 of node 1 and the reference value of virtual node V10.
[0109] S301: Determine the correlation between each node and each load type based on the correlation between at least some load metrics of each node and the reference values of multiple virtual nodes corresponding to at least some load metrics.
[0110] The type of the virtual node is the same as the type of the load.
[0111] When the load type is low load, low-medium load, medium load, medium-high load, or high load, the virtual node type can be low load, low-medium load, medium load, medium-high load, or high load.
[0112] When the load type is low load, medium load, or high load, the virtual node type can be low load, medium load, or high load.
[0113] The multiple virtual nodes proposed in this invention can be determined according to the load type. For example, the multiple virtual nodes include 6 low-load type virtual nodes (represented by V1 to V6), 3 medium-load type virtual nodes (represented by V7 to V9), and 1 high-load type virtual node (represented by V10).
[0114] Optionally, step 301 specifically includes:
[0115] The correlation between each node and each virtual node is determined based on the correlation between at least some of the load metrics of each node and the reference values of multiple virtual nodes corresponding to at least some of the load metrics.
[0116] The correlation between each node and each load type is determined based on the correlation between each node and each type of virtual node.
[0117] For example, the association degree between each node and each virtual node is determined by the following formula:
[0118]
[0119] Each node includes k load metrics, and the correlation between each load metric and each virtual node is γ. ij (t), the correlation between a node and a virtual node is the sum of the correlations between all load metrics of a node and a virtual node, divided by the number of load metrics of a node.
[0120] Taking a node with two load metrics and multiple virtual nodes V1 to V10 as an example, the correlation between the node's first load metric and virtual node V1, and the average of the correlation between the second load metric and virtual node V1, is the correlation between the node and virtual node V1. Similarly, nine correlations can be calculated between the node and virtual nodes V2 to V10.
[0121] Among them, multiple virtual nodes are classified according to their load type. Taking low load, medium load and high load as an example, multiple virtual nodes can be divided into a low load group, a medium load group and a high load group. For example, virtual nodes V1 to V10 are divided into virtual nodes V1 to V6 as low load, virtual nodes V7 to V9 as medium load, and virtual node V10 as high load.
[0122] The average correlation between each node and each type of virtual node is used as the correlation between each node and each load type. The correlation between low load type and each node is calculated using the following formula:
[0123]
[0124] Where, γ i低 Let |S| represent the association degree between the i-th node and the low-load type. 低 | represents the number of virtual nodes belonging to the low-load type, for example, 6, then |S 低 | is 6; The sum of the correlations between the i-th node and the virtual nodes belonging to the low-load type is given. For example, if the virtual nodes belonging to the low-load type are V1 to V6, then the sum of the six correlations between the i-th node and the virtual nodes V1 to V6 divided by 6 is the correlation between the low-load type and the i-th node.
[0125] When the types of virtual nodes include low load, medium load and high load, determine one element of a node corresponding to low load, one element of a node corresponding to medium load and one element of a node corresponding to high load, and combine the elements corresponding to low load, medium load and high load to form the absolute load matrix of a node.
[0126] S302: Determine the absolute load matrix for each node based on the correlation between each node and each load type and the weight corresponding to each load type.
[0127] The weight for each load type is determined based on the number of virtual nodes belonging to each load type.
[0128] Specifically, the weight corresponding to a load type is the number of virtual nodes belonging to that load type divided by the total number of virtual nodes.
[0129] For example, if there are 6 virtual nodes in the low-load type and the total number of virtual nodes is 10, then the weight corresponding to the low-load type is 6 / 10 = 0.6; if there are 3 virtual nodes in the medium-load type, then the weight corresponding to the medium-load type is 3 / 10 = 0.3; and if there is 1 virtual node in the high-load type, then the weight corresponding to the high-load type is 1 / 10 = 0.1.
[0130] In detail, step 302 involves weighting the correlation between a node and a load type for each node and each load type using the weight corresponding to that load type, and then using the weighted correlation between a node and a load type as an element in the absolute load matrix of that node.
[0131] In this system, each element in the absolute load matrix of a node corresponds one-to-one with the load type. For example, if the load types are low load, medium load, and high load, then the elements in the absolute load matrix of each node include the elements corresponding to the low load type, the medium load type, and the high load type.
[0132] S303: Perform fuzzy clustering on the absolute load matrix of multiple nodes to obtain various types of clusters.
[0133] For example, multiple nodes include FE1 and FE2, and both FE1 and FE2 include load index 1 and load index 2. The virtual nodes are V1 to V10, and the specific values are shown in Table 1.
[0134]
[0135]
[0136] The correlation between load index 1 of FE1 and the reference values of virtual nodes V1 to V10 corresponding to load index 1, the correlation between load index 2 of FE1 and the reference values of virtual nodes V1 to V10 corresponding to load index 2, the correlation between load index 1 of FE2 and the reference values of virtual nodes V1 to V10 corresponding to load index 1, and the correlation between load index 2 of FE2 and the reference values of virtual nodes V1 to V10 corresponding to load index 2 are determined by formula (1).
[0137] The correlation calculation process between the load index 1 of FE1 and the reference value of the virtual node V1 corresponding to the load index 1 is as follows:
[0138] First, determine the difference between the load index 1 of FE1 and the reference value of the virtual node V1 corresponding to the load index 1;
[0139] Referring to Table 1, 1.0 is the value of load index 1 for FE1, and 0.95 is the reference value of virtual node V1 corresponding to load index 1. Therefore, their difference is:
[0140] Δ ij (k) = |1.0 - 0.95| = 0.05
[0141] Where 0.05 is the difference between the load index 1 of FE1 and the reference value of the virtual node V1 corresponding to the load index 1.
[0142] Then, find the maximum and minimum values of the differences between all load metrics of the two nodes and the reference values of each corresponding virtual node;
[0143] For example, if the minimum value is 0.05, then Δ min =0.05, the maximum value is the difference of 0.55 between the load index 1 of FE2 and the reference value of the virtual node V10 corresponding to load index 1, then Δ max =0.55;
[0144] Finally, the correlation between the load index 1 of FE1 and the reference value of the virtual node V1 corresponding to the load index 1 is determined.
[0145] The degree of correlation is determined by combining formula (1) and the content determined above, as shown below:
[0146]
[0147] The correlation between the load index 1 of FE1 and the reference value of the virtual node V1 corresponding to the load index 1 is 1.
[0148] Similarly, the difference between the load index 2 of FE1 and the reference value of the virtual node V1 corresponding to the load index 2 is |0.8-0.85|=0.05;
[0149] The correlation between load index 2 of FE1 and the reference value of the virtual node V1 corresponding to load index 2 is calculated as follows:
[0150]
[0151] The correlation degree between FE1 and virtual node V1 is calculated using formula (2), that is:
[0152]
[0153] Similarly, calculate the correlation degree between FE1 and virtual nodes V2 to V10, and the correlation degree between FE2 and virtual nodes V1 to V10.
[0154] Table 2 shows the correlation between FE1 and virtual nodes V1 to V10 calculated using the above method.
[0155] Table 2
[0156] node correlation FE1 and V1 1.0 FE1 and V2 0.85 FE1 and V3 0.90 FE1 and V4 0.82 FE1 and V5 0.88 FE1 and V6 0.80 FE1 and V7 0.78 FE1 and V8 0.72 FE1 and V9 0.85 FE1 and V10 0.65
[0157] The virtual nodes belonging to the low-load type are V1 to V6. Then, based on Table 2, the correlation between the low-load type and FE1 using formula (3) is as follows:
[0158]
[0159] The virtual nodes belonging to the medium load type are V7 to V9. Based on Table 2, and using a formula similar to (3) to determine the correlation between load type and FE1, the results are as follows:
[0160]
[0161] The virtual node belonging to the high-load type is V10. Then, combining with Table 2, the correlation between the high-load type and FE1 can be calculated using a formula similar to (3):
[0162]
[0163] The weights for low load types are 0.6, medium load types are 0.3, and high load types are 0.1. Therefore, the elements of the absolute load matrix of FE1 are:
[0164] The contribution of low-load types is: 0.875 × 0.6 = 0.525;
[0165] The contribution of the medium load type is: 0.783 × 0.3 = 0.235;
[0166] The contribution of high-load types is: 0.65 × 0.1 = 0.065;
[0167] The absolute load matrix of FE1 is [0.525 0.235 0.065].
[0168] Similarly, the absolute load matrix of FE2 is calculated as [0.480 0.210 0.058].
[0169] In some embodiments, another way to cluster multiple nodes based on their load metrics to obtain various types of clusters is as follows:
[0170] Based on the load metrics of multiple nodes, the initial load value of each node is determined; fuzzy clustering is then performed on the initial load values of multiple nodes to obtain various types of clusters.
[0171] The initial load value of each node can be the average of the load metrics of multiple nodes, or the weighted average of the load metrics of each node.
[0172] Step 303 performs fuzzy clustering on the absolute load values of multiple nodes to obtain various types of clusters. The fuzzy clustering process described above is the same, specifically:
[0173] For each iteration, determine the cluster centers for each iteration;
[0174] Determine the distance between the cluster centers and the absolute load matrices of multiple nodes in each iteration;
[0175] Fuzzy clustering is performed based on the distance between the cluster centers and the absolute load matrices of multiple nodes in each iteration to obtain the iterative clusters for each iteration;
[0176] The value of the objective function for each iteration is determined based on the membership degrees between multiple nodes and multiple iterative clusters;
[0177] Based on the value of the objective function in each iteration, determine the cluster centers for the next iteration;
[0178] After the iteration stopping condition is met, the iteration stops; and the iterative cluster obtained from the last iteration is the clustering cluster.
[0179] The formula for the objective function of the fuzzy clustering algorithm is:
[0180]
[0181] in, c is the membership degree of the i-th node to the j-th cluster. j is the cluster center of the j-th cluster, m is a constant (taken as 2 here) representing the fuzziness of the clustering, ||x i -c j || is the distance between the i-th node and the cluster center of the j-th cluster.
[0182] Optionally, the distance can be calculated using Euclidean distance.
[0183] In some embodiments, for each node and each iterative cluster, the node currently calculating its membership degree is called the target node, and the iterative cluster currently calculating its membership degree is called the target iterative cluster. The membership degree between the target node and the target iterative cluster is determined in the following way:
[0184] Determine the distance from each element in the absolute load matrix of the target node to the cluster center of any type of iterative cluster;
[0185] The membership degree between the target node and the target cluster is determined by the ratio between the distance from each element in the absolute load matrix of the target node to the cluster center of any type of iterative cluster and the distance from each element in the absolute load matrix of the target node to the cluster center of the target iterative cluster.
[0186] For example, the membership degree of the i-th node and the j-th iterative cluster is determined by the following formula (5):
[0187]
[0188] Where, ||x i -c k ||x represents the Euclidean distance between the i-th node and the cluster center of the k-th iterative cluster; i -c j || represents the Euclidean distance between the i-th node and the cluster center of the j-th iterative cluster; U ij Let be the membership degree between the i-th node and the j-th iterative cluster. j belongs to k.
[0189] For example, the cluster consists of 5 nodes with load types of low load, medium load, and high load. The absolute load matrix of the 5 nodes is as follows:
[0190] The absolute load matrix of node 1 is [0.8 0.1 0.1];
[0191] The absolute load matrix of node 2 is [0.2 0.7 0.1];
[0192] The absolute load matrix of node 3 is [0.1 0.1 0.8];
[0193] The absolute load matrix of node 4 is [0.6 0.3 0.1];
[0194] The absolute load matrix of node 5 is [0.3 0.5 0.2].
[0195] In the first iteration, three initial cluster centers can be randomly selected, for example, the first three data points, such as:
[0196] Cluster centers of low-load cluster C1: [0.8 0.1 0.1];
[0197] Cluster centers of the medium-load cluster C2: [0.2 0.7 0.1];
[0198] Cluster centers of high-load cluster C3: [0.1 0.1 0.8].
[0199] Calculate the Euclidean distance between each of the five nodes and the cluster center of each of the above clusters. Taking node 4 as an example, the specific steps are as follows:
[0200] The Euclidean distance between node 4 and the low-load cluster C1 is:
[0201]
[0202] The Euclidean distance between node 4 and the medium-load cluster C2 is:
[0203]
[0204] The Euclidean distance between node 4 and the high-load cluster C3 is:
[0205]
[0206] The membership degree of node 4 and low-load cluster C1 is calculated using formula (5):
[0207]
[0208] Using the above method, calculate the membership degree of node 4 with the medium-load cluster C2, the membership degree of node 4 with the high-load cluster C3, and the membership degree of other nodes with the three clusters.
[0209] Based on the membership degrees of all nodes to the three clusters and formula (4), the numerical value of the objective function for the first iteration is determined;
[0210] Based on the value of the objective function in the first iteration, the cluster centers for the second iteration are determined. This process is repeated multiple times to obtain the clusters after the clustering process.
[0211] In some embodiments, determining the load values of multiple nodes based on preset load values corresponding to the types to which multiple clusters belong includes the following implementation methods:
[0212] The load values of multiple nodes are determined based on the preset load values corresponding to the types to which multiple clusters belong, and the product of the membership degrees of multiple nodes with multiple types of clusters.
[0213] In detail, the load value of a node is determined using the following formula:
[0214]
[0215] Where: L i μ is the load value of the i-th node. ik L is the membership degree between the i-th node and the k-th cluster. k It is the preset load value corresponding to the type of the kth cluster.
[0216] For example, when a cluster includes low-load clusters, medium-load clusters, and high-load clusters, the load value of the i-th node is the sum of the three products: the preset load value corresponding to the low-load cluster, the preset load value corresponding to the medium-load cluster, and the preset load value corresponding to the high-load cluster.
[0217] For any node and any iterative cluster, the node whose membership degree is currently being calculated is called the target node, and the cluster whose membership degree is currently being calculated is called the target cluster. The membership degree between the target node and the target cluster is determined in the following way:
[0218] Determine multiple first distances for the target node; where any one of the first distances is the distance from each element in the absolute load matrix of the target node to the cluster center of any type of cluster.
[0219] The membership degree between the target node and the target cluster is determined based on the ratio between the multiple first distances of the target node and the second distance of the target node; where the second distance is the distance from each element in the absolute load matrix of the target node to the cluster center of the target cluster.
[0220] Of course, the membership degree of each iterative cluster and each node is also determined by formula (5).
[0221] In some embodiments, the values of the load metric need to be standardized, for example, by determining the standard value of the load metric using formula (6):
[0222]
[0223] Where: x ij It is the j-th load metric of the i-th node, min(x j ) and max(x j ) are the minimum and maximum values of the j-th load metric, which can be the maximum and minimum values among the historical values of the j-th load metric, x′ ij It is standardized data.
[0224] In some embodiments, after determining the standard value of the load index, the standard value of the load index is weighted using the weights corresponding to the load index, and the load value of the node is determined using the weighted load index.
[0225] For example, in combination Figure 4As shown, in this embodiment of the invention, multiple load metrics of the FE node and multiple load metrics of the BE node are first obtained. The multiple load metrics of the FE node and multiple load metrics of the BE node are then preprocessed, that is, the multiple load metrics of the FE node and multiple load metrics of the BE node are standardized as described above. The weights of the FE node and the BE node are determined using the multiple load metrics of the FE node and the BE node. The load metrics of the FE node are then weighted using the weights of the BE node and the BE node. The load values of the FE node and the BE node are then determined using the weighted multiple load metrics of the FE node and the multiple load metrics of the BE node.
[0226] The weight for each load metric is determined using the following method:
[0227] Based on each load metric, the weights corresponding to the entropy weight method and the weights corresponding to the analytic hierarchy process are determined using the entropy weight method and the analytic hierarchy process, respectively.
[0228] The weights corresponding to the entropy weight method and the weights corresponding to the analytic hierarchy process are normalized to obtain the weights corresponding to each load index.
[0229] In detail, the entropy weight method and the analytic hierarchy process (AHP) are used to calculate the two types of weights respectively. The purpose of using the entropy weight method is to avoid the influence of subjective factors and determine the weights based on the characteristics of the data itself, so that the results are more objective and reliable. The AHP method is used to add expert judgment, so that not only quantitative data are considered, but also the subjective judgment of experts can be included in the weight calculation.
[0230] The specific method for determining the weight corresponding to the load index of each node using the entropy weight method is as follows:
[0231] Calculate the information entropy for each load metric to reflect its uncertainty. The formula for information entropy is:
[0232]
[0233] Where: p ij It is the proportion of the standardized value of the i-th node on the j-th load metric to the sum of the standardized values of that load metric: k is a constant, usually taken as 1 / ln(n), where n is the number of samples.
[0234] Based on the information entropy of each load metric, the weight of each load metric is calculated. The formula for calculating the weight is as follows:
[0235]
[0236] Where: w j H is the weight of the j-th indicator. jIt is the entropy value of the information entropy of the j-th load indicator. The smaller the entropy value (i.e. the greater the change in the indicator), the greater the weight.
[0237] The specific method for determining the weight corresponding to the load metric of each node using the analytic hierarchy process is as follows:
[0238] First, construct the judgment matrix;
[0239] In detail, a judgment matrix is constructed by comparing each load metric pairwise. The matrix includes core host hardware and 25 service metrics, as shown below. Figure 5 As shown. The matrix explanation: all diagonal elements of the matrix are 1, because the relative importance of any metric to itself is 1. For example, in the first row and second column of the matrix, A12 = 3, indicating that CPU utilization is 3 times more important than CPU usage; while A21 = 1 / 3, indicating that CPU temperature is 3 times less important than CPU utilization.
[0240] Secondly, based on the judgment matrix, the eigenvectors are determined. For example, the geometric mean of each row of data in the judgment matrix is calculated, and then the geometric mean of each row of data is normalized to obtain the eigenvectors.
[0241] Normalizing the eigenvectors yields the weights of each load metric in the analytic hierarchy process (AHP). The normalization method involves dividing each element of the eigenvector by the sum of all its elements.
[0242]
[0243] Among them, v j It is the j-th element of the eigenvector, w j These are the normalized weights.
[0244] Then, the weights are merged and normalized. The two types of weights calculated by the entropy weight method and the analytic hierarchy process are combined by weighted average method. The weighted average method is used to combine the two types of weights. α is adjusted according to objective factors and expert experience. In this case, α is 0.4.
[0245]
[0246] in, The weights determined by the entropy weight method, The weights determined by the analytic hierarchy process (AHP) The weights are the weights after weight fusion.
[0247] In some embodiments, step 240, determining the node from the plurality of nodes that meets the load value of the first preset requirement, includes:
[0248] If the node is the first node used to receive user requests and allocate database services, then the first preset requirement is that the first node has the smallest load value.
[0249] This invention enables intelligent load balancing by accurately analyzing the hardware status and internal service metrics of each first node to intelligently assess its load value. Through this scientifically sound judgment mechanism, it automatically identifies and selects the most suitable first node for the current query requirement, thereby ensuring efficient utilization of system resources and balanced load distribution, resulting in more efficient and stable system response and performance assurance.
[0250] In some embodiments, step 240, determining the node from the plurality of nodes that meets the load value of the first preset requirement, includes:
[0251] If the node is a second node used to execute database business, and the database business is a query business, then the first preset requirement is that the second node in the cluster executes the query business submitted by the user.
[0252] If the node is a second node used to execute database business, and the database business is an import business, then the first preset requirement is that it is at least one target second node with the largest load value; wherein, the target second node is the second node in the cluster that executes the query business submitted by the user.
[0253] Among them, the second node in the cluster that executes the query business submitted by the user, namely the target second node, is determined by the distribution of Tablets. In Bigtable (a distributed data storage system), since a single table may store a lot of data, the efficiency of reading and writing will be very low. Therefore, Bigtable divides the table into fixed-size Tablets, which are used as the basic unit for data storage and retrieval.
[0254] Taking the target second nodes as second node A, second node B, and third node C as an example. If the nodes are second nodes used to execute database business, and the database business is a query business, then the second nodes that meet the first preset requirement are second node A, second node B, and third node C.
[0255] For example, if the third node C has the largest load value, and the node is the second node used to execute database business, and the database business is an import business, then the second node that meets the first preset requirement is the third node C.
[0256] Furthermore, since the database task is received, the user's resource request is checked. If the user's requested resource limit exceeds the resource size of the second node, an error will be automatically reported, causing the database business processing to stop, and the error needs to be manually handled.
[0257] To avoid errors, this embodiment of the invention also proposes that: if the database service is a query service, when the resource limit required by the user submitting the database service, the resource limit configured for the user by the cluster, and the resource size of at least one target second node that meets the second preset condition are the smallest, the resource limit of the user is modified to a preset value determined based on the resource size of the target second node that meets the second preset condition.
[0258] If the database service is an import service, and the user's own resource limit exceeds the resource limit configured for the user by the cluster, and the load value of at least one target second node meets the third preset condition, then the user's own resource limit will be modified to a preset value determined based on the resource size of the second node with the largest load value among at least one target second node.
[0259] The second preset condition is the minimum resource size among at least one target second node. The third preset condition is that the maximum load value among at least one target second node is greater than the preset load value corresponding to the medium-high load type.
[0260] In detail, the resource limits and Tablet distribution of the user submitting the database service are obtained: by obtaining the user's connection to the FE-Leader node through the database service-related requests submitted by the user, the user's resource limits are obtained. At the same time, based on the database table names in the database service-related requests, the corresponding Tablet distribution is obtained.
[0261] Among them, the user's own resource limit is the upper limit of the idle CPU and the upper limit of the idle memory of the second node required by the user.
[0262] Use the Prometheus tool to obtain the current free CPU and free memory of the second node.
[0263] For query tasks:
[0264] Rule 1: Determine if the resource limit of the user submitting the database service exceeds the resource limit configured by the cluster for that user. If it does, modify the user's resource limit to match the cluster's configured limit. If it does not exceed the limit, leave the user's resource limit unchanged.
[0265] Rule 2: Based on the modification results of Rule 1, determine whether the resource limit of the user submitting the database service exceeds the minimum resource size of at least one target second node. If it does, modify the resource limit of the user submitting the database service to 50% of the minimum resource size of at least one target second node. If it does not exceed the minimum resource size, do not modify the resource limit of the user submitting the database service.
[0266] Among them, the upper limit of resources required by the user is the upper limit of CPU usage of the second node, the upper limit of memory usage for querying the second node, and the upper limit of memory usage for importing from the second node.
[0267] For example, determining whether the resource limit of the user submitting the database service exceeds the resource limit configured by the cluster for that user includes:
[0268] Determine whether the user submitting the database service has more idle CPU than the cluster has configured for that user, and also determine whether the user submitting the database service has more idle memory than the cluster has configured for that user.
[0269] If any of these conditions are exceeded, the excess resources will be modified to the resources configured by the cluster for the user submitting the database service. For example, if the idle CPU is exceeded, the idle CPU of the user submitting the database service will be modified to the idle CPU configured by the cluster for that user. If the idle memory is exceeded, the idle memory of the user submitting the database service will be modified to the idle memory configured by the cluster for that user.
[0270] Taking a scenario where the second node for executing database services is defined as node A, node B, and node C, the determination of whether the user submitting the database service has a resource limit exceeding the minimum resource size among the second nodes executing the database service includes:
[0271] Choose the smallest resource size from the second node A, the second node B, and the third node C.
[0272] Determine whether the user submitting the database transaction has an upper limit of free CPU and a lower limit of free memory.
[0273] If any one of them exceeds the limit, the user's own resources for the database service will be modified to 50% of the minimum resource size.
[0274] The process of selecting the smallest resource size from the second node A, second node B, and third node C includes: determining the minimum available CPU and minimum available memory among the available CPU and available memory of the second nodes A, B, and C. If the minimum resource size is equal to the resource size of a single second node (e.g., second node A has the minimum resource size), then that second node is selected.
[0275] For import tasks:
[0276] Rule 1: Determine whether the resource limit of the user submitting the database service exceeds the resource limit configured by the cluster for that user. If it does, modify the resource limit of the user to the set limit; otherwise, do not modify the resource limit of the user.
[0277] Rule 2: Determine whether the maximum load value in at least one target second node is greater than the preset load value corresponding to the medium-high load type. If it is greater, modify the resource limit of the user who submitted the database business to 50% of the resource size of the second node with the maximum load value in at least one target second node.
[0278] For example, rule one is the same as the query business rule, and you can refer to the understanding of query business rule one.
[0279] In Rule 2, taking at least one target second node as an example, which is second node A, second node B, and third node C, the maximum load value among at least one target second node is selected, for example, third node C.
[0280] Determine whether the third node C is greater than the preset load value corresponding to the medium-high load type. The preset load value corresponding to the cluster of the medium-high load type is 3. If the preset load value is 3, it is necessary to determine whether the third node C is greater than 3. If it is greater, the resource limit of the user who submitted the database business is modified to 50% of the resource size of the third node C.
[0281] As described above, this invention enables precise dynamic resource allocation. Based on user group resource limits, table distribution, idle CPU and memory of the second node, and the load value of the second node, it accurately allocates business resources after multi-dimensional comprehensive evaluation. This strategy ensures query stability and efficiency while significantly reducing reliance on manual intervention, achieving automated and intelligent resource management, demonstrating the flexibility and efficiency of dynamic resource allocation, and improving system stability and overall performance.
[0282] Combination Figure 6 As shown, specific implementation methods are as follows in practice:
[0283] S610: Obtain load metrics for EF and BE nodes.
[0284] For example, a StarRocks cluster with 9FE and 30BE nodes collects 18 types of load metrics related to node hardware, such as CPU, GPU, memory, disk, and network card, by deploying Node Exporters and custom Exporters on the FE and BE nodes. Prometheus periodically (with controllable frequency) pulls these metrics from the Exporters and stores them in the internal time-series database TSDB (which stores the last 30 days of data by default). Simultaneously, by configuring the IP address and HTTP port of each FE and BE node in the Prometheus configuration file and setting the collection period (with controllable frequency), Prometheus will collect 7 types of load metrics related to the FE and BE services and store them in the TSDB.
[0285] S620: Determine the load values of the EF and BE nodes in the SR cluster based on their load metrics. The determination method can be found above.
[0286] S630: Receives user-submitted requests and identifies the task type and database table name of the submitting user from the submitted requests.
[0287] For example, a user-submitted request could be an SQL (Structured Query Language) database request.
[0288] S640: Based on the task type and database table name submitted by the user, obtain the user's required resource limit and Tablet distribution through the FE-Leader node, and obtain the current idle CPU and idle memory of the BE node through Prometheus.
[0289] S650: Generates the optimal resource allocation plan based on the user's required resource limit, Tablet distribution, idle CPU and memory of BE nodes, and load value of BE nodes.
[0290] The resource application scheme includes a modified resource limit for users submitting database services, as well as a second node for processing database services.
[0291] S660: Based on the load value of the FE node, select the first node with the lowest load and submit the database task to the corresponding FE node.
[0292] like Figure 7 As shown, the present invention also provides a database service processing node selection device in a cluster, comprising:
[0293] The acquisition module 710 is used to acquire load metrics that affect the load size of multiple nodes used to process database business.
[0294] Clustering module 720 is used to cluster multiple nodes based on their load metrics to obtain various types of clusters; wherein the type of cluster is determined according to the load type.
[0295] The determination module 730 is used to determine the load values of multiple nodes based on the preset load values corresponding to the types to which multiple clusters belong.
[0296] Selection module 740 is used to determine, from multiple nodes, a node that meets a first preset load value, and assign the database service to the determined node so that the determined node can process the database service.
[0297] Optional, clustering module 720, specifically used for:
[0298] Determine the correlation between the load metrics of multiple nodes and the reference values of multiple virtual nodes corresponding to each load metric;
[0299] The correlation degree between each node and each load type is determined based on the correlation degree between at least some load metrics of each node and reference values of multiple virtual nodes corresponding to at least some load metrics; wherein the type of the virtual node is the same as the load type.
[0300] The absolute load matrix of each node is determined based on the correlation between each node and each load type and the weight corresponding to each load type.
[0301] Fuzzy clustering is performed on the absolute load matrices of multiple nodes to obtain various types of clusters.
[0302] Optionally, clustering module 720 is also used for:
[0303] Determine the difference between the load metrics of multiple nodes and the reference values of multiple virtual nodes corresponding to each load metric;
[0304] For the difference between each load value and each reference value, the correlation between the load index of multiple nodes and the reference value of multiple virtual nodes corresponding to each load index is determined based on the maximum and minimum values of the differences between the load index of multiple nodes and the reference value of multiple virtual nodes corresponding to each load index, and the difference itself.
[0305] Optionally, clustering module 720 is also used for:
[0306] The correlation between each node and each virtual node is determined based on the correlation between at least some of the load metrics of each node and the reference values of multiple virtual nodes corresponding to at least some of the load metrics.
[0307] The correlation between each node and each load type is determined based on the correlation between each node and each type of virtual node.
[0308] Optionally, module 730 is determined, specifically for:
[0309] The load values of multiple nodes are determined based on the preset load values corresponding to the types to which multiple clusters belong, and the product of the membership degrees of multiple nodes with multiple types of clusters.
[0310] Specifically, for any node and any type of cluster, the membership degree between the node and the cluster is determined in the following way:
[0311] Determine multiple first distances for the node; wherein any one of the first distances is the distance from each element in the absolute load matrix of the node to the cluster center of any type of cluster.
[0312] The membership degree of a node to a cluster is determined based on the ratio between a plurality of first distances of the node and a second distance of the node; wherein the second distance is the distance from each element in the absolute load matrix of the node to the cluster center of the cluster.
[0313] Optional, select module 740, specifically for:
[0314] If the node is a first node used to receive user requests and allocate database services, then the first preset requirement is the first node with the smallest load value;
[0315] If the node is a second node used to execute database services, and the database services are query services, then the first preset requirement is the second node in the cluster that executes the query services submitted by the user.
[0316] If the node is a second node used to execute database business, and the database business is an import business, then the first preset requirement is that the target second node with the largest load value among at least one target second node; wherein, the target second node is the second node in the cluster that executes the query business submitted by the user.
[0317] Optionally, module 740 can also be used for:
[0318] If the database service is a query service, then when the resource limit required by the user submitting the database service, the resource limit configured for the user by the cluster, and the resource size of at least one target second node that meets the second preset condition are the smallest, the resource limit of the user itself will be modified to a preset value determined based on the resource size of the target second node that meets the second preset condition.
[0319] If the database service is an import service, and the user's own resource limit exceeds the resource limit configured for the user by the cluster, and the load value of at least one target second node meets the third preset condition, then the user's own resource limit will be modified to a preset value determined based on the resource size of the second node with the largest load value among at least one target second node.
[0320] The module division of the device provided by this invention is merely exemplary and should not be considered a specific limitation of this invention. In addition to the module division described above, embodiments of this invention can also be divided into other functional modules based on function, for example, combining... Figure 8 As shown, the device provided in this embodiment of the invention includes an analysis module 810, a resource calculation module 820, a load balancing module 830, and a load calculation module 840.
[0321] The load calculation module 840 is used to obtain load indicators that affect the load size of multiple first nodes and second nodes used to process database business; based on the load indicators of multiple first nodes and second nodes, the first nodes and second nodes are clustered to obtain multiple types of clusters; based on the preset load values corresponding to the types of multiple clusters, the load values of the first nodes and second nodes are determined.
[0322] Analysis module 810 is used to obtain the resource limits and Tablet distribution of the user submitting the database service.
[0323] The resource calculation module 820 is used to obtain the resource size of at least one target second node through the Prometheus tool, determine at least one target second node based on the Tablet distribution, and if the database service is a query service, then when the resource limit required by the user submitting the database service, the resource limit configured by the cluster for the user submitting the database service, and the resource size of at least one target second node that meets the second preset condition are the smallest, the resource limit of the user submitting the database service is modified to the preset value determined based on the resource size of at least one target second node that meets the second preset condition; and at least one target second node is used as the second node for executing the query service.
[0324] If the database service is an import service, and the user submitting the database service has a resource limit that exceeds the resource limit configured for the user in the cluster, and the load value of at least one target second node meets the third preset condition, then the user submitting the database service's own resource limit will be modified to a preset value determined based on the resource size of the second node with the largest load value among the at least one target second nodes, and the second node with the largest load value among the at least one target second nodes will be used as the second node to execute the query service.
[0325] The load balancing module 830 is used to determine the first node that meets the first preset requirement in the multiple first nodes, and output the database service to the first node.
[0326] In addition, combined Figures 1-8 The method and apparatus for selecting database service processing nodes in a cluster as described in this embodiment of the invention can be implemented by an electronic device.
[0327] Electronic devices, including: processors;
[0328] Memory used to store the processor's executable instructions;
[0329] The processor is configured to execute the instructions to implement the database service processing node selection method in the cluster as described above.
[0330] Based on the above introduction, an example is proposed. Figure 9 The structure of electronic devices.
[0331] The electronic device may include a processor 910 and a memory 920 storing computer program instructions.
[0332] Specifically, the processor 910 may include a central processing unit (CPU), an application specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of the present invention.
[0333] Memory 920 may include mass storage for data or instructions. For example, and not limitingly, memory 920 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where suitable, memory 920 may include removable or non-removable (or fixed) media. Where suitable, memory 920 may be internal or external to a data processing device. In a particular embodiment, memory 920 is a non-volatile solid-state memory. In a particular embodiment, memory 920 includes read-only memory (ROM). Where suitable, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.
[0334] The processor 910 implements any of the methods for performing tasks in the above embodiments by reading and executing computer program instructions stored in the memory 920.
[0335] In one example, the electronic device may also include a communication interface 930 and a bus 940. For example, Figure 9 As shown, the processor 910, memory 920, and communication interface 930 are connected via bus 940 and communicate with each other.
[0336] The communication interface 930 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of the present invention.
[0337] Bus 940 includes hardware, software, or both, that couples components of an electronic device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a memory bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 940 may include one or more buses. While specific buses are described and illustrated in embodiments of the invention, the invention contemplates any suitable bus or interconnect.
[0338] This electronic device can execute the database service processing node selection method in the cluster of this invention based on the received task, thereby achieving a combination of... Figures 1-8 The method and apparatus for selecting database business processing nodes in a cluster are described.
[0339] The electronic device provided by this invention proposes to select a first node, a second node, and the user's required resource limit, and then sends its service, the second node, and the user's required resource limit to the first node. The first node parses out the database service and determines whether the user's required resource limit is within a preset range. If it is, the first node sends the database service to the second node, and the second node executes the database service.
[0340] The present invention provides another electronic device and a first node; the electronic device selects the first node according to the method provided by the present invention, sends the service to the first node, the first node selects a second node according to the method provided by the present invention, modifies the upper limit of the user's required resources, determines whether the upper limit of the user's required resources is within a preset range, if so, sends the database service to the second node, and the second node executes the database service.
[0341] In addition, in conjunction with the electronic devices in the above embodiments, the present invention can provide a storage medium that, when the instructions in the storage medium are executed by the processor of the electronic device, enables the electronic device to execute the cluster database service processing node selection method as described in any of the above embodiments.
[0342] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0343] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0344] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0345] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0346] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for selecting database service processing nodes in a cluster, characterized in that, include: Obtain load metrics that reflect the impact of multiple nodes used to process database operations on the load size. Determine the correlation between the load metrics of multiple nodes and the reference values of multiple virtual nodes corresponding to each load metric; The correlation degree between each node and each load type is determined based on the correlation degree between at least some load metrics of each node and reference values of multiple virtual nodes corresponding to at least some load metrics; wherein the type of the virtual node is the same as the load type. The absolute load matrix of each node is determined based on the correlation between each node and each load type and the weight corresponding to each load type. Fuzzy clustering is performed on the absolute load matrices of multiple nodes to obtain various types of clusters; wherein the type of the cluster is determined according to the load type. The load values of multiple nodes are determined based on the preset load values corresponding to the types of multiple clusters. From multiple nodes, a node that meets the first preset load value is determined, and the database service is assigned to the determined node so that the determined node can process the database service.
2. The method for selecting database service processing nodes in a cluster according to claim 1, characterized in that, Determine the correlation between load metrics of multiple nodes and reference values of multiple virtual nodes corresponding to each load metric, including: Determine the difference between the load metrics of multiple nodes and the reference values of multiple virtual nodes corresponding to each load metric; For the difference between each load value and each reference value, the correlation between the load index of multiple nodes and the reference value of multiple virtual nodes corresponding to each load index is determined based on the maximum and minimum values of the differences between the load index of multiple nodes and the reference value of multiple virtual nodes corresponding to each load index, and the difference itself.
3. The method for selecting database service processing nodes in a cluster according to claim 1, characterized in that, The correlation between each node and each load type is determined based on the correlation between at least some load metrics of each node and reference values of multiple virtual nodes corresponding to at least some load metrics, including: The correlation between each node and each virtual node is determined based on the correlation between at least some of the load metrics of each node and the reference values of multiple virtual nodes corresponding to at least some of the load metrics. The correlation between each node and each load type is determined based on the correlation between each node and each type of virtual node.
4. The method for selecting database service processing nodes in a cluster according to claim 1, characterized in that, Based on preset load values corresponding to the types of multiple clusters, determine the load values of multiple nodes, including: The load values of multiple nodes are determined based on the preset load values corresponding to the types to which multiple clusters belong, and the product of the membership degrees of multiple nodes with multiple types of clusters. Specifically, for any node and any type of cluster, the membership degree between the node and the cluster is determined in the following way: Determine multiple first distances for the node; wherein any one of the first distances is the distance from each element in the absolute load matrix of the node to the cluster center of any type of cluster. The membership degree of a node to a cluster is determined based on the ratio between a plurality of first distances of the node and a second distance of the node; wherein the second distance is the distance from each element in the absolute load matrix of the node to the cluster center of the cluster.
5. The method for selecting database service processing nodes in a cluster according to any one of claims 1 to 4, characterized in that, From multiple nodes, the nodes that meet the first preset load value are determined, including: If the node is a first node used to receive user requests and allocate database services, then the first preset requirement is the first node with the smallest load value; If the node is a second node used to execute database services, and the database services are query services, then the first preset requirement is the second node in the cluster that executes the query services submitted by the user. If the node is a second node used to execute database business, and the database business is an import business, then the first preset requirement is that the target second node with the largest load value among at least one target second node; wherein, the target second node is the second node in the cluster that executes the query business submitted by the user.
6. The method for selecting database service processing nodes in a cluster according to claim 5, characterized in that, The method further includes: If the database service is a query service, then when the resource limit required by the user submitting the database service, the resource limit configured for the user by the cluster, and the resource size of at least one target second node that meets the second preset condition are the smallest, the resource limit of the user itself will be modified to a preset value determined based on the resource size of the target second node that meets the second preset condition. If the database service is an import service, and the user's own resource limit exceeds the resource limit configured for the user by the cluster, and the load value of at least one target second node meets the third preset condition, then the user's own resource limit will be modified to a preset value determined based on the resource size of the second node with the largest load value among at least one target second node.
7. A device for selecting database service processing nodes in a cluster, characterized in that, include: The acquisition module is used to acquire load metrics that affect the load size of multiple nodes used to process database business. A clustering module is used to determine the correlation between load metrics of multiple nodes and reference values of multiple virtual nodes corresponding to each load metric; to determine the correlation between each node and each load type based on the correlation between at least some load metrics of each node and the reference values of multiple virtual nodes corresponding to at least some load metrics; wherein the type of the virtual node is the same as the load type; to determine the absolute load matrix of each node based on the correlation between each node and each load type and the weight corresponding to each load type; and to perform fuzzy clustering on the absolute load matrices of multiple nodes to obtain multiple types of clusters; wherein the type of the cluster is determined according to the load type. The determination module is used to determine the load values of multiple nodes based on the preset load values corresponding to the types to which multiple clusters belong. The selection module is used to determine, from multiple nodes, a node that meets a first preset load value, and to assign the database service to the determined node so that the determined node can process the database service.
8. An electronic device, characterized in that, include: Memory is used to store computer programs or instructions; A processor is configured to execute a computer program or instructions in the memory, such that the cluster database service processing node selection method as described in any one of claims 1-6 is executed.
9. A computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor, the processor is able to perform the cluster database service processing node selection method as described in any one of claims 1-6.
Citation Information
Patent Citations
Task allocation method, device and equipment based on distributed cluster
CN119127415A
Node load-based dynamic data partitioning system
WO2021073083A1
