Load balancing method and device for network connection in distributed database

By adopting load balancing methods in distributed databases, reading client configuration files, determining polling sequences and responding to connection requests, the problem that traditional methods cannot handle a large number of concurrent connections is solved, and stable and uniform connection services are achieved in a high concurrency environment.

CN118869702BActive Publication Date: 2025-03-21SUZHOU JIBEISI DATA TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411275800.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2025-03-21
Estimated Expiration
2044-09-12

AI Technical Summary

Technical Problem

Traditional connection management methods cannot handle a large number of concurrent network connections easily and easily while being efficient and controllable, resulting in unsuitable commercial operation environments with multiple connections and lightweight services.

Method used

A load balancing method for network connections in a distributed database is provided. By reading the load balancing configuration file of the client, the polling sequence is determined, and the target service connection information is determined based on the polling sequence and the previous service connection information to respond to the target connection request.

Benefits of technology

A secure and controllable configuration flexible and simple load optimization technology for network connections can be realized, which can provide stable, secure and evenly distributed connection services in high concurrency environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118869702B_ABST
    Figure CN118869702B_ABST
Patent Text Reader

Abstract

The present invention provides a load balancing method and device for network connection in a distributed database, which is applied to the fields of computer and network technology. The method comprises: in response to a target connection request generated by a client for a server cluster, reading a load balancing configuration file of the client, the load balancing configuration file comprising a polling starting point value and a plurality of service connection information, the polling starting point value being used to determine the starting point service connection information assigned for the first connection request, the client having a plurality of clients, and the polling starting point values ​​configured in the load balancing configuration files of different clients are different; determining a polling sequence according to the plurality of service connection information; obtaining the last service connection information determined for the last connection request generated by the client; determining the target service connection information located after the last service connection information according to the polling sequence and the last service connection information; responding to the target connection request according to the target service connection information.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of computer and network technology, and more specifically, to a load balancing method and device for network connection in a distributed database. Background Art

[0002] With the development of the Internet, distributed databases are responsible for more and more network access and need to handle a large number of network connections. Whether it is real-time communication, large-scale data processing, or distributed systems, network connection load management and optimization have become key technologies. Traditional connection management methods cannot handle a large number of concurrent connections in an efficient and controllable manner while being simple and easy to use, which makes them unsuitable for commercial operating environments with many connections and lightweight services. Summary of the invention

[0003] In view of this, the present invention provides a load balancing method and device for network connections in a distributed database.

[0004] One aspect of the present invention provides a load balancing method for network connection in a distributed database, comprising: in response to a target connection request for a server cluster generated by a client, reading a load balancing configuration file of the client, wherein the server cluster includes multiple servers, the load balancing configuration file includes a polling starting value and multiple service connection information of the multiple servers, the polling starting value is used to determine the starting service connection information assigned to the first connection request generated by the client in the initialization startup phase, the client has multiple clients, and the polling starting values ​​configured in the load balancing configuration files of different clients are different; determining a polling sequence based on the multiple service connection information, wherein the polling sequence represents the order of polling for the multiple service connection information; obtaining the previous service connection information determined for the previous connection request generated by the client; determining the target service connection information located after the previous service connection information based on the polling sequence and the previous service connection information; and responding to the target connection request based on the target service connection information.

[0005] Another aspect of the present invention provides a load balancing device for network connection in a distributed database, comprising: a reading module, for reading a load balancing configuration file of a client in response to a target connection request for a server cluster generated by a client, wherein the server cluster includes multiple servers, the load balancing configuration file includes a polling starting value and multiple service connection information of the multiple servers, the polling starting value is used to determine the starting service connection information assigned to the first connection request generated by the client in the initialization startup phase, and the client has multiple clients, and the polling starting values ​​configured in the load balancing configuration files of different clients are different; a polling sequence determination module, for determining a polling sequence based on multiple service connection information, wherein the polling sequence represents the order of polling for multiple service connection information; a connection information acquisition module, for obtaining the previous service connection information determined for the previous connection request generated by the client; a connection information determination module, for determining the target service connection information located after the previous service connection information based on the polling sequence and the previous service connection information; and a response module, for responding to the target connection request based on the target service connection information.

