Load balancing method for database, storage medium and device
By creating multiple connection services in the database system and continuously sending load information using the load connection service, the server node with the lowest load rate is selected to handle connection requests, thus solving the problem of uneven database server load and improving response efficiency and task execution timeliness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CETC JINCANG (BEIJING) TECH CO LTD
- Filing Date
- 2023-01-17
- Publication Date
- 2026-04-17
AI Technical Summary
In existing database systems, the random allocation of task requests leads to significant differences in load rates among database servers, resulting in low response efficiency.
By creating multiple connection services to connect to multiple server nodes, and using load balancing connection services to continuously send load information, the server node with the lowest load rate is selected to handle connection requests.
It achieves uniformity of server node load, improves processing efficiency, ensures timely execution of important tasks, and simplifies the running process.
Smart Images

Figure CN116010527B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of database technology, and in particular to a database load balancing method, storage medium, and device. Background Technology
[0002] In existing database systems, multiple database servers are typically configured for load balancing to provide stable service. Specifically, load balancing distributes multiple task requests from clients across multiple database servers for execution, thereby improving response efficiency to some extent. Currently, databases implement load balancing through random allocation, meaning that when a new task request is received, it is randomly assigned to a database server for execution. While random allocation can distribute task requests, it can easily lead to significant differences in load rates among the database servers, resulting in slow task response times. Summary of the Invention
[0003] One object of the present invention is to provide a load balancing method, storage medium and device for database server connections that can solve any of the above problems.
[0004] A further objective of this invention is to simplify the operating procedure.
[0005] Another further objective of this invention is to ensure the timely execution of important tasks.
[0006] Specifically, the present invention provides a database load balancing method, comprising:
[0007] Create multiple connection services, which are used to connect to multiple server nodes, and each server node connects to multiple connection services;
[0008] Use the connection service to send a load notification start command to the server node to start the task of sending load information on the server node;
[0009] Receive and store load information;
[0010] Receive connection requests from clients;
[0011] Filter out the server nodes with the lowest load rates based on load information;
[0012] Returns the idle connection service of the server node with the lowest load rate to the connection request.
[0013] Optionally, the steps of sending a load notification start command to the server node using the connection service include:
[0014] Identify one of the multiple connection services for a server node as the load balancing connection service;
[0015] Use the load balancing connection service to send a load notification start command to the server node;
[0016] The steps for receiving and storing payload information include:
[0017] Continuously receive and store load information sent by the load connection service.
[0018] Optionally, the step of determining one of the multiple connection services of the server node as the load balancing connection service includes:
[0019] The connection service used for the initial connection of the server node is designated as the load balancing connection service.
[0020] Optionally, the step of returning an idle connection service from the server node with the lowest load rate to the connection request includes:
[0021] Determine if the server node has an idle connection service. If it does, execute the step of returning an idle connection service to the connection request; otherwise, return a load-bearing connection service to the connection request.
[0022] Optionally, the step of returning a load connection service to the connection request includes:
[0023] After the connection request task is completed, determine whether there are other idle connection services on the server node. If so, continue to use the returned load connection service to receive load information; otherwise, put the returned load connection service into an idle state.
[0024] Optionally, the step of putting the returned load connection service into an idle state includes:
[0025] Detect whether the server node has multiple idle connection services;
[0026] If a server node has multiple idle connection services, select one of them as the load balancer connection service.
[0027] Optionally, the load notification enable command includes a notification interval, and the step of continuously receiving and storing load information sent by the load connection service includes:
[0028] Continuously receive load information sent by the load connection service at regular intervals according to the notification interval.
[0029] Optionally, the load information includes the number of active sessions, the number of inactive sessions, CPU utilization, memory utilization, and I / O utilization of the server node. The step of filtering the server node with the lowest load rate based on the load information includes:
[0030] The load factor is calculated based on the sum of the number of active sessions, the number of inactive sessions, the first preset correction value, the CPU utilization rate, the second preset correction value, the memory utilization rate, the third preset correction value, and the I / O utilization rate, the fourth preset correction value.
[0031] In another aspect of the invention, a machine-readable storage medium is also provided, on which a machine-executable program is stored, which, when executed by a processor, implements a database load balancing method according to any of the preceding claims.
[0032] In another aspect of the invention, a computer device is also provided, including a memory, a processor, and a machine-executable program stored in the memory and running on the processor, wherein the processor, when executing the machine-executable program, implements a database load balancing method according to any of the preceding claims.
[0033] The database load balancing method of this invention creates multiple connection services and connects each server node to multiple connection services. After enabling load notification, it receives and stores the load information of the server nodes. Upon receiving a connection request from a client, it can filter out the server node with the lowest load rate based on the load information and then return an idle connection of the server node with the lowest load rate to the client. That is, after each new connection request is received, it can return an idle connection of the server node with the lowest load rate to the new connection request. Thus, it ensures that the server node with the lowest load rate executes the new task request. Therefore, it helps to avoid the problem of new tasks being randomly assigned to server nodes with high load rates, leading to a widening gap in load rates between different server nodes. Furthermore, it helps to improve the uniformity of server node load rates, making the load among server nodes more balanced, which is beneficial to improving the processing efficiency of server nodes.
[0034] Furthermore, the database load balancing method of the present invention determines a load connection service and, after determining the load connection service, continuously sends the load information of the server nodes using the load connection service. That is, the task of sending load information is always performed by the determined load connection service. Therefore, it effectively avoids the frequent switching of the connection service performing the task of sending load information, thereby helping to simplify the operation process.
[0035] Furthermore, the database load balancing method of this invention, when the server node with the lowest load rate has no idle service, stops the task of sending load information by the load connection service and returns an idle load connection service to the connection request, thereby enabling the connection request task to be executed. This is because the result of the connection request task is generally more urgent for the user than the task of sending load information. Moreover, since the server node with the lowest load rate also has no idle service, the sending of load information can be stopped for a short period. Therefore, executing the connection request task by making the load connection service idle helps ensure the timely execution of important tasks, thereby guaranteeing the user experience.
[0036] The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments of the invention in conjunction with the accompanying drawings. Attached Figure Description
[0037] The following sections will describe some specific embodiments of the invention in detail by way of example and not limitation, with reference to the accompanying drawings. The same reference numerals in the drawings denote the same or similar parts or portions. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:
[0038] Figure 1 This is a schematic flowchart of a database load balancing method according to an embodiment of the present invention;
[0039] Figure 2 This is a schematic diagram of a database system according to an embodiment of the present invention;
[0040] Figure 3 This is a schematic flowchart of a database load balancing method according to another embodiment of the present invention;
[0041] Figure 4 This is a schematic flowchart of a database load balancing method according to yet another embodiment of the present invention;
[0042] Figure 5 This is a schematic flowchart of a database load balancing method according to yet another embodiment of the present invention;
[0043] Figure 6 This is a schematic flowchart of a database load balancing method according to yet another embodiment of the present invention;
[0044] Figure 7 This is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention;
[0045] Figure 8 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation
[0046] Those skilled in the art should understand that the embodiments described below are merely a part of the embodiments of the present invention, and not all of the embodiments of the present invention. These partial embodiments are intended to explain the technical principles of the present invention and are not intended to limit the scope of protection of the present invention. Based on the embodiments provided by the present invention, all other embodiments obtained by those skilled in the art without creative effort should still fall within the scope of protection of the present invention.
[0047] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-included system or other system that can fetch and execute instructions from, an instruction execution system, apparatus or device).
[0048] like Figure 1 As shown, in one embodiment, the database load balancing method generally includes:
[0049] Step S101: Create multiple connection services. These multiple connection services are used to connect to multiple server nodes, and each server node connects to multiple connection services.
[0050] Reference Figure 2 As shown, the database system in this embodiment includes a client 10, a connection pool 20, and multiple server nodes 30. The connection pool 20, as the name suggests, can be viewed as a pool with multiple pre-established connection services 21. When a connection request 11 is received from the client 10, a connection service 21 can be retrieved from the connection pool 20 to connect to the server node 30. After the task is completed, the connection service 21 is returned to the connection pool 20 for reuse, thereby saving system resources.
[0051] Therefore, this step can also be described as creating a connection pool, which contains multiple connection services. Furthermore, each server node in the database system has corresponding multiple connection services. In other words, each server node pre-establishes connections with multiple connection services.
[0052] Step S102: A load notification enable command is sent to the server node using the connection service to start the task of sending load information on the server node. Specifically, for each server node, a load notification enable command is sent to the server node through a connection service to enable load notification.
[0053] Step S103: Receive and store load information. Specifically, after enabling load notification, the server node sends its current load information to the connection service that sends the load notification start command. The load information refers to parameters that reflect the server node's load level. Examples include the number of active sessions (i.e., the number of connection services in use), the number of inactive sessions (i.e., the number of idle connection services), CPU utilization, memory utilization, and input / output utilization (i.e., IO utilization).
[0054] Step S104: Receive a connection request from the client. Specifically, the client requests a connection service from the connection pool to send a task request to the server node through the connection service to execute the task.
[0055] Step S105: Select the server node with the lowest load rate based on the load information. Specifically, select the server node with the lowest load rate from multiple server nodes based on the load information of each server node.
[0056] In one implementation, the load factor is calculated based on the sum of the number of active sessions, the number of inactive sessions, a first preset parameter, CPU utilization, a second preset parameter, memory utilization, a third preset parameter, and I / O utilization, a fourth preset parameter. The first preset parameter can be 0.3, the second preset parameter can be 0.3, the third preset parameter can be 0.2, and the fourth preset parameter can be 0.1.
[0057] For example, a server node has 16 active sessions, 5 inactive sessions, a CPU utilization of 25%, a memory utilization of 14%, and an I / O utilization of 15%. Therefore, the load factor = 16 + 5 * 0.3 + 25 * 0.3 + 14 * 0.2 + 15 * 0.1, and the final load factor is recorded as 29.
[0058] Step S106: Return an idle connection service from the server node with the lowest load rate to the connection request. Specifically, the server node with the lowest load rate experiences the least execution pressure. Therefore, after selecting the server node with the lowest load rate from multiple server nodes, return an idle connection from the server node with the lowest load rate to the client to process the task.
[0059] In this embodiment, multiple connection services are created, and each server node connects to multiple connection services. After load notification is enabled, the load information of the storage server nodes is received and stored. Upon receiving a connection request from a client, the server node with the lowest load rate can be selected based on the load information, and then an idle connection of the server node with the lowest load rate is returned to the client. In other words, each time a new connection request is received, an idle connection of the server node with the lowest load rate can be returned to the new connection request. Thus, it is ensured that the server node with the lowest load rate executes the new task request.
[0060] Therefore, this helps avoid the problem of new tasks being randomly assigned to server nodes with high load rates, leading to a widening gap in load rates between different server nodes. Furthermore, it helps improve the uniformity of server node load rates, resulting in a more balanced load across server nodes and ultimately improving server node processing efficiency.
[0061] like Figure 3 As shown, in one embodiment, the step of sending a load notification start command to a server node using a connection service includes: determining one of a plurality of connection services of the server node as the load connection service; and sending a load notification start command to the server node using the load connection service. The step of receiving and storing load information includes: continuously receiving and storing load information sent by the load connection service. Database load balancing methods generally include:
[0062] Step S301: Create multiple connection services.
[0063] Step S302: Determine one of the multiple connection services of the server node as the load connection service.
[0064] Step S303: Use the load connection service to send a load notification start command to the server node.
[0065] Step S304: Continuously receive and store load information sent by the load connection service.
[0066] Specifically, a server node corresponds to multiple connection services. One of these connection services is selected as the load balancing connection service. Then, the selected load balancing connection service continuously performs the task of transmitting load information, enabling the driver to continuously receive load information sent by the load balancing connection service.
[0067] Furthermore, the connection service used for the initial connection of the server node is designated as the load balancing connection service. In other words, for each server node, the initial step is to enable load notification. That is, the first task of each server node is to send load information. During the subsequent operation of the database, load information is continuously sent by the load balancing connection service.
[0068] Step S305: Receive the client's connection request.
[0069] Step S306: Filter out the server node with the lowest load rate based on the load information.
[0070] Step S307: Return the idle connection service of the server node with the lowest load rate to the connection request.
[0071] In this embodiment, a load balancing connection service is determined, and once determined, it continuously sends the load information of the server nodes. In other words, the task of sending load information is always performed by the determined load balancing connection service. Therefore, the frequent switching of the connection service performing the task of sending load information is effectively avoided, thus simplifying the program operation.
[0072] Furthermore, in one embodiment, the load notification enable command includes a notification interval, and the step of continuously receiving and storing load information sent by the load connection service includes: continuously receiving load information sent by the load connection service at regular intervals according to the notification interval.
[0073] Specifically, when enabling load notification via the load notification enable command, the notification interval for sending load information can be set. This allows server nodes to send load information periodically according to the pre-defined intervals, eliminating the need to frequently send load notification enable commands to server nodes to request load information.
[0074] It should be noted that in some other embodiments of this application, load information can also be requested by periodically sending a load notification start command using an idle connection service. In other words, the task of sending load information can be accomplished through any idle connection service of the server node.
[0075] like Figure 4 As shown, in one embodiment, the database load balancing method generally includes:
[0076] Step S401: Create multiple connection services.
[0077] Step S402: Determine one of the multiple connection services of the server node as the load connection service.
[0078] Step S403: Use the load connection service to send a load notification start command to the server node.
[0079] Step S404: Continuously receive and store load information sent by the load connection service.
[0080] Step S405: Receive connection request from client.
[0081] Step S406: Filter out the server node with the lowest load rate based on the load information.
[0082] Step S407: Determine if the server node has an idle connection service. If yes, proceed to step S408; otherwise, proceed to step S409. Specifically, because the load balancing connection service is constantly performing the task of sending load information, it is not an idle connection service. Therefore, it can also be said that, excluding the load balancing connection service, are there any idle connection services among the remaining connection services of the server node?
[0083] Step S408: Return an idle connection service to the connection request. Specifically, if the server node still has idle connection services, then an idle connection service is normally returned to perform the task of the connection request.
[0084] Step S409: Return a load balancer connection service to the connection request. Specifically, if the server node does not have an idle connection service, then stop the task of sending load information by the load balancer connection service. Then, return an idle load balancer connection service to the connection request and use the load balancer connection service to execute the task of the connection request.
[0085] In this embodiment, when the server node with the lowest load rate has no idle service, the load balancing service stops sending load information and returns an idle load balancing service to the connection request, thus allowing the connection request task to be executed. This is because the result of the connection request task is generally more urgent for the user than the task of sending load information. Furthermore, since the server node with the lowest load rate also has no idle service—meaning all server nodes are at full load—sending load information can be stopped within a short period. Therefore, executing the connection request task by making the load balancing service idle helps ensure the timely execution of important tasks, thereby guaranteeing the user experience.
[0086] It should be noted that in some other embodiments of this application, the load connection service can also be fixed to perform the task of sending load information. That is, only the other connection services of the server node besides the load connection service are used to perform the task of connection request.
[0087] like Figure 5 As shown, in one embodiment, after the step of returning the load connection service to the connection request, the method includes: after the task execution of the connection request is completed, determining whether there are other idle connections on the server node; if so, continuing to use the returned load connection service to receive load information; if not, putting the returned load connection service into an idle state.
[0088] Specifically, in this embodiment, the database load balancing method generally includes:
[0089] Step S501: Return load connection service to the connection request.
[0090] Step S502: After the connection request task is completed, determine whether the server node has other idle connections. If yes, proceed to step S503; otherwise, proceed to step S504. Specifically, after the load balancing connection service completes the connection request task, it is returned to the connection pool and becomes an idle connection service. In other words, determine whether the server node has other idle connection services besides the idle load balancing connection service. Or, in other words, whether the server node has more than one idle connection service, including the load balancing connection service.
[0091] Step S503: Continue to use the returned load connection service to receive load information. Specifically, if the server node has multiple idle connection services, the returned load connection service is used again as the connection service to perform the task of sending load information. At this time, the load notification start command is sent to the server node again using the load connection service.
[0092] Step S504: Put the returned load balancing connection service into an idle state. Specifically, if the server node only has one idle connection service, the returned load balancing connection service, it is kept idle to facilitate its use in subsequent operations.
[0093] Continue to refer to Figure 5 As shown, after the returned load connection service is put into an idle state, the following steps are included:
[0094] Step S505: Detect whether the server node has multiple idle connection services. Specifically, it determines whether the server node has more than two idle connection services.
[0095] Step S506: If the server node has multiple idle connection services, select one of them as the new load balancing connection service. If the server node already has multiple idle connection services, select one of them as the new load balancing connection service to re-execute the task of continuously sending load information.
[0096] Because if multiple idle connection services exist on a server node, even if one connection service acts as a load balancer, the server node still has other connection services capable of executing subsequent connection requests. Therefore, one of these connection services can be selected as the load balancer to continuously perform the task of sending load information.
[0097] like Figure 6As shown, in one embodiment, the database system includes a client 10, a database driver 40, and a server node 30. The database driver 40 is the interface between the client 10 and the server node 30.
[0098] In this embodiment, the database load balancing method generally includes:
[0099] Step S601: Create a connection pool. This means creating multiple connection services.
[0100] Step S602: Send a load notification enable command to the server node using the connection service. Specifically, send a connection request to server node 30 to obtain a connection service. Send the load notification enable command using the connection service to enable load notification.
[0101] Furthermore, the connection service used for the initial connection with server node 30 is determined to be the load balancing connection service. This means that for each server node, the initial step is to enable load notification. In other words, the first task of each server node is to send load information. During the subsequent operation of the database, load information is continuously sent by the load balancing connection service.
[0102] Step S603: Receive and store load information. Specifically, receive and store the load information sent by server node 30 through the load connection service.
[0103] Step S604: Receive the client's connection request and return an idle connection to the client. Specifically, client 10 requests a connection from the connection pool. Database driver 40 calls a filter, which selects the server node with the lowest load rate from multiple server nodes based on the load information of each server node 30. An idle connection from the server node 30 with the lowest load rate is returned to client 10.
[0104] Additionally, the system checks if the server node has an idle connection service. If so, it returns an idle connection service to the connection request. Specifically, if the server node still has idle connection services, it normally returns an idle connection service to execute the connection request task. If not, it returns a load balancer connection service to the connection request. Specifically, if the server node does not have an idle connection service, it stops the task of sending load information using the load balancer connection service. Then, it returns an idle load balancer connection service to the connection request and uses the load balancer connection service to execute the connection request task.
[0105] Step S605: Execute the task. Specifically, after obtaining the connection service, client 10 establishes a connection with server node 30 through the connection service, enabling server node 30 to execute the task according to the task request of client 10.
[0106] Step S606: Return the connection. Specifically, after the task is completed, the connection service is returned to the connection pool.
[0107] If the task was not completed using the load balancing connection service, it is returned normally. If the task was completed using the load balancing connection service, then upon return, it is determined whether there are other idle connections on the server node. If so, the returned load balancing connection service continues to receive load information; otherwise, the returned load balancing connection service is placed in an idle state.
[0108] Step S607: Re-enable load notification. Specifically, if the request task is completed using the load connection service, then upon return, if the server node has other idle connections, the load connection service is re-enabled to re-enable load notification and the load information of server node 30 is sent again using the load connection service, i.e., load notification is re-enabled.
[0109] Additionally, when using a load balancer to complete a request task, the load balancer will be returned normally upon return if the server node has no other idle connections. Then, it checks whether the server node has multiple idle connection services. Specifically, it determines whether the server node has more than two idle connection services.
[0110] When a server node has multiple idle connection services, one of these idle connection services is selected as the load balancer connection service. Load notification is then enabled using the new load balancer connection service, effectively re-enabling load notification.
[0111] For example, the database system includes a client, server node A, server node B, and server node C. The connection pool contains connection services A1, A2, and A3 for server node A; connection services B1, B2, and B3; and connection services C1, C2, and C3. Connection services A1, A2, and A3 correspond to server node A. Connection services B1, B2, and B3 correspond to server node B. Connection services C1, C2, and C3 correspond to server node C.
[0112] First, a load notification enable command is sent to server node A using connection service A1, enabling load notification for server node A. Then, a load notification enable command is sent to server node B using connection service B1, enabling load notification for server node B. Finally, a load notification enable command is sent to server node C using connection service C1, enabling load notification for server node C. In other words, connection services A1, B1, and C1 constitute load balancing connection services.
[0113] Server node A periodically sends load information through connection service A1. Server node B periodically sends load information through connection service B1. Server node C periodically sends load information through connection service C1.
[0114] Then, upon receiving a connection request from a client, the load rates of server nodes A, B, and C are calculated. If server node A has the lowest load rate, connection service A2 is returned to the connection request.
[0115] When server nodes A, B, and C all have no idle connections, and a client connection request is received, the load rates of server nodes A, B, and C are calculated. Since server node A has the lowest load rate, the task of sending load information for connection service A1 is stopped, and connection service A1 is returned to the connection request.
[0116] After connection service A1 completes its task of executing the connection request, it returns the connection to the pool. At this time, connection services A2 and A3 have also completed their tasks. Therefore, server node A has other idle connections besides connection service A1. Connection service A1 then continues to act as a load balancer and restarts load notification.
[0117] When server nodes A, B, and C all have no idle connections, and a client connection request is received, the load rates of server nodes A, B, and C are calculated. Server node B has the lowest load rate, so the task of sending load information for connection service B1 is stopped, and connection service B1 is returned to the connection request.
[0118] After connection service B1 completes its task for the connection request, it returns the connection to the connection pool. At this time, the tasks of connection services B2 and B3 are still running. Therefore, server node B has no other idle connections besides connection service B1. Thus, connection service B1 is simply returning the connection to the pool, and subsequent connection requests can directly return connection service B1.
[0119] Then, it was detected that server node B had idle connection services B2 and B3. This means there were multiple idle connections. Therefore, connection service B2 was designated as the new load balancing connection service, and load balancing notifications were restarted.
[0120] In this embodiment, a connection pool (multiple connection services) is created, and each server node connects to multiple connection services. After load notification is enabled, load information from the server nodes is received. Upon receiving a connection request from a client, the server node with the lowest load rate can be selected based on the load information, and an idle connection from that server node is returned to the client. In other words, each time a new connection request is received, an idle connection from the server node with the lowest load rate is returned to the new connection request. This ensures that the server node with the lowest load rate executes the new task request.
[0121] Therefore, this helps avoid the problem of new tasks being randomly assigned to server nodes with high load rates, leading to a widening gap in load rates between different server nodes. Furthermore, it helps improve the uniformity of server node load rates, resulting in a more balanced load across server nodes and ultimately improving server node processing efficiency.
[0122] Furthermore, when the server node with the lowest load rate has no idle service, the load balancing service stops sending load information and returns an idle load balancing service to the connection request, thus allowing the connection request task to be executed. This is because the result of the connection request task is generally more urgent for the user than the task of sending load information. Moreover, since the server node with the lowest load rate also has no idle service—meaning all server nodes are at full load—sending load information can be stopped within a short period. Therefore, executing the connection request task by making the load balancing service idle helps ensure the timely execution of important tasks, thereby guaranteeing a better user experience.
[0123] like Figure 7 and Figure 8 As shown, this embodiment also provides a machine-readable storage medium 100 and a computer device 200. The machine-readable storage medium 100 stores a machine-executable program 110 thereon, which, when executed by a processor, implements the database load balancing method of any of the above embodiments.
[0124] Computer device 200 may include memory 210, processor 220 and machine-executable program 110 stored on memory 210 and running on processor 220, and processor 220 implements the database load balancing method of any of the above embodiments when executing machine-executable program 110.
[0125] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any machine-readable storage medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-based system or other system that can fetch and execute instructions from, an instruction execution system, apparatus or device).
[0126] Therefore, those skilled in the art should recognize that although numerous exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications conforming to the principles of the present invention can be directly determined or derived from the disclosure of the present invention without departing from the spirit and scope of the invention. Thus, the scope of the present invention should be understood and construed as covering all such other variations or modifications.
Claims
1. A database load balancing method, comprising: Multiple connection services are created, which are used to connect to multiple server nodes, and each server node connects to multiple connection services; The connection service is used to send a load notification start command to the server node to start the task of sending load information on the server node. Receive and store the load information; Receive connection requests from clients; The server node with the lowest load rate is selected based on the load information; The connection request returns an idle connection service for the server node with the lowest load rate. The step of sending a load notification start command to the server node using the connection service includes: One of the multiple connection services of the server node is selected as the load balancing connection service; The load connection service is used to send a load notification start command to the server node; The step of receiving and storing the load information includes: Continuously receive and store the load information sent by the load connection service; Prior to the step of returning an idle connection service to the server node with the lowest load rate in the connection request, the following steps are included: Determine whether the server node has an idle connection service. If yes, execute the step of returning the idle connection service to the connection request; otherwise, return the load connection service to the connection request.
2. The database load balancing method of claim 1, wherein, The step of determining one of the multiple connection services of the server node as the load balancing connection service includes: The connection service used for the initial connection of the server node is used as the load connection service.
3. The database load balancing method according to claim 1, wherein, The step of returning the load connection service to the connection request includes: After the task of the connection request is completed, it is determined whether there are other idle connection services on the server node. If so, the returned load connection service is used to continue receiving load information. If not, the returned load connection service is put into an idle state.
4. The database load balancing method according to claim 3, wherein, The step of putting the returned load connection service into an idle state includes: Detect whether the server node has multiple idle connection services; If the server node has multiple idle connection services, one of the multiple idle connection services is selected as the load balancing connection service.
5. The database load balancing method according to claim 1, wherein, The load notification enable command includes a notification interval, and the step of continuously receiving and storing the load information sent by the load connection service includes: Continuously receive load information sent periodically by the load connection service according to the notification interval.
6. The database load balancing method according to claim 1, wherein, The load information includes the number of active sessions, the number of inactive sessions, CPU utilization, memory utilization, and I / O utilization of the server node. The step of filtering the server node with the lowest load rate based on the load information includes: The load rate is calculated based on the sum of the number of active sessions, the number of inactive sessions, the first preset correction value, the CPU utilization rate, the second preset correction value, the memory utilization rate, the third preset correction value, and the I / O utilization rate, the fourth preset correction value.
7. A machine-readable storage medium having a machine-executable program stored thereon, the machine-executable program, when executed by a processor, implementing the database load balancing method according to any one of claims 1 to 6.
8. A computer device comprising a memory, a processor, and a machine-executable program stored in the memory and running on the processor, wherein the processor, when executing the machine-executable program, implements a database load balancing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Routing method, load balancing device and data communication system
CN105471760A