CN116010527A - Load balancing method, storage medium and equipment for database - Google Patents
Load balancing method, storage medium and equipment for database Download PDFInfo
- Publication number
- CN116010527A CN116010527A CN202310083208.3A CN202310083208A CN116010527A CN 116010527 A CN116010527 A CN 116010527A CN 202310083208 A CN202310083208 A CN 202310083208A CN 116010527 A CN116010527 A CN 116010527A
- Authority
- CN
- China
- Prior art keywords
- load
- connection
- server node
- connection service
- idle
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 42
- 238000012216 screening Methods 0.000 claims abstract description 5
- 238000012937 correction Methods 0.000 claims description 8
- 238000010586 diagram Methods 0.000 description 8
- 230000005540 biological transmission Effects 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000004044 response Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 1
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/50—Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate
Landscapes
- Computer And Data Communications (AREA)
Abstract
The invention provides a load balancing method, a storage medium and equipment of a database. The load balancing method of the database comprises the following steps: creating a plurality of connection services for connecting with a plurality of server nodes, and each server node connecting with the plurality of connection services; transmitting a load notification starting command to the server node by using the connection service so as to start a task of transmitting load information at the server node; receiving and storing load information; receiving a connection request of a client; screening out the server node with the lowest load rate according to the load information; and returning the idle connection service of the server node with the lowest load rate to the connection request. After 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. Therefore, the server node with the lowest load rate is guaranteed to execute the new task request, and uniformity of the load rate of the server node is improved.
Description
Technical Field
The present invention relates to the field of database technologies, and in particular, to a method, a storage medium, and an apparatus for load balancing a database.
Background
In existing database systems, a plurality of database servers are typically configured to perform load balancing to provide a stable service to the outside. Specifically, load balancing is to split a plurality of task requests from clients to a plurality of database servers for execution, so that response efficiency is improved to a certain extent. Currently, the load balancing mode of the database is random allocation, that is, in the case of receiving a new task request, the new task request is randomly allocated to a database server for execution. Because of the random allocation, the task requests can be shared, but the problem of slow response of the task requests is easily caused by the large load factor gap between database servers.
Disclosure of Invention
It is an object of the present invention to provide a load balancing method, a storage medium and a device for database server connection that can solve any of the above problems.
A further object of the invention is to simplify the running process.
It is a further object of the present invention to ensure timely execution of important tasks.
In particular, the invention provides a load balancing method of a database, comprising the following steps:
creating a plurality of connection services for connecting with a plurality of server nodes, and each server node connecting with the plurality of connection services;
transmitting a load notification starting command to the server node by using the connection service so as to start a task of transmitting load information at the server node;
receiving and storing load information;
receiving a connection request of a client;
screening out the server node with the lowest load rate according to the load information;
and returning the idle connection service of the server node with the lowest load rate to the connection request.
Optionally, the step of sending the load notification on command to the server node using the connection service comprises:
determining one of a plurality of connection services of a server node as a load connection service;
transmitting a load notification start command to the server node by using the load connection service;
the step of receiving and storing load information includes:
and continuously receiving and storing the load information sent by the load connection service.
Optionally, the step of determining one of the plurality of connection services of the server node as a load connection service comprises:
and taking the connection service adopted by the first connection of the server node as a load connection service.
Optionally, before the step of returning the idle connection service of the server node with the lowest load rate to the connection request, the method includes:
and judging whether the server node has idle connection service, if so, executing the step of returning the idle connection service to the connection request, and if not, returning the load connection service to the connection request.
Optionally, the step of returning the load connection service to the connection request includes:
after the task execution of the connection request is completed, judging whether other idle connection services exist in the server node, if so, continuously receiving load information by using the returned load connection service, and if not, enabling the returned load connection service to be in an idle state.
Optionally, the step of placing the restored load connection service in an idle state includes:
detecting whether a plurality of idle connection services exist in the server node;
and if the server node has a plurality of idle connection services, selecting one of the plurality of idle connection services as a load connection service.
Optionally, the load notification on command includes a notification interval, and the step of continuously receiving and storing the load information sent by the load connection service includes:
the continuous reception load connection service periodically transmits load information at notification intervals.
Optionally, the load information includes the number of active sessions, the number of inactive sessions, the CPU usage, the memory usage, and the input/output usage of the server node, and the step of screening the server node with the lowest load rate according to the load information includes:
calculating a load rate according to the number of active sessions, the number of inactive sessions, the first preset correction value, the second preset correction value, the memory usage rate, the third preset correction value, the input and output usage rate and the fourth preset correction value.
In another aspect of the invention, there is also provided a machine-readable storage medium having stored thereon a machine-executable program which when executed by a processor implements a method of load balancing a database according to any of the above.
In yet another aspect of the present invention, there is also provided a computer device comprising a memory, a processor and a machine executable program stored on the memory and running on the processor, and the processor implementing a load balancing method for a database according to any one of the above when executing the machine executable program.
The load balancing method of the database of the invention enables each server node to connect a plurality of connection services by creating a plurality of connection services. And after the load notification is started, receiving and storing load information of the server node. After receiving the connection request of the client, the server node with the lowest load rate can be screened out according to the load information, and then the idle connection of the server node with the lowest load rate is returned to the client. That is, after 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, the server node with the lowest load rate is guaranteed to perform the new task request. Therefore, the method helps to avoid the problem that new tasks are separated to server nodes with higher load rates under the random distribution condition, so that the load rate difference distance between different server nodes is larger and larger. Furthermore, uniformity of the load rate of the server nodes is improved, load among the server nodes is balanced, and processing efficiency of the server nodes is improved.
Further, the load balancing method of the database of the invention continuously transmits the load information of the server node by using the load connection service after determining the load connection service by determining the load connection service. That is, the task of transmitting load information is always completed by the well-defined load connection service. Therefore, the situation of frequently replacing the connection service performing the task of transmitting the load information is effectively avoided, thereby contributing to simplifying the operation procedure.
Furthermore, the load balancing method of the database of the invention stops the task of the load connection service for sending the load information and returns the idle load connection service to the connection request under the condition that the server node with the lowest load rate does not have idle service, thereby executing the task of the connection request. Because the task of the connection request is generally more demanding for the user than the task of sending the load information. Further, since the server node with the lowest load rate does not have any idle service, the transmission of the load information can be stopped in a short time. Therefore, the task of the connection request is executed by changing the load connection service into the idle state, so that timely execution of important tasks is guaranteed, and the use experience of a user is guaranteed.
The above, as well as additional objectives, advantages, and features of the present invention will become apparent to those skilled in the art from the following detailed description of a specific embodiment of the present invention when read in conjunction with the accompanying drawings.
Drawings
Some specific embodiments of the invention will be described in detail hereinafter by way of example and not by way of limitation with reference to the accompanying drawings. The same reference numbers will be used throughout the drawings to refer to the same or like parts or portions. It will be appreciated by those skilled in the art that the drawings are not necessarily drawn to scale. In the accompanying drawings:
FIG. 1 is a schematic flow chart diagram of a method of load balancing of a database according to one embodiment of the invention;
FIG. 2 is a schematic diagram of a database system according to one embodiment of the invention;
FIG. 3 is a schematic flow chart of a method of load balancing of a database according to another embodiment of the invention;
FIG. 4 is a schematic flow chart diagram of a method of load balancing of a database according to yet another embodiment of the invention;
FIG. 5 is a schematic flow chart diagram of a method of load balancing of a database in accordance with yet another embodiment of the invention;
FIG. 6 is a schematic flow chart diagram of a method of load balancing of a database in accordance with yet another embodiment of the invention;
FIG. 7 is a schematic diagram of a machine-readable storage medium according to one embodiment of the invention;
FIG. 8 is a schematic diagram of a computer device according to one embodiment of the invention.
Detailed Description
It should be understood by those skilled in the art that the embodiments described below are only some embodiments of the present invention, but not all embodiments of the present invention, and the some embodiments are intended to explain the technical principles of the present invention and are not intended to limit the scope of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive effort, based on the embodiments provided by the present invention, shall still fall within the scope of protection of the present invention.
It should be noted that the logic and/or steps represented in the flowcharts or otherwise described herein, for example, may be considered as a ordered listing of executable instructions for implementing logical functions, and may be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions.
As shown in fig. 1, in one embodiment, a method of load balancing a database generally includes:
step S101, a plurality of connection services are created. The plurality of connection services are for connecting with the plurality of server nodes, and each server node connects with the plurality of connection services.
Referring to fig. 2, the database system of the present embodiment includes a client 10, a connection pool 20, and a plurality of server nodes 30. The connection pool 20, as the name implies, can be considered as a pool with a plurality of connection services 21 pre-established. When receiving the connection request 11 of the client 10, a connection service 21 can be taken out from the connection pool 20 to connect with the server node 30, and after the task is executed, the connection service 21 is put back into the connection pool 20 for multiplexing, so as to save system resources.
Therefore, in this step, it can also be said that a connection pool is created, in which a plurality of connection services are provided. And each server node of the database system has a corresponding plurality of connection services. That is, each server node establishes connections with a plurality of connection services in advance.
Step S102, a load notification starting command is sent to the server node by using the connection service so as to start a task of sending load information at the server node. Specifically, for each server node, a load notification on command is sent to the server node through one connection service of the server node, thereby turning on the load notification.
Step S103, receiving and storing the load information. Specifically, after the load notification is started, the server node sends out current load information through a connection service sending a load notification starting command. The load information can embody the related parameters of the load size of the server node. For example, the number of active sessions (i.e., the number of connection services in use), the number of inactive sessions (i.e., the number of connection services in idle), CPU usage, memory usage, and Input/Output usage (i.e., IO usage), etc.
Step S104, receiving a connection request of the client. Specifically, the client requests to acquire a connection service in the connection pool to perform a task by sending a task request to the server node through the connection service.
Step S105, the server node with the lowest load rate is screened out according to the load information. Specifically, the server node with the lowest load rate is selected from the plurality of server nodes according to the load information of each server node.
In one embodiment, the load factor is calculated according to the number of active sessions+the number of inactive sessions+the first preset parameter+the CPU utilization+the second preset parameter+the memory utilization+the third preset parameter+the input/output utilization+the fourth preset parameter. The first preset parameter may be 0.3, the second preset parameter may be 0.3, the third preset parameter may be 0.2, and the fourth preset parameter may be 0.1.
Illustratively, one server node has an active session number of 16, an inactive session number of 5, a cpu usage rate of 25 (%), a memory usage rate of 14 (%), and an input-output usage rate of 15 (%). The load factor=16+5×0.3+25×0.3+14×0.2+15×0.1, and the final load factor is 29.
And step S106, returning the idle connection service of the server node with the lowest load rate to the connection request. Specifically, the execution pressure of the server node with the lowest load rate is the smallest. Therefore, after the server node with the lowest load rate is selected from the plurality of server nodes, one idle connection of the server node with the lowest load rate is returned to the client, so that the task is processed.
In the solution of the present embodiment, by creating a plurality of connection services, and making each server node connect the plurality of connection services. And after the load notification is started, receiving and storing load information of the server node. After receiving the connection request of the client, the server node with the lowest load rate can be screened out according to the load information, and then the idle connection of the server node with the lowest load rate is returned to the client. That is, after 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, the server node with the lowest load rate is guaranteed to perform the new task request.
Therefore, the method helps to avoid the problem that new tasks are separated to server nodes with higher load rates under the random distribution condition, so that the load rate difference distance between different server nodes is larger and larger. Furthermore, uniformity of the load rate of the server nodes is improved, load among the server nodes is balanced, and processing efficiency of the server nodes is improved.
As shown in fig. 3, in one embodiment, the step of sending a load notification on command to a server node using a connection service includes: determining one of a plurality of connection services of a server node as a load connection service; and sending a load notification starting command to the server node by using the load connection service. The step of receiving and storing load information includes: and continuously receiving and storing the load information sent by the load connection service. The load balancing method of the database generally comprises the following steps:
step S301, a plurality of connection services are created.
In step S302, one of a plurality of connection services of the server node is determined as a load connection service.
Step S303, a load notification on command is sent to the server node using the load connection service.
Step S304, load information sent by the load connection service is continuously received and stored.
Specifically, one server node corresponds to a plurality of connection services, and one of the plurality of connection services is selected as a load connection service. Then, the determined load connection service is used for completing the task of transmitting the load information, so that the driver continuously receives the load information sent by the load connection service.
Further, a connection service adopted by the first connection of the server node is taken as a load connection service. That is, for each server node, a load notification is initially turned on. That is, the first task of each server node is to send load information. The load information is always sent by the load connection service during the subsequent operation of the database.
In step S305, a connection request of the client is received.
Step S306, the server node with the lowest load rate is screened out according to the load information.
Step S307, returns the idle connection service of the server node with the lowest load rate to the connection request.
In the solution of this embodiment, by determining a load connection service, after determining the load connection service, load information of the server node is continuously transmitted by using the load connection service. That is, the task of transmitting load information is always completed by the well-defined load connection service. Therefore, the situation of frequently replacing the connection service performing the task of transmitting the load information is effectively avoided, thereby contributing to simplifying the operation procedure.
Further, in one embodiment, the load notification on command includes a notification interval, and the step of continuously receiving and storing load information transmitted by the load connection service includes: the continuous reception load connection service periodically transmits load information at notification intervals.
Specifically, the load notification command can set a notification interval for transmitting load information while the load notification is turned on by the load notification on command. Thus, the server node is enabled to send the load information at regular intervals according to the set notification intervals, and further, the load notification start command is not required to be sent to the server node frequently to request the load information.
In other embodiments of the present application, the load information may be requested by periodically sending a load notification on command using the idle connection service. That is, the task of sending load information is accomplished through any of the idle connection services of the server node.
As shown in fig. 4, in one embodiment, the load balancing method of the database generally includes:
in step S401, a plurality of connection services are created.
Step S402, one of a plurality of connection services of the server node is determined as a load connection service.
Step S403, a load notification on command is sent to the server node using the load connection service.
Step S404, load information sent by the load connection service is continuously received and stored.
Step S405, a connection request of a client is received.
Step S406, the server node with the lowest load rate is screened out according to the load information.
Step S407, determining whether the server node has an idle connection service, if so, executing step S408, and if not, executing step S409. In particular, since the load connection service is always performing a task of transmitting load information, it is not an idle connection service. Therefore, it can be said that the load connection service is removed, and whether or not an idle connection service exists among the remaining connection services of the server node.
Step S408, an idle connection service is returned to the connection request. Specifically, if the server node also has an idle connection service, then one idle connection service is normally returned for performing the task of the connection request.
Step S409, load connection service is returned to the connection request. Specifically, if the server node does not have an idle connection service, the task of the load connection service to send load information is stopped. And then returning the idle load connection service to the connection request, and executing the task of the connection request by using the load connection service.
In the solution of this embodiment, when the server node with the lowest load rate does not have an idle service, the task of the load connection service for sending load information is stopped and the idle load connection service is returned to the connection request, so that the task of the connection request is executed. Because the task of the connection request is generally more demanding for the user than the task of sending the load information. Moreover, since the server node with the lowest load rate does not have any idle service, that is, all server nodes are in a full-load state, transmission of load information can be stopped in a short time. Therefore, the task of the connection request is executed by changing the load connection service into the idle state, so that timely execution of important tasks is guaranteed, and the use experience of a user is guaranteed.
It should be noted that, in other embodiments of the present application, the load connection service may be made to perform the task of sending the load information fixedly, that is, only the connection service of the server node other than the load connection service is used to perform the task of the connection request.
As shown in fig. 5, in one embodiment, the step of returning the load connection service to the connection request includes, after: after the task execution of the connection request is completed, judging whether other idle connection exists in the server node, if so, continuously receiving load information by using the returned load connection service, and if not, enabling the returned load connection service to be in an idle state.
Specifically, in this embodiment, the load balancing method of the database generally includes:
step S501, a load connection service is returned to the connection request.
Step S502, after the task execution of the connection request is completed, it is determined whether there is another idle connection in the server node, if yes, step S503 is executed, and if not, step S504 is executed. Specifically, after the load connection service completes the task execution of the connection request, the task is put back into the connection pool, and then becomes the idle connection service. That is, it is determined whether or not the server node has other idle connection services in addition to the load connection service in the idle state. In other words, whether the server node includes more than two idle connection services including a load connection service.
In step S503, the load information is received by the returned load connection service. Specifically, in the case where the server node has a plurality of idle connection services, the returned load connection service is again taken as the connection service that performs the task of transmitting load information. At this time, the load notification on command is sent to the server node by reusing the load connection service.
Step S504, the returned load connection service is put in an idle state. Specifically, in the case that the server node has only one idle connection service, i.e., the returned load connection service is kept in an idle state, so that the server node is convenient to use in a subsequent operation process.
With continued reference to fig. 5, after placing the restored load connection service in an idle state, it includes:
in step S505, it is detected whether or not there are a plurality of idle connection services for the server node. Specifically, it is determined whether or not there are more than two idle connection services for the server node.
In step S506, if the server node has a plurality of idle connection services, one of the plurality of idle connection services is selected as a new load connection service. In case that the server node already has a plurality of idle connection services, one connection service is selected as a new load connection service to re-perform the task of continuously transmitting load information.
Since in the case where there are a plurality of idle connection services in the server node, even if there is one connection service as a load connection service, the server node also has a connection service capable of executing a subsequent connection request. Therefore, one connection service can be selected as the load connection service to continue the task of transmitting load information.
As shown in fig. 6, in one embodiment, the database system includes a client 10, a database driver 40, and a server node 30. Database driver 40 is the interface between client 10 and server node 30.
In this embodiment, the load balancing method of the database generally includes:
step S601, a connection pool is created. I.e. create a plurality of connection services.
Step S602, a load notification on command is sent to the server node by using a connection service. Specifically, a connection request is issued to the server node 30 to acquire one connection service. A load notification on command is sent with the connection service to turn on the load notification.
Further, the connection service employed for the first connection with the server node 30 is determined as the load connection service. That is, for each server node, a load notification is initially turned on. That is, the first task of each server node is to send load information. The load information is always sent by the load connection service during the subsequent operation of the database.
Step S603, receiving and storing load information. Specifically, the load information transmitted by the server node 30 through the load connection service is received and stored.
Step S604, receiving the connection request of the client and returning the idle connection to the client. Specifically, the client 10 requests to acquire a connection in the connection pool, and the database driver 40 invokes a filter that selects a server node with the lowest load rate from the plurality of server nodes according to the load information of each server node 30. One idle connection of the server node 30 with the lowest load rate is returned to the client 10.
In addition, whether the server node has idle connection service is judged, if yes, the idle connection service is returned to the connection request. Specifically, if the server node also has an idle connection service, then one idle connection service is normally returned for performing the task of the connection request. If not, returning the load connection service to the connection request. Specifically, if the server node does not have an idle connection service, the task of the load connection service to send load information is stopped. And then returning the idle load connection service to the connection request, and executing the task of the connection request by using the load connection service.
Step S605, execute the task. Specifically, after the client 10 obtains the connection service, a connection is established between the connection service and the server node 30, so that the server node 30 performs a task according to the task request of the client 10.
Step S606, the connection is restored. Specifically, after the task execution is completed, the connection service is restored to the connection pool.
Wherein if it is not a task completed with the load connection service, the return is normal. If the task is completed by using the load connection service, judging whether other idle connection exists in the server node during returning, if so, continuously receiving load information by using the returned load connection service, and if not, enabling the returned load connection service to be in an idle state.
In step S607, the load notification is restarted. Specifically, in the case where the request task is completed with the load connection service, at the time of return, if there is another idle connection to the server node, the load notification is turned on with the load connection service again and the load information of the server node 30 is transmitted with the load connection service continuously, that is, the load notification is turned on again.
In addition, in the case of completing a request task with the load connection service, then at the time of return, if there is no other idle connection at the server node, the load connection service is returned normally. Then, it is detected whether a plurality of idle connection services exist at the server node. Specifically, it is determined whether or not there are more than two idle connection services for the server node.
When the server node has a plurality of idle connection services, one of the plurality of idle connection services is selected to be used as the load connection service again. And turns on the load notification, i.e., re-turns on the load notification, with the new load connection service.
Illustratively, the database system includes a client, a server node a, a server node B, and a server node C. The connection pool is provided with a server node A which is provided with a connection service A1, a connection service A2 and a connection service A3; connection service B1, connection service B2, and connection service B3; connection service C1, connection service C2, and connection service C3. Connection service A1, connection service A2, and connection service A3 correspond to server node a. Connection service B1, connection service B2, and connection service B3 correspond to server node B. Connection service C1, connection service C2, and connection service C3 correspond to server node C.
First, a load notification start command is transmitted to the server node a by the connection service A1, and the load notification of the server node a is started. And sending a load notification starting command to the server node B by using the connection service B1, and starting the load notification of the server node B. And sending a load notification starting command to the server node C by using the connection service C1, and starting the load notification of the server node C. Namely, the connection service A1, the connection service B1, and the connection service C1 are load connection services.
The server node a periodically transmits load information through the connection service A1. The server node B periodically transmits load information through the connection service B1. The server node C periodically transmits load information through the connection service C1.
Then, the connection request of the client is received, and the load rates of the server node A, the server node B and the server node C are calculated. And if the server node A has the lowest load rate, returning the connection service A2 to the connection request.
When there is no idle connection service in any of server node a, server node B and server node C. And receiving a connection request of the client, and calculating the load rates of the server node A, the server node B and the server node C. The lowest load rate of the server node A is obtained, the task of sending load information of the connection service A1 is stopped, and the connection service A1 is returned to the connection request.
After the connection service A1 performs the task of the connection request, the connection pool is restored. At this time, the tasks of the connection service A2 and the connection service A3 have also been performed. Therefore, the server node a has other idle connections in addition to the connection service A1. Then the connection service A1 continues to act as a load connection service, restarting the load notification.
When there is no idle connection service in any of server node a, server node B and server node C. And receiving a connection request of the client, and calculating the load rates of the server node A, the server node B and the server node C. The lowest load rate of the server node B is obtained, the task of sending load information of the connection service B1 is stopped, and the connection service B1 is returned to the connection request.
After the connection service B1 performs the task of the connection request, the connection pool is restored. At this time, the tasks of the connection service B2 and the connection service B3 are still being performed. Therefore, the server node B has no other idle connection than the connection service B1. Then connection service B1 simply returns the connection pool and subsequently may return connection service B1 directly to the connection request.
Then, the presence of the idle connection service B2 and the connection service B3 by the server node B is detected. I.e. there are a plurality of idle connections. Connection service B2 is restarted with the load notification as a new load connection service.
In the solution of the present embodiment, by creating a connection pool, that is, a plurality of connection services, and making each server node connect the plurality of connection services. And after the load notification is started, receiving load information of the server node. After receiving the connection request of the client, the server node with the lowest load rate can be screened out according to the load information, and then the idle connection of the server node with the lowest load rate is returned to the client. That is, 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, the server node with the lowest load rate is guaranteed to perform the new task request.
Therefore, the method helps to avoid the problem that new tasks are separated to server nodes with higher load rates under the random distribution condition, so that the load rate difference distance between different server nodes is larger and larger. Furthermore, uniformity of the load rate of the server nodes is improved, load among the server nodes is balanced, and processing efficiency of the server nodes is improved.
Further, when the server node with the lowest load rate does not have the idle service, the task of the load connection service for sending the load information is stopped, and the idle load connection service is returned to the connection request, so that the task of the connection request is executed. Because the task of the connection request is generally more demanding for the user than the task of sending the load information. Moreover, since the server node with the lowest load rate does not have any idle service, that is, all server nodes are in a full-load state, transmission of load information can be stopped in a short time. Therefore, the task of the connection request is executed by changing the load connection service into the idle state, so that timely execution of important tasks is guaranteed, and the use experience of a user is guaranteed.
As shown in fig. 7 and 8, the present embodiment also provides a machine-readable storage medium 100 and a computer device 200. The machine-readable storage medium 100 has stored thereon a machine-executable program 110, which when executed by a processor, implements the method of load balancing a database of any of the embodiments described above.
The computer device 200 may include a memory 210, a processor 220, and a machine executable program 110 stored on the memory 210 and running on the processor 220, and the processor 220 implements the load balancing method of the database of any of the embodiments described above when executing the machine executable program 110.
It should be noted that the logic and/or steps represented in the flow diagrams or otherwise described herein, e.g., a ordered listing of executable instructions for implementing logical functions, can be embodied in any machine-readable storage medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions.
By now it should be appreciated by those skilled in the art that while a number of exemplary embodiments of the invention have been shown and described herein in detail, many other variations or modifications of the invention consistent with the principles of the invention may be directly ascertained or inferred from the present disclosure without departing from the spirit and scope of the invention. Accordingly, the scope of the present invention should be understood and deemed to cover all such other variations or modifications.
Claims (10)
1. A method of load balancing a database, comprising:
creating a plurality of connection services for connecting with a plurality of server nodes, and each of the server nodes connecting with a plurality of the connection services;
transmitting a load notification starting command to the server node by using a connection service so as to start a task of transmitting load information at the server node;
receiving and storing the load information;
receiving a connection request of a client;
screening out the server node with the lowest load rate according to the load information;
and returning the idle connection service of the server node with the lowest load rate to the connection request.
2. The load balancing method of a database according to claim 1, wherein the step of transmitting a load notification on command to the server node using a connection service comprises:
determining one of a plurality of said connection services of said server node as a load connection service;
transmitting a load notification start command to the server node by using the load connection service;
the step of receiving and storing the load information includes:
and continuously receiving and storing the load information sent by the load connection service.
3. The method of load balancing of a database according to claim 2, wherein the step of determining one of the plurality of connection services of the server node as a load connection service comprises:
and taking the connection service adopted by the first connection of the server node as the load connection service.
4. The method for load balancing of a database according to claim 2, wherein the step of returning to the connection request the idle connection service of the server node having the lowest load rate comprises, before:
and judging whether the server node has idle connection service, if so, executing the step of returning the idle connection service to the connection request, and if not, returning the load connection service to the connection request.
5. The method of load balancing of a database according to claim 4, wherein said step of returning said load connection service to said connection request comprises, after said step of:
after the task execution of the connection request is completed, judging whether other idle connection services exist in the server node, if so, continuing to receive load information by using the returned load connection service, and if not, enabling the returned load connection service to be in an idle state.
6. The method of load balancing of a database according to claim 5, wherein said step of placing said returned load connection service in an idle state comprises:
detecting whether the server node has a plurality of idle connection services;
and if the server node has a plurality of idle connection services, selecting one of the idle connection services as a load connection service.
7. The load balancing method of a database according to claim 2, wherein the load notification on command includes a notification interval, and the step of continuously receiving and storing load information transmitted by the load connection service includes:
and continuously receiving the load information sent by the load connection service according to the notification interval.
8. The load balancing method of the database according to claim 1, wherein the load information includes an active session number, an inactive session number, a CPU usage rate, a memory usage rate, and an input output usage rate of the server node, and the step of screening out the server node with the lowest load rate according to the load information includes:
and calculating the load rate according to the first preset correction value of the number of active sessions plus the number of inactive sessions plus the CPU utilization rate plus the second preset correction value of the number of active sessions plus the memory utilization rate plus the third preset correction value of the number of active sessions plus the input and output utilization rate plus the fourth preset correction value of the number of inactive sessions.
9. A machine-readable storage medium having stored thereon a machine-executable program which when executed by a processor implements a method of load balancing a database according to any of claims 1 to 8.
10. A computer device comprising a memory, a processor and a machine executable program stored on the memory and running on the processor, and the processor implementing a load balancing method for a database according to any one of claims 1 to 8 when executing the machine executable program.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310083208.3A CN116010527A (en) | 2023-01-17 | 2023-01-17 | Load balancing method, storage medium and equipment for database |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310083208.3A CN116010527A (en) | 2023-01-17 | 2023-01-17 | Load balancing method, storage medium and equipment for database |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116010527A true CN116010527A (en) | 2023-04-25 |
Family
ID=86021526
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310083208.3A Pending CN116010527A (en) | 2023-01-17 | 2023-01-17 | Load balancing method, storage medium and equipment for database |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116010527A (en) |
-
2023
- 2023-01-17 CN CN202310083208.3A patent/CN116010527A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CA3168286A1 (en) | Data flow processing method and system | |
US20090328054A1 (en) | Adapting message delivery assignments with hashing and mapping techniques | |
US10250482B2 (en) | Distributed task execution in different locations with dynamic formation of testing groups | |
JPWO2010131778A1 (en) | Workflow monitoring control system, monitoring control method and monitoring control program | |
CN101510167A (en) | Plug-in component operation method, apparatus and system | |
CN112465615B (en) | Method, device and system for processing bill data | |
CN108243222A (en) | Server network architecture method and device | |
CN109491788A (en) | A kind of virtual platform implementation of load balancing and device | |
CN106506278B (en) | Service availability monitoring method and device | |
CN111143170A (en) | Cloud mobile phone monitoring system and method | |
CN113946362B (en) | Consumption data processing method and storage medium | |
EP2472416B1 (en) | Data query system and constructing method thereof and corresponding data query method | |
CN111835809B (en) | Work order message distribution method, work order message distribution device, server and storage medium | |
CN111355751A (en) | Task scheduling method and device | |
CN111737028B (en) | Dubbo service detection method and device | |
CN112994918B (en) | Equipment management method and device | |
CN116010527A (en) | Load balancing method, storage medium and equipment for database | |
CN117032987A (en) | Distributed task scheduling method, system, equipment and computer readable medium | |
CN108234215B (en) | Gateway creating method and device, computer equipment and storage medium | |
WO2023137204A1 (en) | Virtual machine as a service for an autonomous edge | |
CN106230878B (en) | Equipment service calling method and device based on AllJoyn framework | |
CN111782364B (en) | Service calling method, device, electronic equipment and storage medium | |
CN111240857B (en) | Remote service calling system and method | |
JPH1124949A (en) | Parallel processing controller | |
CN105099934A (en) | Load balancing method and device in telecommunication product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information |
Country or region after: China Address after: 100102 201, 2 / F, 101, No. 5 building, No. 7 Rongda Road, Chaoyang District, Beijing Applicant after: China Electronics Technology Group Jincang (Beijing) Technology Co.,Ltd. Address before: 100102 201, 2 / F, 101, No. 5 building, No. 7 Rongda Road, Chaoyang District, Beijing Applicant before: BEIJING KINGBASE INFORMATION TECHNOLOGIES Inc. Country or region before: China |
|
CB02 | Change of applicant information |