[0006] Another aspect of the present invention provides an electronic device, comprising: one or more processors; a memory for storing one or more programs, wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the load balancing method for network connections in the distributed database of the present invention.

[0007] Another aspect of the present invention provides a computer-readable storage medium storing computer-executable instructions, which, when executed, are used to implement the load balancing method for network connections in a distributed database of the present invention.

[0008] According to the embodiments of the present invention, a secure and controllable load optimization technology for network connection with flexible and simple configuration is implemented, which can provide stable, secure and evenly distributed connection services in a high-concurrency environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:

[0010] Figure 1 An exemplary system architecture to which a load balancing method for network connections in a distributed database can be applied according to an embodiment of the present invention is shown;

[0011] Figure 2 A flow chart showing a load balancing method for network connections in a distributed database according to an embodiment of the present invention is shown;

[0012] Figure 3 A schematic diagram of a load balancing management architecture according to an embodiment of the present invention is shown;

[0013] Figure 4A A schematic diagram showing load balancing of three connections sequentially generated by client 1 (polling starting point value=1) according to an embodiment of the present invention is shown;

[0014] Figure 4B A schematic diagram showing load balancing of three connections sequentially generated by client 2 (polling starting point value=2) according to an embodiment of the present invention is shown;

[0015] Figure 5 A block diagram showing a load balancing device for network connection in a distributed database according to an embodiment of the present invention; and

[0016] Figure 6 A block diagram of an electronic device suitable for a load balancing method for network connections in a distributed database according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0017] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.

[0018] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0019] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0020] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0021] In the embodiments of the present invention, the collection, updating, analysis, processing, use, transmission, provision, disclosure, storage, etc. of the data involved (for example, including but not limited to user personal information) are in compliance with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. In particular, necessary measures are taken for user personal information to prevent illegal access to user personal information data and maintain information security.

[0022] In the embodiment of the present invention, before obtaining or collecting the user's personal information, the user's authorization or consent is obtained.

[0023] For the management of a large number of network connections, the relevant technologies generally adopt methods such as load balancing, connection reuse and asynchronous I / O, and use the form of concentrating connections on the load balancing server and then distributing them to various business services after the server calculates the pressure of each connection. Although these technologies can solve the problem of large-scale connection management to a certain extent, there are still some shortcomings. For example, the method of centrally calculating the load and then distributing the connections has the characteristics of complex connection management, cumbersome load calculation method, and difficult deployment and configuration, which is not suitable for high-concurrency but lightweight service environments.

[0024] An embodiment of the present invention provides a load balancing method and device for network connection in a distributed database. The method includes: in response to a target connection request generated by a client for a server cluster, reading a load balancing configuration file of the client, wherein the server cluster includes multiple servers, the load balancing configuration file includes a polling starting value and multiple service connection information of multiple servers, the polling starting value is used to determine the starting service connection information assigned to the first connection request generated by the client in the initialization startup phase, the client has multiple clients, and the polling starting values ​​configured in the load balancing configuration files of different clients are different; according to the multiple service connection information, determining a polling sequence, wherein the polling sequence represents the order of polling for the multiple service connection information; obtaining the previous service connection information determined for the previous connection request generated by the client; according to the polling sequence and the previous service connection information, determining the target service connection information located after the previous service connection information; and responding to the target connection request according to the target service connection information.

[0025] Figure 1 An exemplary system architecture 100 to which a load balancing method for network connections in a distributed database can be applied according to an embodiment of the present invention is shown. It should be noted that: Figure 1 The examples shown are merely examples of system architectures to which the embodiments of the present invention may be applied, to help those skilled in the art understand the technical content of the present invention, but do not mean that the embodiments of the present invention may not be used in other devices, systems, environments or scenarios.

[0026] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0027] The user may use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (only for example).

