CN108696549B - Load balancing method, device and system - Google Patents

Load balancing method, device and system Download PDF

Info

Publication number
CN108696549B
CN108696549B CN201710216555.3A CN201710216555A CN108696549B CN 108696549 B CN108696549 B CN 108696549B CN 201710216555 A CN201710216555 A CN 201710216555A CN 108696549 B CN108696549 B CN 108696549B
Authority
CN
China
Prior art keywords
list
identifier
identification
server
preset
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.)
Active
Application number
CN201710216555.3A
Other languages
Chinese (zh)
Other versions
CN108696549A (en
Inventor
罗睿恒
林德强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710216555.3A priority Critical patent/CN108696549B/en
Publication of CN108696549A publication Critical patent/CN108696549A/en
Application granted granted Critical
Publication of CN108696549B publication Critical patent/CN108696549B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/12Avoiding congestion; Recovering from congestion
    • H04L47/125Avoiding congestion; Recovering from congestion by balancing the load, e.g. traffic engineering

Abstract

The application discloses a load balancing method, a device and a system. One embodiment of the method comprises: for each server in the server cluster, determining a topic of a message which is processed by the server, and determining an identifier of a client which has established connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list which corresponds to the server and is divided according to the topic; for each generated identification list, extracting a preset identification list corresponding to the identification list, and updating the identification list based on the preset identification list in response to determining that the identification list does not match the preset identification list; analyzing the IP address of the client indicated by the identifier in the updated identifier list to generate a target identifier set; and sending the generated target identification sets to a storage server. This embodiment improves the efficiency of establishing a connection and improves the stability of the connection.

Description

Load balancing method, device and system
Technical Field
The present application relates to the field of computer technologies, and in particular, to the field of internet, and in particular, to a load balancing method, apparatus, and system.
Background
With the development of computer technology, distributed technology is widely applied to enterprise production environments. In distributed technologies, a distributed Message Queue (MQ) service is generally utilized to achieve stable, reliable, and efficient transfer and exchange of data between different services. Generally, the distributed message queue service needs to be completed by a plurality of servers to realize the relay of information, however, the number of clients is much larger than that of the servers, and thus, the information processed by the servers needs to be distributed to realize load balancing.
The existing load balancing method usually processes the connection request of the client by using a method of distributing message routing, however, the method is usually deployed across a machine room and a data center, resulting in connection delay; in addition, this approach can result in clients being jittered by reassigning message routes in the event that a connection is broken or a new connection is added, resulting in less stability.
Disclosure of Invention
An object of the embodiments of the present application is to provide an improved load balancing method, apparatus and system, so as to solve the technical problems mentioned in the above background.
In a first aspect, an embodiment of the present application provides a load balancing method, where a load balancing server is in communication connection with a storage server, the storage server is in communication connection with each server in a server cluster, and the server cluster includes a preset server, where the method includes: for each server in the server cluster, determining a topic of a message which is processed by the server, and determining an identifier of a client which has established connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list which corresponds to the server and is divided according to the topic; for each generated identification list, extracting a preset identification list corresponding to the identification list, updating the identification list based on the preset identification list in response to determining that the identification list is not matched with the preset identification list, and analyzing an Internet Protocol (IP) address of a client indicated by an identification in the updated identification list to generate a target identification set; and sending each generated target identification set to a storage server so that the storage server sends each target identification set to a preset server when receiving a load result acquisition request sent by the preset server.
In some embodiments, for each generated identification list, extracting a preset identification list corresponding to the identification list, and in response to determining that the identification list does not match the preset identification list, updating the identification list based on the preset identification list, includes: for each generated identification list, in response to determining that the identification list does not match the preset identification list, extracting the same identification in the identification list and the preset identification list and the order of the same identification in the preset identification list; storing the same identification to a pre-established temporary identification list in sequence; inserting the identifiers in the identifier list except the same identifier into a temporary identifier list; the list of identities is replaced with a temporary list of identities to update the list of identities.
In some embodiments, resolving the IP address of the client indicated by the identifier in the updated list of identifiers to generate a target set of identifiers includes: for each updated identification list, extracting the IP address of the client indicated by each identification in the identification list, extracting the IP address of a server corresponding to the identification list in the server cluster, and determining the extracted IP address of the server as a target IP address; determining whether the extracted IP address of each client and the target IP address correspond to the same machine room identifier or not based on a preset mapping table of the IP address and the machine room identifier; determining the identification of the client with the same machine room identification corresponding to the IP address and the target IP address as a first identification, and determining the identification of the client with different machine room identifications corresponding to the IP address and the target IP address as a second identification; and selecting a preset number of first identifications and a preset number of second identifications in the identification list, and determining the selected first identifications and the selected second identifications as target identifications to be classified into a target identification set matched with the identification list.
In some embodiments, selecting a preset number of first identifiers and a preset number of second identifiers in the identifier list, and determining the selected first identifiers and second identifiers as target identifiers to be included in a target identifier set matching the identifier list includes: for each updated identifier list, determining the times of the set entry matched with each identifier in the identifier list; selecting a preset number of first identifications according to the sequence from small to large of the times of the set entry, and selecting a preset number of second identifications according to the sequence; and determining the selected first identifier and the second identifier as target identifiers to be classified into a target identifier set matched with the identifier list.
In some embodiments, selecting a preset number of first identifiers and a preset number of second identifiers in the identifier list, and determining the selected first identifiers and second identifiers as target identifiers to be included in a target identifier set matching the identifier list includes: for each updated identifier list, determining the times of the set entry matched with each identifier in the identifier list; in response to determining that the first identifier does not exist in the identifier list, sorting the identifiers in the identifier list according to the sequence of the times of the sets from small to large; and selecting the identifiers meeting the preset conditions as target identifiers according to the sequence so as to be included in a target identifier set matched with the identifier list.
In some embodiments, resolving the IP address of the client indicated by the identifier in the updated list of identifiers to generate a target set of identifiers further comprises: and increasing the times of putting the target identifications into the set matched with the target identifications in the generated target identification set by a preset value.
In a second aspect, an embodiment of the present application provides a load balancing apparatus, where a load balancing server is in communication connection with a storage server, the storage server is in communication connection with each server in a server cluster, and the server cluster includes a preset server, the apparatus includes: the generating unit is configured to determine, for each server in the server cluster, a topic of a message which the server is responsible for processing, and determine an identifier of a client which has established connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list which corresponds to the server and is divided by topic; the updating unit is configured to extract a preset identification list corresponding to each generated identification list, update the identification list based on the preset identification list in response to determining that the identification list is not matched with the preset identification list, and analyze the IP address of the client indicated by the identification in the updated identification list to generate a target identification set; and the sending unit is configured to send each generated target identifier set to the storage server, so that the storage server sends each target identifier set to the preset server when receiving a load result acquisition request sent by the preset server.
In some embodiments, the update unit is further configured to: for each generated identification list, extracting a preset identification list corresponding to the identification list, and in response to determining that the identification list is not matched with the preset identification list, extracting the same identification in the identification list and the preset identification list and the sequence of the same identification in the preset identification list; storing the same identification to a pre-established temporary identification list in sequence; inserting the identifiers in the identifier list except the same identifier into a temporary identifier list; the list of identities is replaced with a temporary list of identities to update the list of identities.
In some embodiments, the update unit is further configured to: for each updated identification list, extracting the IP address of the client indicated by each identification in the identification list, extracting the IP address of a server corresponding to the identification list in the server cluster, and determining the extracted IP address of the server as a target IP address; determining whether the extracted IP address of each client and the target IP address correspond to the same machine room identifier or not based on a preset mapping table of the IP address and the machine room identifier; determining the identification of the client with the same machine room identification corresponding to the IP address and the target IP address as a first identification, and determining the identification of the client with different machine room identifications corresponding to the IP address and the target IP address as a second identification; and selecting a preset number of first identifications and a preset number of second identifications in the identification list, and determining the selected first identifications and the selected second identifications as target identifications to be classified into a target identification set matched with the identification list.
In some embodiments, the update unit is further configured to: for each updated identifier list, determining the times of the set entry matched with each identifier in the identifier list; selecting a preset number of first identifications according to the sequence from small to large of the times of the set entry, and selecting a preset number of second identifications according to the sequence; and determining the selected first identifier and the second identifier as target identifiers to be classified into a target identifier set matched with the identifier list.
In some embodiments, the update unit is further configured to: for each updated identifier list, determining the times of the set entry matched with each identifier in the identifier list; in response to determining that the first identifier does not exist in the identifier list, sorting the identifiers in the identifier list according to the sequence of the times of the sets from small to large; and selecting the identifiers meeting the preset conditions as target identifiers according to the sequence so as to be included in a target identifier set matched with the identifier list.
In some embodiments, the update unit is further configured to: and increasing the times of putting the target identifications into the set matched with the target identifications in the generated target identification set by a preset value.
In a third aspect, an embodiment of the present application provides a load balancing system, where the system includes: the system comprises a load balancing server, a storage server, a client and a server cluster consisting of a plurality of servers, wherein the plurality of servers comprise preset servers; the load balancing server is used for determining the theme of the message which is processed by the server and the identification of the client which is connected with the server and subscribes to the message of the theme so as to generate at least one identification list which corresponds to the server and is divided according to the theme; for each generated identification list, extracting a preset identification list corresponding to the identification list, updating the identification list based on the preset identification list in response to determining that the identification list is not matched with the preset identification list, and analyzing the IP address of the client indicated by the identification in the updated identification list to generate a target identification set; sending each generated target identification set to a storage server; the storage server is used for responding to a load result acquisition request sent by the preset server and sending each target identification set to the preset server; the preset server is used for responding to a server cluster information acquisition request sent by the client and sending server cluster information containing each target identification set to the client; and the client is used for establishing connection with the servers in the corresponding server cluster based on the target identification set.
According to the load balancing method, the load balancing device and the load balancing system, the theme of the message which is processed by each server in the server cluster is determined, and the identification of the client which is connected with the server and subscribes to the message of the theme is determined, so that at least one identification list which corresponds to the server and is divided according to the theme is generated; then extracting a preset identification list corresponding to each identification list, updating the identification list based on the mismatching between the identification list and the corresponding preset identification list, and analyzing the IP address of the client indicated by the identification in the updated identification list to generate a target identification set; and finally, sending each generated target identification set to a storage server so that the storage server sends each target identification set to a preset server when receiving a load result acquisition request sent by the preset server. Therefore, load distribution can be carried out based on the analysis of the IP address, so that the number of connections which are deployed across machine rooms and data centers is reduced, and the connection establishing efficiency is improved; meanwhile, the identification list can be updated based on the comparison between the identification list and the preset identification list, so that load distribution is performed, and the connection stability is improved.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram of one embodiment of a load balancing method according to the present application;
FIG. 3 is an exploded flow diagram of the processing steps for the list of identifications in the flow diagram of FIG. 2;
FIG. 4 is a schematic diagram of an application scenario of a load balancing method according to the present application;
FIG. 5 is a schematic block diagram of one embodiment of a load balancing apparatus according to the present application;
FIG. 6 is a schematic diagram of an interaction process between devices in a load balancing system according to the present application;
FIG. 7 is a block diagram of a computer system suitable for use in implementing a server according to embodiments of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 shows an exemplary system architecture 100 to which the load balancing method or load balancing apparatus of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include a load balancing server 101, a storage server 103, a server cluster 105, terminal devices 110, 111, 112, and networks 102, 104, 109. The server cluster 105 includes servers 106, 107, and 108. Networks 102, 104, 109 may be used to provide a medium for communication links between load balancing server 101 and storage server 103, between storage server 103 and server cluster 105, and between server cluster 105 and end devices 110, 111, 112, respectively. The networks 102, 104, 109 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
The load balancing server 101 may be a server that provides load balancing services for the server cluster 105. The load balancing server 101 may determine the identities of the clients that have established connections with the respective servers in the server cluster 105, perform processes such as list partitioning, list updating, and the like on the determined identities, and send the load balancing result (e.g., the target identity set) to the storage server 103 through the network 102.
The storage server 103 may be configured to store the load balancing result sent by the load balancing server 101, and the storage server 103 may provide a distributed application coordination service.
The servers 106, 107, 108 in the server cluster 105 may be message processing servers that provide message processing services. The message processing server may be responsible for processing messages of a plurality of subjects, and each message processing server may be constituted by a plurality of servers, for example, may be constituted by a master server and a slave server. The master server may perform operations such as reading and writing on messages sent by the terminal devices 110, 111, and 112, and the slave server may be used to synchronize data in the master server or read synchronized data when the master server fails. Here, each message processing server may be composed of one master server and any number of slave servers, and is not limited herein. In addition, one or more of the servers 106, 107, and 108 may be used as a preset server, the preset server may also monitor the load balancing result stored in the storage server 103, and when the update of the load balancing result stored in the storage server 103 is monitored, a load result obtaining request may be sent to the storage server 103 through the network 104, so as to obtain the current load balancing result.
The terminal devices 110, 111, and 112 may send a server cluster information obtaining request to a preset server in the server cluster 105 through the network 109 to obtain a load balancing result, and establish a connection with a corresponding server in the server cluster 105 based on the load balancing result. After establishing the connection, the user may use the terminal devices 110, 111, 112 to interact with the respective servers in the server cluster 105 via the network 109 to receive or send messages or the like. The terminal devices 110, 111, 112 may have installed thereon various communication client applications, such as a web browser application, a shopping-like application, a search-like application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 110, 111, 112 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
It should be noted that the load balancing method provided in the embodiment of the present application is generally executed by the load balancing server 101, and accordingly, the load balancing apparatus is generally disposed in the load balancing server 101.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of load balancing servers, storage servers, server clusters, terminal devices, and networks, and any number of servers may be included in a server cluster.
With continued reference to fig. 2, a flow 200 of one embodiment of a load balancing method according to the present application is shown. The load balancing method comprises the following steps:
step 201, for each server in the server cluster, determining a topic of a message which the server is responsible for processing, and determining an identifier of a client which has established a connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list which corresponds to the server and is divided according to the topic.
In this embodiment, an electronic device (e.g., the load balancing server 101 shown in fig. 1) on which the load balancing method operates may obtain client information of a client that has established a connection with at least one server in a server cluster (e.g., the server cluster 105 shown in fig. 1) from a database for storing client-side information. The database may be a local database of the electronic device, or may be a database connected to the electronic device and installed on another device. The client information may include an IP (Internet Protocol) address of the client, a client name, a client identifier (for example, a character string for uniquely identifying the client, which is formed by arbitrary characters), a topic (topic) of a message subscribed by the client, and the like. In practice, each topic may be used to indicate a type of message, e.g., a page view log, a click log, etc., may exist in the form of a topic.
In this embodiment, the electronic device may store server information of each server in the server cluster in advance, where the server information may include a server identifier (for example, a character string composed of a server name and a serial number), an IP address of the server, a subject of a message handled by the server, and the like. For each server in the server cluster, the electronic device may determine, based on the acquired client information, a topic of a message that the server is responsible for processing, and determine an identifier of a client that has established a connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list that corresponds to the server and is divided by topic.
As an example, for a certain server in the above server cluster, the topic of the message that the server is responsible for processing contains a first topic and a second topic. The clients which are connected with the server and subscribe the message of the first theme are respectively a first client, a second client and a third client, and the clients which are connected with the server and subscribe the message of the second theme are respectively a third client, a fourth client and a fifth client. The electronic device may generate two identification lists (a first identification list and a second identification list, respectively) corresponding to the server and divided according to the first theme and the second theme. The first identifier list corresponding to the first theme may include identifiers of three clients, namely, a first client, a second client, and a third client, and the second identifier list corresponding to the second theme may include identifiers of three clients, namely, a third client, a fourth client, and a fifth client.
It should be noted that each generated identification list corresponding to the server may have a server identification of the server and a corresponding topic identification, the topic identification may be used to indicate and distinguish topics, and each topic identification may be a character string formed by any character. Taking the above example as an example, the first identification list may have a server identification of the server and a topic identification for indicating the first topic, and the second identification list may have a server identification of the server and a topic identification for indicating the second topic.
Step 202, for each generated identification list, extracting a preset identification list corresponding to the identification list, in response to determining that the identification list is not matched with the preset identification list, updating the identification list based on the preset identification list, and analyzing the IP address of the client indicated by the identification in the updated identification list to generate a target identification set.
In this embodiment, for the processing of each generated identification list, further reference may be made to fig. 3, where fig. 3 is an exploded flowchart of the above step 202. In fig. 3, the control step is broken down into 3 sub-steps as follows: step 2021, step 2022 and step 2023.
At step 2021, for each generated identifier list, a preset identifier list corresponding to the identifier list is extracted.
In this embodiment, for each generated identifier list, the electronic device may first extract a preset identifier list corresponding to the identifier list, where the preset identifier list corresponding to the identifier list may be a preset identifier list with the same server identifier and the same subject identifier. It should be noted that the electronic device may periodically execute the load balancing method including steps 201 to 203, and the preset identifier list may be an identifier list generated by the electronic device in the last execution of the load balancing method. Before the electronic device executes the load balancing method for the first time, each client subscribing to a message of a certain topic may establish a connection with all servers in the server cluster responsible for processing the message of the topic, and therefore, before the load balancing method is executed for the first time, an initial preset identifier list, which is corresponding to each server and divided by the topic, may be established and stored in the electronic device in advance based on a connection condition between the client and the server.
In response to determining that the list of identifications does not match the list of preset identifications, step 2022 updates the list of identifications based on the list of preset identifications.
In this embodiment, after the preset identifier list is extracted, the electronic device may first perform a comparison between the identifier list and the preset identifier list to determine whether the identifier list matches with the preset identifier list. Specifically, the electronic device may determine whether each identifier described in the identifier list is described in the preset identifier list, determine whether the number of identifiers described in the identifier list is identical to the number of identifiers described in the preset identifier list if the identifier list is described in the preset identifier list, and determine that the identifier list matches the preset identifier list if the number of identifiers is identical to the number of identifiers described in the preset identifier list. If there is an identifier not listed in the preset identifier list in the identifier list, or if the number of identifiers listed in the identifier list does not match the number of identifiers listed in the preset identifier list, it can be determined that the identifier list does not match the preset identifier list. As an example, the identifiers described in the identifier list are sequentially identifier "a", identifier "B" and identifier "C", and if the identifiers described in the preset identifier list are sequentially identifier "C", identifier "B" and identifier "a", it may be determined that the identifier list matches the preset identifier list; if the identifiers described in the preset identifier list are the identifier "a", the identifier "B", the identifier "C", and the identifier "D" in this order, it can be determined that the identifier list does not match the preset identifier list.
In this embodiment, in response to determining that the identifier list does not match the preset identifier list, the electronic device may update the identifier list based on the preset identifier list in various updating manners. As an example, in response to determining that the identifier list does not match the preset identifier list, the electronic device may first delete identifiers in the preset identifier list that are not listed in the identifier list; then, the identifiers which are not recorded in the preset identifier list in the identifier list can be extracted; and then, inserting the extracted identifications into the preset identification list one by one. As an example, the identifiers recorded in the identifier list are sequentially an identifier "a", an identifier "B", an identifier "D", an identifier "E", and an identifier "F"; the identifiers described in the preset identifier list corresponding to the identifier list are the identifier "a", the identifier "B", the identifier "C", and the identifier "D" in this order. The electronic device may delete the identifier "C" in the preset identifier list first; then, extracting the mark 'E' and the mark 'F' which are not recorded in the preset mark list in the mark list; then, the mark "E" is inserted into the position of the original mark "C" in the preset mark list, and the mark "F" is inserted behind the mark "D" in the preset mark list.
It should be noted that, after updating the identifier list, the electronic device may store the updated identifier list in a cache, so as to extract the stored identifier list as a preset list in a process of next executing the load balancing method.
Step 2023, the IP address of the client indicated by the identifier in the updated identifier list is resolved to generate a target identifier set.
In this embodiment, the electronic device may first extract, from the client information obtained in step 201, an updated IP address of the client indicated by each identifier in the identifier list. Then, the electronic device may parse the extracted IP address of the client, and determine a target identifier in the identifier list according to a parsing result to generate a target identifier set. It should be noted that, after each identification list is processed, a corresponding target identification set may be generated, so that a plurality of target identification sets may be obtained.
In this embodiment, the electronic device may analyze the extracted IP address of the client in various analysis manners, and determine the target identifier in the identifier list according to an analysis result to generate a target identifier set. As an example, after obtaining the updated identifier list and extracting the IP addresses of the clients indicated by the identifiers in the identifier list, the electronic device may first parse the extracted IP addresses of the clients to determine the network segments corresponding to the IP addresses of the clients. Then, the determined network segments can be matched with the preset network segments corresponding to the identifier list, the identifiers of the clients corresponding to the network segments matched with the preset network segments in the specified number and the identifiers of the clients corresponding to the network segments unmatched with the preset network segments in the specified number are respectively extracted, and the extracted identifiers of the clients are used as target identifiers to be classified into a target identifier set. It should be noted that each server in the server cluster may correspond to a preset network segment, and the electronic device may store a preset mapping table between the server and the preset network segment, and determine the preset network segment corresponding to the identifier list based on the mapping table.
In some optional implementations of this embodiment, in response to determining that the identifier list does not match the preset identifier list, the electronic device may first extract the same identifier in the identifier list and the preset identifier list and an order of the same identifier in the preset identifier list, where the same identifier may be an identifier recorded in both the identifier list and the preset identifier list; then, the electronic device may store the same identifier in the order to a temporary identifier list established in advance; then, the identifiers in the identifier list except the same identifier can be inserted into the temporary identifier list; finally, the list of identifications may be replaced with the temporary list of identifications to update the list of identifications. As an example, the identifiers recorded in the identifier list are sequentially an identifier "a", an identifier "B", an identifier "D", an identifier "E", and an identifier "F"; the identifiers described in the preset identifier list corresponding to the identifier list are the identifier "a", the identifier "B", the identifier "C", and the identifier "D" in this order. The electronic device may first extract the same identifier (identifier "a", identifier "B", and identifier "D") in the identifier list and the preset identifier list and the order of the same identifier in the preset identifier list (i.e., 1, 2, and 4, respectively). Then, the extracted identifier "a" may be stored at a position of temporary identifier list order 1, the extracted identifier "B" may be stored at a position of temporary identifier list order 2, and the extracted identifier "D" may be stored at a position of temporary identifier list order 4. Then, the electronic device may extract identifiers (i.e., identifier "E" and identifier "F") other than the same identifier in the identifier list, insert identifier "E" into the position with the order of 3 in the temporary identifier list, and insert identifier "F" into the position with the order of 5 in the temporary identifier list. Finally, the electronic device may replace the identifier list with the temporary identifier list to update the identifier list.
In some optional implementations of this embodiment, after obtaining the updated identification list, the electronic device may first extract, from the stored server information, an IP address of a server in the server cluster corresponding to the identification list. In practice, the electronic device may read the server identifier carried in the identifier list, and query the IP address of the server from the stored server information based on the server identifier. Then, the electronic device may determine the extracted IP address of the server as a target IP address, and determine whether the extracted IP address of each client and the target IP address correspond to the same machine room identifier based on a preset mapping table of IP addresses and machine room identifiers. Then, the electronic device may determine an IP address of the same machine room identifier as the target IP address in the extracted IP addresses of the clients, and determine an identifier of the client corresponding to the determined IP address as a first identifier; meanwhile, the electronic device may determine, as the second identifier, an identifier of the client whose IP and the target IP address correspond to different machine room identifiers. Then, the electronic device may select a preset number (e.g., 1, 2, etc.) of first identifiers and a preset number of second identifiers in the identifier list, and determine the selected first identifiers and the selected second identifiers as target identifiers to be included in a target identifier set matching the identifier list.
In some optional implementations of this embodiment, after obtaining the updated identifier list, the electronic device may first determine the number of times of grouping that matches each identifier in the identifier list. The number of times of putting into the set matched with each identifier may be a number indicating a target identifier set into which the identifier is put. Each client may subscribe to messages of multiple topics, and the subscribed messages of multiple topics may be processed by multiple servers, so that the client may be connected to multiple servers, and each server in the server cluster may correspond to multiple identification lists divided by topics, and each identification list may correspond to one target identification set, so that the identification of the client may be categorized as a target identification into one or more target identification sets. The number of times of putting in the set matched with the identification of the client can be increased by 1 every time the target identification set is put in. It should be noted that, before each time the load balancing method is executed, the electronic device may set an initial value of the number of times of putting into the set that matches the identifier of each client to zero. Then, the electronic device may select a preset number (e.g., 1, 2, etc.) of first identifiers in an order from a small number to a large number of times of grouping, and select the preset number of second identifiers in the order. Finally, the selected first and second identities may be determined as target identities to be included in a set of target identities matching the list of identities.
In some optional implementations of this embodiment, after obtaining the updated identifier list, the electronic device may first determine the number of times of grouping that matches each identifier in the identifier list. Then, in response to determining that the first identifier does not exist in the identifier list, the identifiers in the identifier list may be sorted in order of the number of times of grouping from small to large. And finally, selecting the identifiers meeting the preset conditions as target identifiers according to the sequence so as to be included in a target identifier set matched with the identifier list. The preset condition may be various conditions, for example, the identifier is located in the first three digits of each sorted identifier, and the number of times of the set entry matched with the identifier is smaller than the preset number of times.
In some optional implementation manners of this embodiment, after determining the selected first identifier and the second identifier as target identifiers to be included in a target identifier set matching the identifier list, for each target identifier set, the electronic device may further extract a number of times of including the selected first identifier and the selected second identifier in the target identifier set, and increase the number of times of including the selected first identifier and the selected second identifier by a preset value. In practice, this preset value is 1.
Step 203, sending each generated target identifier set to a storage server, so that the storage server sends each target identifier set to a preset server when receiving a load result obtaining request sent by the preset server.
In this embodiment, the electronic device may send each generated target identifier set to a storage server (e.g., the storage server 103 shown in fig. 1), so that the storage server sends each target identifier set to a preset server when receiving a load result obtaining request sent by the preset server (e.g., one or more servers in the server cluster 105 shown in fig. 1).
With continued reference to fig. 4, fig. 4 is a schematic diagram of an application scenario of the load balancing method according to the present embodiment. In the application scenario of fig. 4, the load balancing server 401 first determines a topic of a message handled by each server in a server cluster formed by a first server and a second server, generates a plurality of identification lists corresponding to the first server and divided by the topic, and generates a plurality of identification lists corresponding to the second server and divided by the topic. Then, the load balancing server 401 performs operations of extracting a preset identifier list, matching the preset identifier list, updating the identifier list, and analyzing the IP address of the client indicated by the identifier in the identifier list on each generated identifier list in sequence, so as to generate a target identifier set corresponding to the identifier list. Finally, the load balancing server 401 sends each generated target identifier set 402 to the storage server 403, and when the preset server 404 sends a load result obtaining request to the storage server 403, the storage server 403 sends each target identifier set 402 to the preset server 404.
In the method provided by the above embodiment of the present application, by determining a topic of a message that each server in a server cluster is responsible for processing, and determining an identifier of a client that has established a connection with the server and has subscribed to the message of the topic, at least one identifier list that corresponds to the server and is divided according to the topic is generated; then extracting a preset identification list corresponding to each identification list, updating the identification list based on the mismatching between the identification list and the corresponding preset identification list, and analyzing the IP address of the client indicated by the identification in the updated identification list to generate a target identification set; and finally, sending each generated target identification set to a storage server so that the storage server sends each target identification set to a preset server when receiving a load result acquisition request sent by the preset server. Therefore, load distribution can be carried out based on the analysis of the IP address, so that the number of connections which are deployed across machine rooms and data centers is reduced, and the connection establishing efficiency is improved; meanwhile, the identification list can be updated based on the comparison between the identification list and the preset identification list, so that load distribution is performed, and the connection stability is improved.
With further reference to fig. 5, as an implementation of the methods shown in the above-mentioned figures, the present application provides an embodiment of a load balancing apparatus, which corresponds to the embodiment of the method shown in fig. 2. The device can be applied to various electronic equipment.
As shown in fig. 5, the load balancing apparatus 500 according to this embodiment includes: a generating unit 501, configured to determine, for each server in the server cluster, a topic of a message that the server is responsible for processing, and determine an identifier of a client that has established a connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list that corresponds to the server and is divided according to the topic; an updating unit 502 configured to, for each generated identification list, extract a preset identification list corresponding to the identification list, and in response to determining that the identification list does not match the preset identification list, update the identification list based on the preset identification list; analyzing the IP address of the client indicated by the identifier in the updated identifier list to generate a target identifier set; a sending unit 503, configured to send each generated target identifier set to the storage server, so that the storage server sends each target identifier set to the preset server when receiving the load result obtaining request sent by the preset server.
In this embodiment, for each server in the server cluster, the generating unit 501 may determine, based on the obtained client information, a topic of a message that the server is responsible for processing, and determine an identifier of a client that has established a connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list that is divided by topic and corresponds to the server.
In this embodiment, for each generated identifier list, the updating unit 502 may first extract a preset identifier list corresponding to the identifier list, where the preset identifier list corresponding to the identifier list may be a preset identifier list with the same server identifier and the same subject identifier. Then, the identifier list may be compared with the preset identifier list to determine whether the identifier list matches with the preset identifier list. In response to determining that the identifier list does not match the preset identifier list, the updating unit 502 may update the identifier list based on the preset identifier list using various updating methods. Then, the updating unit 502 may first extract the IP addresses of the clients indicated by the identifiers in the updated identifier list, may analyze the extracted IP addresses of the clients by using various analysis methods, and determine the target identifiers in the identifier list according to the analysis result to generate the target identifier set.
In some optional implementations of this embodiment, the updating unit 502 may be further configured to, for each generated identifier list, extract a preset identifier list corresponding to the identifier list, and in response to determining that the identifier list does not match the preset identifier list, extract the same identifier in the identifier list and the preset identifier list and an order of the same identifier in the preset identifier list; storing the same identification to a pre-established temporary identification list in the sequence; inserting the identifiers in the identifier list except the same identifier into the temporary identifier list; and replacing the identification list with the temporary identification list to update the identification list.
In some optional implementation manners of this embodiment, the updating unit 502 may be further configured to, for each updated identifier list, extract an IP address of a client indicated by each identifier in the identifier list, extract an IP address of a server in the server cluster corresponding to the identifier list, and determine the extracted IP address of the server as a target IP address; determining whether the extracted IP address of each client and the target IP address correspond to the same machine room identifier or not based on a preset mapping table of the IP address and the machine room identifier; determining the identification of the client with the same machine room identification corresponding to the IP address and the target IP address as a first identification, and determining the identification of the client with the different machine room identifications corresponding to the IP address and the target IP address as a second identification; and selecting a preset number of first identifications and a preset number of second identifications in the identification list, and determining the selected first identifications and the selected second identifications as target identifications to be classified into a target identification set matched with the identification list.
In some optional implementation manners of this embodiment, the updating unit 502 may be further configured to determine, for each updated identifier list, a number of times of grouping sets that is matched with each identifier in the identifier list; selecting a preset number of first identifications according to the sequence from small to large of the times of the set entry, and selecting the preset number of second identifications according to the sequence; and determining the selected first identifier and the second identifier as target identifiers to be classified into a target identifier set matched with the identifier list.
In some optional implementation manners of this embodiment, the updating unit 502 may be further configured to determine, for each updated identifier list, a number of times of grouping sets that is matched with each identifier in the identifier list; in response to determining that the first identifier does not exist in the identifier list, sorting the identifiers in the identifier list according to the sequence of the times of the sets from small to large; and selecting the identifiers meeting the preset conditions as target identifiers according to the sequence so as to be included in a target identifier set matched with the identifier list.
In some embodiments, the updating unit 502 may be further configured to increase the number of times of grouping into a set, which is matched with each target identifier in the generated target identifier set, by a preset value.
In this embodiment, the sending unit 503 may send each generated target identifier set to a storage server (e.g., the storage server 103 shown in fig. 1), so that the storage server sends each target identifier set to a preset server when receiving a load result obtaining request sent by the preset server (e.g., one or more servers in the server cluster 105 shown in fig. 1).
The apparatus provided in the foregoing embodiment of the present application determines, by the generating unit 501, a topic of a message that each server in a server cluster is responsible for processing, and determines an identifier of a client that has established a connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list that corresponds to the server and is divided by topic; then, the updating unit 502 extracts the preset identifier list corresponding to each identifier list, updates the identifier list based on the mismatch between the identifier list and the corresponding preset identifier list, and analyzes the IP address of the client indicated by the identifier in the updated identifier list to generate a target identifier set; finally, the sending unit 503 sends each generated target identifier set to the storage server, so that the storage server sends each target identifier set to the preset server when receiving the load result obtaining request sent by the preset server. Therefore, load distribution can be carried out based on the analysis of the IP address, so that the number of connections which are deployed across machine rooms and data centers is reduced, and the connection establishing efficiency is improved; meanwhile, the identification list can be updated based on the comparison between the identification list and the preset identification list, so that load distribution is performed, and the connection stability is improved.
With further reference to fig. 6, a schematic diagram 600 of an interaction process between devices in a load balancing system according to the present application is shown.
The system comprises a load balancing server, a storage server, a client and a server cluster consisting of a plurality of servers, wherein the plurality of servers comprise preset servers. The load balancing server is configured to determine, for each server in the server cluster, a topic of a message that the server is responsible for processing, and determine an identifier of a client that has established a connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list that is corresponding to the server and is divided according to the topic; for each generated identification list, extracting a preset identification list corresponding to the identification list, and updating the identification list based on the preset identification list in response to determining that the identification list is not matched with the preset identification list; analyzing the IP address of the client indicated by the identifier in the updated identifier list to generate a target identifier set; and sending each generated target identification set to the storage server. And the storage server is used for responding to a load result acquisition request sent by the preset server and sending each target identifier set to the preset server. The preset server is used for responding to a server cluster information acquisition request sent by a client and sending each target identification set to the client. And the client is used for establishing connection with the server in the corresponding server cluster based on the target identification set.
As shown in fig. 6, in the load balancing system, the interaction process 600 between the devices may include the following steps:
step 601, the load balancing server determines, for each server in the server cluster, a topic of a message that the server is responsible for processing, and determines an identifier of a client that has established a connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list that corresponds to the server and is divided by topic.
In this embodiment, for each server in the server cluster, the load balancing server may determine, based on the obtained client information, a topic of a message that the server is responsible for processing, and determine an identifier of a client that has established a connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list that is divided by topic and corresponds to the server.
Step 602, the load balancing server extracts a preset identifier list corresponding to each generated identifier list, updates the identifier list based on the preset identifier list in response to determining that the identifier list is not matched with the preset identifier list, and parses the internet protocol IP address of the client indicated by the identifier in the updated identifier list to generate a target identifier set.
In this embodiment, for each generated identifier list, the load balancing server may first extract a preset identifier list corresponding to the identifier list. Then, the comparison between the identifier list and the preset identifier list may be performed to determine whether the identifier list matches with the preset identifier list. Finally, the IP address of the client indicated by each identifier in the updated identifier list may be extracted first, the extracted IP address of the client is analyzed in various analysis manners, and according to the analysis result, the target identifier in the identifier list is determined to generate a target identifier set. It should be noted that, after each identification list is processed, a corresponding target identification set may be generated, so that a plurality of target identification sets may be obtained.
Step 603, the load balancing server sends each generated target identifier set to the storage server.
In this embodiment, the load balancing server may send each generated target identifier set to the storage server.
In step 604, the storage server sends each target identifier set to a preset server in response to receiving a load result obtaining request sent by the preset server.
In this embodiment, the storage server may send each target identifier set to the preset server in response to receiving the load result obtaining request sent by the preset server. In practice, the preset server may monitor the update of the target identifier set stored in the storage server, and when the preset server monitors the update, the preset server may send a load result obtaining request to the storage server.
Step 605, the preset server sends, in response to receiving the server cluster information acquisition request sent by the client, server cluster information including each target identifier set to the client.
In this embodiment, the preset server sends, to the client, the server cluster information including each target identifier set in response to receiving the server cluster information acquisition request sent by the client. The number of the clients can be one or more. The server cluster information obtaining request may include a subject of the message requested to be obtained by the client. The server cluster information may further include server information of each server in the server cluster, such as an IP address of the server, a server identifier, and the like.
Step 606, the client establishes a connection with the server in the corresponding server cluster based on the target identifier set.
In this embodiment, the client may determine a server in the server cluster to be connected based on the target identification set, and establish a connection with the determined server. In practice, if the server to be connected is not determined based on the target identifier set, the topic of the message included in the sent cluster information acquisition request may be determined as the target topic, and a connection may be established with all servers in the server cluster that are responsible for processing the message of the target topic.
In the system provided by the above embodiment of the present application, a target identifier set is generated by a load balancing server, and each generated target identifier set is sent to a storage server; the storage server sends each target identification set to a preset server when receiving a load result acquisition request sent by the preset server; the preset server responds to a received server cluster information acquisition request sent by the client and sends each target identification set to the client; and the client establishes connection with the corresponding server in the server cluster based on the target identification set. Therefore, load distribution can be carried out based on the analysis of the IP address, so that the number of connections which are deployed across machine rooms and data centers is reduced, and the connection establishing efficiency is improved; meanwhile, the identification list can be updated based on the comparison between the identification list and the preset identification list, so that load distribution is performed, and the connection stability is improved.
Referring now to FIG. 7, shown is a block diagram of a computer system 700 suitable for use in implementing a server according to embodiments of the present application. The server shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 7, the computer system 700 includes a Central Processing Unit (CPU)701, which can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage section 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
The following components are connected to the I/O interface 705: an input portion 706 including a keyboard, a mouse, and the like; an output section 707 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 708 including a hard disk and the like; and a communication section 709 including a network interface card such as a LAN card, a modem, or the like. The communication section 709 performs communication processing via a network such as the internet. A drive 710 is also connected to the I/O interface 705 as needed. A removable medium 711 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 710 as necessary, so that a computer program read out therefrom is mounted into the storage section 708 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 709, and/or installed from the removable medium 711. The computer program, when executed by a Central Processing Unit (CPU)701, performs the above-described functions defined in the method of the present application. It should be noted that the computer readable medium described herein can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a generation unit, an update unit, and a transmission unit. Where the names of these units do not in some cases constitute a limitation on the unit itself, for example, a generating unit may also be described as a "unit that generates an identification list".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be present separately and not assembled into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to: for each server in the server cluster, determining a topic of a message which is processed by the server, and determining an identifier of a client which has established connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list which corresponds to the server and is divided according to the topic; for each generated identification list, extracting a preset identification list corresponding to the identification list, and updating the identification list based on the preset identification list in response to determining that the identification list does not match the preset identification list; analyzing the IP address of the client indicated by the identifier in the updated identifier list to generate a target identifier set; and sending the generated target identification sets to a storage server.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention herein disclosed is not limited to the particular combination of features described above, but also encompasses other arrangements formed by any combination of the above features or their equivalents without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (15)

1. A load balancing method for a load balancing server is characterized in that the load balancing server is in communication connection with a storage server, the storage server is in communication connection with each server in a server cluster, the server cluster comprises preset servers, and the method comprises the following steps:
for each server in the server cluster, determining a topic of a message which is processed by the server, and determining an identifier of a client which has established connection with the server and subscribed to the message of the topic, so as to generate at least one identifier list which corresponds to the server and is divided according to the topic;
for each generated identification list, extracting a preset identification list corresponding to the identification list, in response to determining that the identification list does not match the preset identification list, updating the identification list based on the preset identification list, resolving the internet protocol IP address of the client indicated by the identifier in the updated list of identifiers, and according to the analysis result, determining the target identifiers in the identifier list to generate a target identifier set corresponding to each identifier list, wherein the preset identification list is an initial preset identification list which is pre-stored, corresponds to the server and is divided according to the theme, the matching of the identification list and the preset identification list is used for representing and comparing each identification recorded in the identification list with each identification recorded in the preset identification list;
and sending each generated target identification set to the storage server so that the storage server sends each target identification set to the preset server when receiving a load result acquisition request sent by the preset server.
2. The method of claim 1, wherein for each generated identifier list, extracting a preset identifier list corresponding to the identifier list, and in response to determining that the identifier list does not match the preset identifier list, updating the identifier list based on the preset identifier list comprises:
for each generated identification list, extracting a preset identification list corresponding to the identification list, and in response to determining that the identification list is not matched with the preset identification list, extracting the same identification in the identification list and the preset identification list and the sequence of the same identification in the preset identification list; storing the same identification to a pre-established temporary identification list in the sequence; inserting the identifiers in the identifier list except the same identifier into the temporary identifier list; replacing the list of identities with the temporary list of identities to update the list of identities.
3. The method for load balancing according to one of claims 1 to 2, wherein the parsing the IP address of the client indicated by the identifier in the updated identifier list to generate the target identifier set includes:
for each updated identification list, extracting the IP address of the client indicated by each identification in the identification list, extracting the IP address of the server corresponding to the identification list in the server cluster, and determining the extracted IP address of the server as a target IP address; determining whether the extracted IP address of each client and the target IP address correspond to the same machine room identifier or not based on a preset mapping table of the IP address and the machine room identifier; determining the identification of the client with the same machine room identification corresponding to the IP address and the target IP address as a first identification, and determining the identification of the client with the different machine room identifications corresponding to the IP address and the target IP address as a second identification; and selecting a preset number of first identifications and a preset number of second identifications in the identification list, and determining the selected first identifications and the selected second identifications as target identifications to be classified into a target identification set matched with the identification list.
4. The load balancing method according to claim 3, wherein the selecting a preset number of first identifiers and a preset number of second identifiers in the identifier list, and determining the selected first identifiers and the selected second identifiers as target identifiers to be included in a target identifier set matching the identifier list comprises:
for each updated identifier list, determining the times of the set entry matched with each identifier in the identifier list; selecting a preset number of first identifications according to the sequence from small to large of the times of the set entry, and selecting a preset number of second identifications according to the sequence; and determining the selected first identifier and the second identifier as target identifiers to be classified into a target identifier set matched with the identifier list.
5. The load balancing method according to claim 3, wherein the selecting a preset number of first identifiers and a preset number of second identifiers in the identifier list, and determining the selected first identifiers and the selected second identifiers as target identifiers to be included in a target identifier set matching the identifier list comprises:
for each updated identifier list, determining the times of the set entry matched with each identifier in the identifier list; in response to determining that the first identifier does not exist in the identifier list, sorting the identifiers in the identifier list according to the sequence of the times of the sets from small to large; and selecting the identifiers meeting the preset conditions as target identifiers according to the sequence so as to be included in a target identifier set matched with the identifier list.
6. The method for load balancing according to one of claims 4 to 5, wherein the parsing the IP address of the client indicated by the identifier in the updated identifier list to generate the target identifier set further comprises:
and increasing the times of putting the target identifications into the set matched with the target identifications in the generated target identification set by a preset value.
7. A load balancing device for a load balancing server, wherein the load balancing server is in communication connection with a storage server, the storage server is in communication connection with each server in a server cluster, the server cluster comprises a preset server, and the device comprises:
the generating unit is configured to determine, for each server in the server cluster, a topic of a message which the server is responsible for processing, and determine an identifier of a client which has established connection with the server and has subscribed to the message of the topic, so as to generate at least one identifier list which corresponds to the server and is divided by topic;
an updating unit configured to, for each generated identification list, extract a preset identification list corresponding to the identification list, update the identification list based on the preset identification list in response to determining that the identification list does not match the preset identification list, the IP address of the client indicated by the identifier in the updated identifier list is resolved, and according to the analysis result, determining the target identifiers in the identifier list to generate a target identifier set corresponding to each identifier list, wherein the preset identification list is an initial preset identification list which is pre-stored, corresponds to the server and is divided according to the theme, the matching of the identification list and the preset identification list is used for representing and comparing each identification recorded in the identification list with each identification recorded in the preset identification list;
and the sending unit is configured to send each generated target identifier set to the storage server, so that the storage server sends each target identifier set to the preset server when receiving a load result acquisition request sent by the preset server.
8. The load balancing apparatus according to claim 7, wherein the updating unit is further configured to:
for each generated identification list, extracting a preset identification list corresponding to the identification list, and in response to determining that the identification list is not matched with the preset identification list, extracting the same identification in the identification list and the preset identification list and the sequence of the same identification in the preset identification list; storing the same identification to a pre-established temporary identification list in the sequence; inserting the identifiers in the identifier list except the same identifier into the temporary identifier list; replacing the list of identities with the temporary list of identities to update the list of identities.
9. Load balancing device according to one of the claims 7 to 8, wherein the updating unit is further configured to:
for each updated identification list, extracting the IP address of the client indicated by each identification in the identification list, extracting the IP address of the server corresponding to the identification list in the server cluster, and determining the extracted IP address of the server as a target IP address; determining whether the extracted IP address of each client and the target IP address correspond to the same machine room identifier or not based on a preset mapping table of the IP address and the machine room identifier; determining the identification of the client with the same machine room identification corresponding to the IP address and the target IP address as a first identification, and determining the identification of the client with the different machine room identifications corresponding to the IP address and the target IP address as a second identification; and selecting a preset number of first identifications and a preset number of second identifications in the identification list, and determining the selected first identifications and the selected second identifications as target identifications to be classified into a target identification set matched with the identification list.
10. The load balancing apparatus according to claim 9, wherein the updating unit is further configured to:
for each updated identifier list, determining the times of the set entry matched with each identifier in the identifier list; selecting a preset number of first identifications according to the sequence from small to large of the times of the set entry, and selecting a preset number of second identifications according to the sequence; and determining the selected first identifier and the second identifier as target identifiers to be classified into a target identifier set matched with the identifier list.
11. The load balancing apparatus according to claim 9, wherein the updating unit is further configured to:
for each updated identifier list, determining the times of the set entry matched with each identifier in the identifier list; in response to determining that the first identifier does not exist in the identifier list, sorting the identifiers in the identifier list according to the sequence of the times of the sets from small to large; and selecting the identifiers meeting the preset conditions as target identifiers according to the sequence so as to be included in a target identifier set matched with the identifier list.
12. Load balancing device according to one of the claims 10 to 11, wherein the updating unit is further configured to:
and increasing the times of putting the target identifications into the set matched with the target identifications in the generated target identification set by a preset value.
13. A load balancing system, the system comprising: the system comprises a load balancing server, a storage server, a client and a server cluster consisting of a plurality of servers, wherein the plurality of servers comprise preset servers;
the load balancing server is used for determining the theme of the message processed by the server for each server in the server cluster, and determining the identification of the client connected with the server and subscribed to the message of the theme so as to generate at least one identification list which corresponds to the server and is divided according to the theme; for each generated identification list, extracting a preset identification list corresponding to the identification list, responding to the situation that the identification list is not matched with the preset identification list, updating the identification list based on the preset identification list, analyzing the IP address of the client indicated by the identification in the updated identification list, and determining a target identification in the identification list according to the analysis result so as to generate a target identification set corresponding to each identification list, wherein the preset identification list is an initial preset identification list which is prestored and corresponds to the server and is divided according to subjects, and the matching between the identification list and the preset identification list is used for comparing each identification recorded in the identification list with each identification recorded in the preset identification list; sending each generated target identification set to the storage server;
the storage server is used for responding to a load result acquisition request sent by the preset server and sending each target identification set to the preset server;
the preset server is used for responding to a server cluster information acquisition request sent by a client and sending server cluster information containing each target identification set to the client;
and the client is used for establishing connection with the corresponding server in the server cluster based on the target identification set.
14. A load-balancing server, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
15. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN201710216555.3A 2017-04-05 2017-04-05 Load balancing method, device and system Active CN108696549B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710216555.3A CN108696549B (en) 2017-04-05 2017-04-05 Load balancing method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710216555.3A CN108696549B (en) 2017-04-05 2017-04-05 Load balancing method, device and system

Publications (2)

Publication Number Publication Date
CN108696549A CN108696549A (en) 2018-10-23
CN108696549B true CN108696549B (en) 2021-05-25

Family

ID=63841924

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710216555.3A Active CN108696549B (en) 2017-04-05 2017-04-05 Load balancing method, device and system

Country Status (1)

Country Link
CN (1) CN108696549B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110401708B (en) * 2019-07-23 2021-11-23 中南民族大学 Session processing system and method based on server load state

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1585357A (en) * 2003-08-19 2005-02-23 华为技术有限公司 Method for selecting server in network
US7216151B2 (en) * 2002-01-30 2007-05-08 Fujifilm Corporation Computer apparatus and program for controlling same
CN105607951A (en) * 2015-12-17 2016-05-25 北京奇虎科技有限公司 Method and device for processing data request and obtaining server information
US9577892B2 (en) * 2013-04-06 2017-02-21 Citrix Systems, Inc. Systems and methods for providing monitoring in a cluster system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9325785B2 (en) * 2012-06-29 2016-04-26 Rodolfo Kohn Device, system, and method for client-governed session persistency between one or more clients and servers of a data center
US20150058466A1 (en) * 2013-08-21 2015-02-26 Ideaware Inc. Device for server grouping

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7216151B2 (en) * 2002-01-30 2007-05-08 Fujifilm Corporation Computer apparatus and program for controlling same
CN1585357A (en) * 2003-08-19 2005-02-23 华为技术有限公司 Method for selecting server in network
US9577892B2 (en) * 2013-04-06 2017-02-21 Citrix Systems, Inc. Systems and methods for providing monitoring in a cluster system
CN105607951A (en) * 2015-12-17 2016-05-25 北京奇虎科技有限公司 Method and device for processing data request and obtaining server information

Also Published As

Publication number Publication date
CN108696549A (en) 2018-10-23

Similar Documents

Publication Publication Date Title
CN111460129B (en) Method, device, electronic equipment and storage medium for generating identification
US11726987B2 (en) Normalizing user identification across disparate systems
CN108093026B (en) Method and device for processing multi-tenant request
US11244153B2 (en) Method and apparatus for processing information
WO2021023149A1 (en) Method and apparatus for dynamically returning message
CN110851468A (en) Method and device for making simulation response to test request of client
CN111478781B (en) Message broadcasting method and device
CN110321252B (en) Skill service resource scheduling method and device
CN108764866B (en) Method and equipment for allocating resources and drawing resources
CN108696549B (en) Load balancing method, device and system
US8214826B2 (en) Optimized targeting in a large scale system
CN112069137A (en) Method and device for generating information, electronic equipment and computer readable storage medium
CN110401709A (en) Processing method, device and the storage medium of session in a kind of instant messaging application
CN108696557B (en) Information processing system, method and device
CN109214846B (en) Information storage method and device
CN112052152A (en) Simulation test method and device
CN112559001B (en) Method and device for updating application
CN112306984A (en) Data source routing method and device
CN113783826A (en) Micro-service exception handling method and device
CN113760695A (en) Method and device for positioning problem code
CN113556370A (en) Service calling method and device
CN108733668B (en) Method and device for querying data
CN116915870B (en) Task creation request processing method, device, electronic equipment and readable medium
CN113986661A (en) Log output method and device, electronic equipment and storage medium
CN116862604A (en) Data processing method, device, electronic equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant