Disclosure of Invention
The invention aims to provide a message access load balancing method and a message access load balancing system, which solve the problems of low reliability, slow response and the like in the prior art.
The invention is realized by the following technical scheme:
a message access load balancing method specifically comprises the following steps:
step S1, receiving a request message of the intelligent terminal;
step S2, analyzing the request message of the intelligent terminal, and determining the target server node group to which the intelligent terminal belongs;
step S3, judging whether all server nodes in the target server node group are fully loaded, if yes, executing step S4, and if not, executing step S5;
step S4, the request message of the intelligent terminal is sent to an off-line server node for caching, and after the preset time is cached, the step S3 is executed;
and step S5, selecting an optimal server node from the server nodes which are not in the full load state according to the load balancing algorithm, sending the request message of the intelligent terminal to the optimal server node for processing, and returning a response message to the intelligent terminal after the optimal server node processes the request message.
As a further alternative of the message access load balancing method, the method further comprises:
and step S6, monitoring the full load condition of each server node in the target server node group in real time, caching the request message subsequently sent by the intelligent terminal to the offline server node if the server node is in the full load condition, and processing the request message cached in the offline server node after the server node releases the full load condition.
As a further alternative of the message access load balancing method, the method further comprises:
step S7, monitoring the failure condition of each server node in the target server node group in real time, switching the request message processed by the server node to the standby server node when detecting that the server node has a failure, and switching back to the server node from the standby server node after the server node has a failure.
As a further alternative of the message access load balancing method, the step S5 of selecting an optimal server node from the server nodes that are not in a full load state according to a load balancing algorithm includes the following steps:
step S51, calculating the weight value of each server node which is not in a full load state;
and step S52, determining the optimal server node according to the weight value.
As a further alternative of the message access load balancing method, the messages cached to the offline server node include all messages specifying a session, all messages specifying a city, and all messages specifying a server node.
A message access load balancing system, comprising:
the receiving unit is used for receiving the intelligent terminal request message;
the route distribution unit is used for analyzing the received intelligent terminal request message;
the message flow control unit is used for judging whether all server nodes to which the intelligent terminal belongs are fully loaded;
the off-line switching unit is used for sending the request message of the intelligent terminal to an off-line server node for caching;
the load balancing unit is used for calculating an optimal server node according to a load balancing algorithm;
and the sending unit is used for sending the response message of the optimal server node to the intelligent terminal.
As a further alternative to the message access load balancing system, the system further comprises:
and the session management unit is used for monitoring the service session volume of each server node in real time and judging the full load condition of each server node.
As a further alternative to the message access load balancing system, the system further comprises:
and the offline disaster recovery unit is used for judging the fault condition of each server node and realizing the switching between the server nodes and the standby server nodes.
As a further alternative of the message access load balancing system, the load balancing unit includes a storage unit for storing a load balancing algorithm and a judging unit for judging the magnitude of the weight value.
As a further alternative of the message access load balancing system, the messages cached to the offline server nodes include all messages specifying a session, all messages specifying a city, and all messages specifying a server node.
The invention has the beneficial effects that:
by using the method and the system, after the target server node group to which the intelligent terminal belongs is obtained by analyzing the request message of the intelligent terminal, whether all server nodes in the target server node group are full is judged, and then whether the request message of the intelligent terminal is sent to the server nodes is determined, so that the server nodes which are still in the full-load state can be prevented from being selected, the reliability of access can be improved, and the user experience is improved.
Detailed Description
The invention will be described in detail with reference to the drawings and specific embodiments, which are illustrative of the invention and are not to be construed as limiting the invention.
As shown in fig. 1-2, a message access load balancing method specifically includes the following steps:
step S1, receiving a request message of the intelligent terminal;
step S2, analyzing the request message of the intelligent terminal, and determining the target server node group to which the intelligent terminal belongs;
step S3, judging whether all server nodes in the target server node group are fully loaded, if yes, executing step S4, and if not, executing step S5;
step S4, the request message of the intelligent terminal is sent to an off-line server node for caching, and after the preset time is cached, the step S3 is executed;
and step S5, selecting an optimal server node from the server nodes which are not in the full load state according to the load balancing algorithm, sending the request message of the intelligent terminal to the optimal server node for processing, and returning a response message to the intelligent terminal after the optimal server node processes the request message.
In this embodiment, after a target server node group to which an intelligent terminal belongs is obtained by analyzing a request message of the intelligent terminal, it is first determined whether all server nodes in the target server node group are fully loaded, and then it is determined whether the request message of the intelligent terminal is sent to the server nodes, so that the server nodes which are still fully loaded can be prevented from being selected, reliability of access can be improved, and user experience can be improved.
It should be noted that, when all server nodes in the target server node group are in a full load state, server nodes near the target server node group may also be allocated to the target server node group temporarily through the back-end server platform, and when the server nodes originally belonging to the target server node group are relieved from the full load state and have enough space to process the request message of the intelligent terminal, the server nodes temporarily added to the target server node group are released, so that the investment cost can be saved, the resource waste is reduced, and the service operation is not affected; further, the load balancing algorithm includes, but is not limited to, a round robin algorithm and a weighted round robin algorithm.
Preferably, the method further comprises:
and step S6, monitoring the full load condition of each server node in the target server node group in real time, caching the request message subsequently sent by the intelligent terminal to the offline server node if the server node is in the full load condition, and processing the request message cached in the offline server node after the server node releases the full load condition.
In this embodiment, by monitoring the full load condition of each server node in the target server node group in real time, after an intelligent terminal request message received by a server node reaches a preset threshold, the subsequent reported message is forwarded to an offline server node for caching, and after the server node processes the received intelligent terminal request message first, the server node acquires the subsequent reported message of the intelligent terminal from the offline server node and then processes the message, so as to prevent the avalanche effect of the server node caused by full load of the intelligent terminal request message amount in a peak period, thereby realizing connection admission control and overload control on the intelligent terminal.
Preferably, the method further comprises:
step S7, monitoring the failure condition of each server node in the target server node group in real time, switching the request message processed by the server node to the standby server node when detecting that the server node has a failure, and switching back to the server node from the standby server node after the server node has a failure.
In this embodiment, by monitoring the fault condition of each server node in the target server node group in real time, when a server node fails, the server node switches the request message of the intelligent terminal that the server node needs to process to the standby server node immediately, so that it can be ensured that the service of the intelligent terminal is not interrupted, the experience of a user is improved, and after the server node is repaired, the server node is switched back from the standby server node, the time for using the standby server node can be reduced, and the service life of the standby server node is prolonged.
Preferably, the step S5 of selecting an optimal server node from the server nodes that are not in a full load state according to the load balancing algorithm includes the following steps:
step S51, calculating the weight value of each server node which is not in a full load state;
and step S52, determining the optimal server node according to the weight value.
In this embodiment, the weight value calculation of each server node is performed according to a difference value and a coefficient n between the number of request messages and the number of response messages of the server node, where the smaller the difference value is, the larger the weight number corresponding to the internal server node is, and if more than two internal server nodes correspond to the same weight value, the internal server nodes having the same minimum difference value are randomly selected, and the server node is selected according to the size of the weight value, so that the data processing capability of the server node can be effectively judged, and a large weight value indicates that the data processing capability is good; it should be noted that, the weight value of the server node is the priority of the server node, and a large weight value indicates that the priority of the server node is high.
Preferably, the messages cached to the offline server node include all messages specifying a session, all messages specifying a city, and all messages specifying a server node.
A message access load balancing system, comprising:
the receiving unit is used for receiving the intelligent terminal request message;
the route distribution unit is used for analyzing the received intelligent terminal request message;
the message flow control unit is used for judging whether all server nodes to which the intelligent terminal belongs are fully loaded;
the off-line switching unit is used for sending the request message of the intelligent terminal to an off-line server node for caching;
the load balancing unit is used for calculating an optimal server node according to a load balancing algorithm;
and the sending unit is used for sending the response message of the optimal server node to the intelligent terminal.
In this embodiment, after a target server node group to which an intelligent terminal belongs is obtained by analyzing a request message of the intelligent terminal, it is first determined whether all server nodes in the target server node group are fully loaded, and then it is determined whether the request message of the intelligent terminal is sent to the server nodes, so that the server nodes which are still fully loaded can be prevented from being selected, reliability of access can be improved, and user experience can be improved.
It should be noted that, the route distribution unit is configured to parse key information, such as user number information, in a received intelligent terminal request message, find a routing node according to a routing rule, and uniformly route a number for which no routing information is found to a default node, and further, parse key information, such as a session ID, in a response message, query relevant routing information through a distributed cache according to the session ID, store the routing information and the request message content in the distributed cache, where the routing information is used for subsequent response message original route return;
and the message flow control unit is used for presetting a flow control threshold value, monitoring the conversation traffic in real time, directly returning a request for subsequent report to the system when the conversation traffic reaches the flow control threshold value, and not sending the request to the server node, so that the avalanche effect of the server node caused by the instant sudden increase of the traffic can be effectively prevented, and the normal processing of the traffic can be automatically recovered when the traffic is recovered to the normal level.
Preferably, the system further comprises:
and the session management unit is used for monitoring the service session volume of each server node in real time and judging the full load condition of each server node.
In this embodiment, by monitoring the full load condition of each server node in the target server node group in real time, after an intelligent terminal request message received by a server node reaches a preset threshold, the subsequent reported message is forwarded to an offline server node for caching, and after the server node processes the received intelligent terminal request message first, the server node acquires the subsequent reported message of the intelligent terminal from the offline server node and then processes the message, so as to prevent the avalanche effect of the server node caused by full load of the intelligent terminal request message amount in a peak period, thereby realizing connection admission control and overload control on the intelligent terminal.
It should be noted that when it is monitored that one internal server node corresponding to the session is fully loaded, the session is balanced to other internal server nodes, and when it is monitored that all internal server nodes corresponding to the session are fully loaded, the session is switched to the offline mode.
Preferably, the system further comprises:
and the offline disaster recovery unit is used for judging the fault condition of each server node and realizing the switching between the server nodes and the standby server nodes.
In this embodiment, by monitoring the fault condition of each server node in the target server node group in real time, when a server node fails, the server node switches the request message of the intelligent terminal that the server node needs to process to the standby server node immediately, so that it can be ensured that the service of the intelligent terminal is not interrupted, the experience of a user is improved, and after the server node is repaired, the server node is switched back from the standby server node, the time for using the standby server node can be reduced, and the service life of the standby server node is prolonged.
Preferably, the load balancing unit includes a storage unit for storing a load balancing algorithm and a judging unit for judging the magnitude of the weight value.
In this embodiment, the weight value calculation of each server node is performed according to a difference value and a coefficient n between the number of request messages and the number of response messages of the server node, where the smaller the difference value is, the larger the weight number corresponding to the internal server node is, and if more than two internal server nodes correspond to the same weight value, the internal server nodes having the same minimum difference value are randomly selected, and the server node is selected according to the size of the weight value, so that the data processing capability of the server node can be effectively judged, and a large weight value indicates that the data processing capability is good; it should be noted that, the weight value of the server node is the priority of the server node, and a large weight value indicates that the priority of the server node is high.
Preferably, the messages cached to the offline server node include all messages specifying a session, all messages specifying a city, and all messages specifying a server node.
The technical solutions provided by the embodiments of the present invention are described in detail above, and the principles and embodiments of the present invention are explained herein by using specific examples, and the descriptions of the embodiments are only used to help understanding the principles of the embodiments of the present invention; meanwhile, for a person skilled in the art, according to the embodiments of the present invention, there may be variations in the specific implementation manners and application ranges, and in summary, the content of the present description should not be construed as a limitation to the present invention.