[0028] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0029] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0030] It should be noted that the load balancing method for network connection in the distributed database provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the load balancing device for network connection in the distributed database provided in the embodiment of the present invention can generally be set in the server 105. The load balancing method for network connection in the distributed database provided in the embodiment of the present invention can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Correspondingly, the load balancing device for network connection in the distributed database provided in the embodiment of the present invention can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Alternatively, the load balancing method for network connection in the distributed database provided in the embodiment of the present invention can also be executed by the first terminal device 101, the second terminal device 102, or the third terminal device 103, or can also be executed by other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103. Correspondingly, the load balancing device for network connection in the distributed database provided in the embodiment of the present invention can also be set in the first terminal device 101, the second terminal device 102, or the third terminal device 103, or in other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103.

[0031] For example, the client and the server can both be the first terminal device 101, the second terminal device 102, the third terminal device 103, other terminal devices, servers, or any one of a server cluster. In response to a target connection request for a server cluster generated by the client, the client can execute the load balancing method for network connection in a distributed database provided in an embodiment of the present invention.

[0032] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0033] Figure 2 A flow chart of a load balancing method for network connections in a distributed database according to an embodiment of the present invention is shown.

[0034] like Figure 2 As shown, the method includes operations S201 to S205.

[0035] In operation S201, in response to a target connection request generated by the client for a server cluster, a load balancing configuration file of the client is read, wherein the server cluster includes multiple servers, the load balancing configuration file includes a polling starting point value and multiple service connection information of the multiple servers, the polling starting point value is used to determine the starting point service connection information assigned to the first connection request generated by the client in the initialization startup phase, and the client has multiple clients, and the polling starting point values ​​configured in the load balancing configuration files of different clients are different.

[0036] According to an embodiment of the present invention, the target connection request is initiated by the client to request a network connection to a server in the server cluster. The client may have one or more. The network may include TCP (Transmission Control Protocol), UDP (User Datagram Protocol), FTP (File Transfer Protocol), HTTP (HyperText Transfer Protocol), etc., and may not be limited thereto.

[0037] According to an embodiment of the present invention, a load balancing configuration file can be used as a lightweight load balancing module and pre-configured in the client. The load balancing module can exist in the form of an API (Application Programming Interface) and can be embedded in the client very flexibly. As a result, there is no need for an independent load balancing server, and the client connection does not require the calculation and forwarding of the load balancing server. The client itself can be used as a small load balancing calculator to connect to the corresponding business service.

[0038] According to an embodiment of the present invention, multiple service connection information can be determined based on server information in a server cluster to be accessed by a client. Multiple service connection information can be stored in an independent relational database in the form of a list, and may not be limited thereto, for example, it may also include a linked list, a sequence, etc. The list may be pre-configured in a load balancing configuration file.

[0039] For example, the list of service connection information may be designed as shown in Table 1 below.

[0040] Table 1

[0041]

[0042] Among them, id can represent the serial number of the service connection information. Virtual tag can represent the first virtual tag. Virtual tag2 can represent the second virtual tag. Virtual tag2 and virtual tag cooperate to determine whether they are the connection information of the same group. For example, in the above example, the 4 lines of connection information all belong to the group 192.99.99.99:999. Sub id can represent the connection information number within the group. IP can represent the IP address of the service connection information. Port can represent the port number of the service connection information. Weight can represent the priority of the service connection information.

[0043] According to an embodiment of the present invention, a list representing multiple service connection information may also be stored in a remote server, and the list may be obtained by using a load balancing module on each client through ODBC or a function interface.

[0044] For example, when there are multiple clients and each client is embedded with a load balancing module, the list of business servers that the client can connect to can be collected through the connection target management server. The list can record service connection information such as target IP, connection weight value, sequence number, etc. This can achieve unified management of multi-client load balancing connection targets without having to configure the connection list for each client one by one.

[0045] Figure 3 A schematic diagram of a load balancing management architecture according to an embodiment of the present invention is shown.

[0046] like Figure 3 As shown, N clients are shown: client 1, ..., client N, 3 servers: business service 1, business service 2, business service 3, and a target management server 310, which can be used to store a list of service connection information of each business service in the three servers. Each client is embedded with a load balancing module. The communication between the client and the server can be completed through the load balancing module. Each client can independently run the load balancing logic, including reading the service connection information and responding to the connection request based on the service connection information, so as to finally complete the establishment of the connection between the client and the server.

[0047] In operation S202, a polling sequence is determined according to the plurality of service connection information, wherein the polling sequence represents the order of polling the plurality of service connection information.

[0048] According to an embodiment of the present invention, the polling sequence can be directly determined according to the storage order of the service connection information. In this case, the polling sequence is the storage order. The storage order can be customized according to business needs, or it can be randomly determined, which is not limited here. The polling sequence can represent the polling order of the service connection information in response to multiple connection requests initiated by the same client.

[0049] In operation S203, the last service connection information determined for the last connection request generated by the client is obtained.

[0050] In operation S204, target service connection information subsequent to the previous service connection information is determined according to the polling sequence and the previous service connection information.

[0051] In operation S205, a response is made to the target connection request according to the target service connection information.

[0052] According to an embodiment of the present invention, each client embedded with a load balancing module can configure a polling starting point value, which can be used to define a polling range. The polling starting point value can directly take the serial number value of the service connection information, or it can take a random integer value, and the target service connection information to be responded to is determined by performing a modulo calculation with the number of recorded service connection information. The value-taking method of the polling starting point value is not limited here, as long as the polling starting point values ​​configured in the load balancing configuration files of different clients are kept different.

[0053] According to the embodiment of the present invention, since the polling starting point values ​​configured in the load balancing modules of different clients are different, the load balancing module can be used to evenly distribute the polling process sequence of the service connection information used to respond to the connection requests initiated by different clients. This solution can be applied to the scenario where the client and the corresponding server have obvious business classification, and can also be applied to the scenario where there is a higher requirement for the uniformity after the load balancing service is started.

[0054] Figure 4A A schematic diagram is shown of load balancing three connections sequentially generated by client 1 (polling starting point value=1) according to an embodiment of the present invention.

[0055] Figure 4B A schematic diagram is shown of load balancing three connections sequentially generated by client 2 (polling starting point value=2) according to an embodiment of the present invention.

[0056] like Figure 4A and Figure 4B As shown, by configuring the starting position, after different clients are started, the order of reading service connection information is shifted back in sequence, effectively achieving a uniform connection effect for multiple concurrent clients.

[0057] Through the above-mentioned embodiments of the present invention, a safe and controllable load optimization technology for network connection with flexible and simple configuration is realized, which can provide stable, safe and evenly distributed connection services in a high-concurrency environment.

[0058] In conjunction with specific embodiments, Figure 2 The method shown is further explained.

[0059] According to an embodiment of the present invention, the servers in the server cluster have weights. The above operation S202 may include: determining a polling sequence constructed by the multiple service connection information according to the weights of the multiple servers related to the multiple service connection information, wherein the number of the polling sequence representing the same service connection information includes multiple.

[0060] According to an embodiment of the present invention, different servers in a server cluster may have different weights due to differences in performance, computing power, etc. According to the differences in weights, a polling sequence for weighted polling may be set based on multiple service connection information.

[0061] For example, if the weight of business service 1 is 2, the weight of business service 2 is 1, and the weight of business service 3 is 3, the polling sequence may be determined as [business service 3, business service 1, business service 3, business service 2, business service 3, business service 1], etc., and may not be limited thereto. Each element in the polling sequence may represent a service connection information.

[0062] According to an embodiment of the present invention, each service connection information may have a sequence number, and the sequence number represents the position information of the service connection information in the polling sequence. The above operation S204 may include: determining a target sequence number according to the polling sequence and a previous sequence number corresponding to the previous service connection information. The service connection information corresponding to the target sequence number is determined as the target service connection information.

[0063] Based on the above embodiment, the sequence number of the service connection information polled this time can be determined by determining the sequence number of the service connection information polled last time in the polling sequence, and then the target service connection information polled this time can be determined.

[0064] It should be noted that the polling sequence can be predetermined and written into the load balancing configuration file or the target management server. It can also not be predetermined, but the load balancing module generates the polling sequence based on multiple service connection information and the weight calculation of each server. This is not limited here.

[0065] Through the above embodiments of the present invention, the load balancing method can be used to calculate the load balancing using a weighted polling algorithm, and the polling ranges between multiple clients can be balanced on a weighted basis. Thus, the possibility of multiple clients initiating connections to the same server at the same time when the weighted polling algorithm is used to calculate the connection load can be reduced.

[0066] According to an embodiment of the present invention, the load balancing method for network connection in a distributed database may further include: obtaining a network connection obtained by responding to a target connection request according to target service connection information. Storing the network connection information in a connection pool. In response to determining that the network connection stored in the connection pool meets a preset condition, releasing resources of the service connection information corresponding to the network connection.

[0067] According to an embodiment of the present invention, after responding to the target connection request according to the target service connection information, a network connection between the client and the server can be established. In this solution, all established network connections will not be disconnected automatically, but by storing the established network connections in the connection pool, the connection pool controls the life cycle of the network connection to prevent the connection port from being occupied for a long time without being used, which will hinder the connection of other clients.

[0068] According to an embodiment of the present invention, each load balancing module may be configured with one or more connection pools. Each connection pool may be configured with a connection upper limit value for controlling the number of network connections that can be stored.

[0069] According to an embodiment of the present invention, control can be performed by two dimensions, time dimension or communication number, to determine whether a network connection has reached the required period of life cycle. For example, the preset condition includes at least one of the following: the network connection state is not used and the connection duration has reached the preset duration, the network connection state is not used and the number of times used has reached the preset number of times, and it is not limited thereto.

[0070] According to an embodiment of the present invention, a network connection may be in a connected state, such as being in use or not in use. The connection duration may represent the length of time the network connection is in a connected state. The number of uses may represent the number of times the network connection is called. Each time a query request is generated based on the network connection, a call to the network connection may be generated.

[0071] According to an embodiment of the present invention, when a network connection is not in use, if it is determined that the connection duration of the network connection has reached a preset duration, or it is determined that the number of times the network connection has been used has reached a preset number of times, the network connection port can be used to release the resources of the service connection information corresponding to the network connection.

[0072] For example, the life cycle can be set according to the connection duration. Once the network connection is established, the connection duration is timed. Once the preset duration is reached, the network connection can be gradually destroyed. This method can calibrate the life cycle of the connection in the time dimension. The process of destroying the connection and creating a new connection will trigger the connection load balancing logic to re-establish the connection with the business server.

[0073] For example, the life cycle can be set according to the number of times a network connection is used. Once a connection is established, the number of times the connection is called can be calculated. Once the preset number of times is reached, the connection can be gradually destroyed. This method can calibrate the life cycle of a connection based on the number of times it is used. The process of destroying a connection and creating a new one will trigger the connection load balancing logic to re-establish the connection with the business server.

[0074] According to an embodiment of the present invention, the life cycle of a network connection may be characterized by a connection lifetime, and the connection lifetime may be determined according to a preset duration or a preset number of times.

[0075] According to an embodiment of the present invention, in order to prevent large-scale connections from being suddenly disconnected and causing system socket cleaning resources to be tight, a slow-release disconnection factor can be designed to gradually disconnect connections by adding a random factor to the expected value, thereby alleviating system cleaning pressure.

[0076] According to an embodiment of the present invention, the preset duration may be determined according to the expected duration and the first slow-release disconnection factor, and the first slow-release disconnection factor may be determined according to the first random number and the expected duration.

[0077] For example, we can get: connection lifetime (connection duration dimension) = expected duration + (srand1 (expected duration × 50%)), where srand1 can be used to generate random numbers within a specified range.

[0078] According to an embodiment of the present invention, the preset number of times may be determined according to the expected number of times and the second slow-release disconnection factor, and the second slow-release disconnection factor may be determined according to the second random number and the expected number of times.

[0079] For example, we can get: connection life (number of uses dimension) = expected number of uses + (srand2 (expected number of uses × 30%)), where srand2 can be used to generate random numbers within a specified range.

[0080] Through the above-mentioned embodiments of the present invention, the disconnection can be released slowly according to the random factor: random factor. By using the release disconnection factor to add a release variable to the service life of the network connection, the impact of batch network connections being disconnected at the same time and then batches of new network connections being generated on the network and backend services can be reduced.

[0081] According to the above-mentioned embodiment of the present invention, a lightweight distributed connection pool technology is proposed, which can optimize the load service of network connections in lightweight business scenarios. It solves the problems of complex connection management, cumbersome load calculation methods, and difficult deployment and configuration of traditional load balancing services, and has the following advantages and application value: the load balancing service and the client are combined into one, eliminating the need to deploy a load balancing service separately, and reducing forwarding failures caused by forwarding by the load balancing server. Because it is a direct transmission from the client to the business service, the data transmission efficiency is improved. Since the load balancing logic is simple, it is suitable for environments with large concurrency but lightweight business. Since there is no need to consider the connection forwarding efficiency, the current environment balancing algorithm, the connection redundant buffer strategy, etc. too much, the configuration is simple and easy to use. By using time and number of times to determine the connection life, the problem of load imbalance caused by high-frequency and long-term occupied connections in the connection pool in extreme cases is solved.

[0082] Figure 5 A block diagram of a load balancing device for network connection in a distributed database according to an embodiment of the present invention is shown.

[0083] like Figure 5 As shown, a load balancing device 500 for network connection in a distributed database includes a reading module 510 , a polling sequence determination module 520 , a connection information acquisition module 530 , a connection information determination module 540 and a response module 550 .

[0084] The reading module 510 is used to read the load balancing configuration file of the client in response to the target connection request for the server cluster generated by the client, wherein the server cluster includes multiple servers, and the load balancing configuration file includes a polling starting point value and multiple service connection information of the multiple servers. The polling starting point value is used to determine the starting point service connection information assigned to the first connection request generated by the client in the initialization startup phase. The client has multiple clients, and the polling starting point values ​​configured in the load balancing configuration files of different clients are different.

[0085] The polling sequence determination module 520 is used to determine a polling sequence according to the multiple service connection information, wherein the polling sequence represents the order of polling the multiple service connection information.

[0086] The connection information acquisition module 530 is used to acquire the last service connection information determined for the last connection request generated by the client.

[0087] The connection information determining module 540 is used to determine the target service connection information located after the previous service connection information according to the polling sequence and the previous service connection information.

[0088] The response module 550 is used to respond to the target connection request according to the target service connection information.

[0089] According to an embodiment of the present invention, the servers in the server cluster have weights. The polling sequence determination module includes a polling sequence determination unit.

[0090] The polling sequence determining unit is used to determine a polling sequence constructed by multiple service connection information according to respective weights of multiple servers related to the multiple service connection information, wherein the number of the same service connection information represented in the polling sequence includes multiple.

[0091] According to an embodiment of the present invention, each service connection information has a sequence number, and the sequence number represents the position information of the service connection information in the polling sequence. The connection information determination module includes a target sequence number determination unit and a connection information determination unit.

[0092] The target sequence number determination unit is used to determine the target sequence number according to the polling sequence and the last sequence number corresponding to the last service connection information.

[0093] The connection information determining unit is used to determine the service connection information corresponding to the target sequence number as the target service connection information.

[0094] According to an embodiment of the present invention, the load balancing device for network connection in a distributed database further includes a network connection acquisition module, a storage module and a release module.

[0095] The network connection acquisition module is used to acquire network connection information obtained by responding to a target connection request based on the target service connection information.

[0096] The storage module is used to store network connection information into the connection pool.

[0097] The release module is used to release the resource of the service connection information corresponding to the network connection in response to determining that the network connection stored in the connection pool meets the preset condition.

[0098] According to an embodiment of the present invention, the preset condition includes at least one of the following: the network connection state is not used and the connection duration has reached a preset duration, the network connection state is not used and the number of times it has been used reaches a preset number of times.

[0099] According to an embodiment of the present invention, the preset duration is determined according to the expected duration and a first slow-release disconnection factor, and the first slow-release disconnection factor is determined according to a first random number and the expected duration.

[0100] According to an embodiment of the present invention, the preset number of times is determined according to the expected number of times and the second slow-release disconnection factor, and the second slow-release disconnection factor is determined according to the second random number and the expected number of times.

[0101] According to the embodiments of the present invention, any multiple of the modules and units, or at least part of the functions of any multiple of them, can be implemented in one module. According to the embodiments of the present invention, any one or more of the modules and units can be split into multiple modules for implementation. According to the embodiments of the present invention, any one or more of the modules and units can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present invention, one or more of the modules and units can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

[0102] For example, any multiple of the reading module 510, the polling sequence determination module 520, the connection information acquisition module 530, the connection information determination module 540, and the response module 550 can be combined in one module / unit for implementation, or any one of the modules / units can be split into multiple modules / units. Alternatively, at least part of the functions of one or more of these modules / units can be combined with at least part of the functions of other modules / units and implemented in one module / unit. According to an embodiment of the present invention, at least one of the reading module 510, the polling sequence determination module 520, the connection information acquisition module 530, the connection information determination module 540, and the response module 550 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, at least one of the reading module 510, the polling sequence determination module 520, the connection information acquisition module 530, the connection information determination module 540 and the response module 550 may be at least partially implemented as a computer program module, which may perform corresponding functions when executed.

[0103] It should be noted that the load balancing device part for network connection in the distributed database in the embodiment of the present invention corresponds to the load balancing method part for network connection in the distributed database in the embodiment of the present invention. The description of the load balancing device part for network connection in the distributed database specifically refers to the load balancing method part for network connection in the distributed database, which will not be repeated here.

[0104] Figure 6 A block diagram of an electronic device suitable for a load balancing method for network connections in a distributed database according to an embodiment of the present invention is shown. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0105] like Figure 6 As shown, the electronic device 600 according to an embodiment of the present invention includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 to a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0106] In RAM 603, various programs and data required for the operation of electronic device 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other via bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in the one or more memories.

[0107] According to an embodiment of the present invention, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the input / output (I / O) interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 609 including a network interface card such as a LAN card, a modem, etc. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.

[0108] According to an embodiment of the present invention, the method flow according to an embodiment of the present invention can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above-mentioned functions defined in the system of the embodiment of the present invention are executed. According to an embodiment of the present invention, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0109] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.

[0110] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device.

[0111] For example, according to an embodiment of the present invention, the computer-readable storage medium may include the ROM 602 and / or the RAM 603 described above and / or one or more memories other than the ROM 602 and the RAM 603 .

[0112] An embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method provided by the embodiment of the present invention. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the method provided by the embodiment of the present invention.

[0113] When the computer program is executed by the processor 601, the above functions defined in the system / device of the embodiment of the present invention are executed. According to the embodiment of the present invention, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0114] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 609, and / or installed from a removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0115] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

[0116] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments and / or claims of the present invention can be combined and / or combined in various ways, even if such a combination or combination is not explicitly recorded in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features described in the various embodiments and / or claims of the present invention may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present invention.

[0117] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination. The scope of the present invention is defined by the attached claims and their equivalents. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.

Claims

1. A load balancing method for network connection in a distributed database, characterized in that: The method comprises: In response to a target connection request for a server cluster generated by a client, a load balancing configuration file of the client is read, wherein the server cluster includes a plurality of servers, the load balancing configuration file includes a polling starting value and a plurality of service connection information of the plurality of servers, the polling starting value is used to determine the starting service connection information assigned to the first connection request generated by the client in the initialization startup phase, the client has a plurality of clients, and the polling starting values ​​configured in the load balancing configuration files of different clients are different, and each of the clients obtains the service connection information of the server to which the client is connected by connecting to a target management server; Determine a polling sequence according to the plurality of service connection information, wherein the polling sequence represents an order of polling the plurality of service connection information; Obtaining last service connection information determined for a last connection request generated by the client; Determining target service connection information located after the previous service connection information according to the polling sequence and the previous service connection information; and Respond to the target connection request according to the target service connection information to obtain network connection information; Storing the network connection information in a connection pool; and In response to determining that the network connection stored in the connection pool meets a preset condition, releasing the resources of the service connection information corresponding to the network connection, wherein the preset condition includes at least one of the following: the status of the network connection is unused and the connection duration has reached a preset duration, the status of the network connection is unused and the number of times it has been used has reached a preset number of times.

2. The method according to claim 1, characterized in that The servers in the server cluster have weights; and determining the polling sequence according to the plurality of service connection information comprises: The polling sequence constructed by the multiple service connection information is determined according to respective weights of multiple servers related to the multiple service connection information, wherein the number of the polling sequence representing the same service connection information includes multiple.

3. The method according to claim 2, characterized in that Each of the service connection information has a sequence number, and the sequence number represents the position information of the service connection information in the polling sequence; and determining the target service connection information located after the previous service connection information according to the polling sequence and the previous service connection information comprises: Determining a target sequence number according to the polling sequence and a previous sequence number corresponding to the previous service connection information; and The service connection information corresponding to the target sequence number is determined as the target service connection information.

4. The method according to claim 1, characterized in that: The preset duration is determined according to the expected duration and a first slow-release disconnection factor, and the first slow-release disconnection factor is determined according to a first random number and the expected duration.

5. The method according to claim 1, characterized in that The preset number of times is determined according to the expected number of times and a second slow-release disconnection factor, and the second slow-release disconnection factor is determined according to a second random number and the expected number of times.

6. A load balancing device for network connection in a distributed database, characterized in that: The device comprises: A reading module, configured to read a load balancing configuration file of the client in response to a target connection request for a server cluster generated by the client, wherein the server cluster includes a plurality of servers, the load balancing configuration file includes a polling starting value and a plurality of service connection information of the plurality of servers, the polling starting value is used to determine the starting service connection information assigned to the first connection request generated by the client in the initialization startup phase, the client has a plurality of clients, and the polling starting values ​​configured in the load balancing configuration files of different clients are different, and each of the clients obtains the service connection information of the server to which the client is connected by connecting to the target management server; A polling sequence determination module, configured to determine a polling sequence according to the plurality of service connection information, wherein the polling sequence represents an order of polling the plurality of service connection information; A connection information acquisition module, used to acquire the last service connection information determined for the last connection request generated by the client; a connection information determination module, configured to determine target service connection information subsequent to the previous service connection information according to the polling sequence and the previous service connection information; and A response module, used for responding to the target connection request according to the target service connection information; A network connection acquisition module, used to acquire network connection information obtained by responding to the target connection request according to the target service connection information; A storage module, used for storing the network connection information into a connection pool; and A release module is used to release the resources of the service connection information corresponding to the network connection in response to determining that the network connection stored in the connection pool meets the preset conditions, wherein the preset conditions include at least one of the following: the status of the network connection is not used and the connection duration has reached the preset duration, the status of the network connection is not used and the number of times it has been used has reached a preset number of times.

7. An electronic device comprising: one or more processors; a memory for storing one or more programs, It is characterized in that when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: Executable instructions are stored thereon, and when the instructions are executed by a processor, the processor implements the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Equipment network connection method, device, electronic equipment, server and system

    CN115514800A

  • Application-oriented model service framework and automatic deployment system thereof

    CN118158106A