Disclosure of Invention
The invention aims to provide a message access load balancing method and 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 an intelligent terminal;
s2, analyzing the request message of the intelligent terminal, and determining a 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 offline server node for caching, and after the caching is performed for a preset time, the step S3 is executed;
and S5, selecting an optimal server node from server nodes which are not in a full-load state according to a load balancing algorithm, sending a 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.
As a further alternative to the message access load balancing method, the method further comprises:
and S6, monitoring the full load condition of each server node in the target server node group in real time, if the server node is in a full load state, caching the request message sent by the intelligent terminal to the offline server node, and processing the request message cached in the offline server node after the server node is released from the full load state.
As a further alternative to the message access load balancing method, the method further comprises:
and S7, monitoring the fault 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 the fault condition of the server node is detected, and switching the request message back to the server node from the standby server node after the fault contact of the server node.
As a further alternative of the message access load balancing method, the selecting, in step S5, the optimal server node among the server nodes not in the 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;
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 session-specific messages, all city-specific messages, and all server node-specific messages.
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 offline switching unit is used for sending the request message of the intelligent terminal to the offline 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 node and the standby server node.
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 to the message access load balancing system, the cached messages to the offline server node include all session-specific messages, all city-specific messages, and all server node-specific messages.
The invention has the beneficial effects that:
by using the method and the system of the invention, 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 fully loaded is judged, and then whether the request message of the intelligent terminal is sent to the server nodes is determined, so that the selection of the server nodes still in the fully loaded state can be avoided, the access reliability can be improved, the user experience is improved, and meanwhile, the request message of the intelligent terminal is sent to the server nodes after the optimal server nodes are screened out, so that the situation that the selected server nodes are not distributed with the message and the message needs to be acquired again from the server nodes distributed with the message can be avoided, the response time of the server nodes is improved, and the processing burden of the server nodes is also reduced.
Detailed Description
The present invention will now be described in detail with reference to the drawings and the detailed description thereof, wherein the invention is illustrated by the schematic drawings and the detailed description thereof, which are included to illustrate and not to limit 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 an intelligent terminal;
s2, analyzing the request message of the intelligent terminal, and determining a 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 offline server node for caching, and after the caching is performed for a preset time, the step S3 is executed;
and S5, selecting an optimal server node from server nodes which are not in a full-load state according to a load balancing algorithm, sending a 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.
In this embodiment, 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 fully loaded is first determined, and then whether the request message of the intelligent terminal is sent to the server nodes is determined, so that the selection of the server nodes still in the fully loaded state can be avoided, the reliability of access can be improved, the user experience is improved, and meanwhile, after the optimal server node is screened out, the request message of the intelligent terminal is sent to the server nodes, so that the situation that the selected server nodes do not distribute the message and the message needs to be acquired again from the server nodes distributed to the message can be avoided, the response time of the server nodes is prolonged, and the processing burden of the server nodes is also reduced.
When all the server nodes in the target server node group are in a full load state, server nodes near the target server node group can be temporarily distributed to the target server node group through a rear end server platform, after the server nodes originally belonging to the target server node group are released from the full load state, and enough space is available for processing request messages of the intelligent terminal, the server nodes temporarily added into the target server node group are released, so that the investment cost can be saved, the resource waste can be reduced, and meanwhile, the service operation cannot be influenced; further, the load balancing algorithm includes, but is not limited to, a polling algorithm and a weighted polling algorithm.
Preferably, the method further comprises:
and S6, monitoring the full load condition of each server node in the target server node group in real time, if the server node is in a full load state, caching the request message sent by the intelligent terminal to the offline server node, and processing the request message cached in the offline server node after the server node is released from the full load state.
In this embodiment, through monitoring the full load condition of each server node in the target server node group in real time, after the intelligent terminal request message received by the server node reaches a preset threshold, forwarding the subsequently reported message to the offline server node for caching, waiting for the server node to process the previously received intelligent terminal request message, acquiring the subsequently reported message of the intelligent terminal from the offline server node, and then processing the subsequently reported message, so as to prevent the avalanche effect of the server node caused by the full load of the intelligent terminal request message in the peak period, thereby realizing connection permission control and overload control on the intelligent terminal.
Preferably, the method further comprises:
and S7, monitoring the fault 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 the fault condition of the server node is detected, and switching the request message back to the server node from the standby server node after the fault contact of the server node.
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 stand-alone horse switches the request message of the intelligent terminal to be processed by the server node to the standby server node, so that the service of the intelligent terminal is not interrupted, the experience of a user is improved, and when the server node fails to repair, the server node is switched back from the standby server node, so that the time for using the standby server node is reduced, and the service life of the standby server node is prolonged.
Preferably, in the step S5, selecting the optimal server node from the server nodes not in the 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;
step S52, determining the optimal server node according to the weight value.
In this embodiment, the weight value calculation of each server node is obtained according to the difference value between the number of request messages and the number of response messages of the server node and the coefficient n, and the weight number corresponding to the internal server node with the smaller difference value is larger, if more than two internal partial server nodes correspond to the same weight value, the internal server nodes with the same minimum difference value are randomly selected, and the server node is selected according to the weight value, so that the data processing capability of the server node can be effectively judged, and the weight value is large to indicate that the data processing capability is good; 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 offline switching unit is used for sending the request message of the intelligent terminal to the offline 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 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 fully loaded is first determined, and then whether the request message of the intelligent terminal is sent to the server nodes is determined, so that the selection of the server nodes still in the fully loaded state can be avoided, the reliability of access can be improved, the user experience is improved, and meanwhile, after the optimal server node is screened out, the request message of the intelligent terminal is sent to the server nodes, so that the situation that the selected server nodes do not distribute the message and the message needs to be acquired again from the server nodes distributed to the message can be avoided, the response time of the server nodes is prolonged, and the processing burden of the server nodes is also reduced.
The routing distribution unit is used for analyzing key information in the received intelligent terminal request message, such as user number information and the like, finding a routing node according to a routing rule, uniformly routing numbers which cannot find the routing information to a default node, analyzing key information in response messages, such as session ID and the like, inquiring related routing information through a distributed cache according to the session ID, storing the routing information and the request message content into the distributed cache, and returning the routing information to a subsequent original response message;
the message flow control unit is used for presetting a flow control threshold value, monitoring the session traffic in real time, and when the session traffic reaches the flow control threshold value, the request for the subsequent report is directly returned to the system to be busy and is not sent to the server node any more, 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 service 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, through monitoring the full load condition of each server node in the target server node group in real time, after the intelligent terminal request message received by the server node reaches a preset threshold, forwarding the subsequently reported message to the offline server node for caching, waiting for the server node to process the previously received intelligent terminal request message, acquiring the subsequently reported message of the intelligent terminal from the offline server node, and then processing the subsequently reported message, so as to prevent the avalanche effect of the server node caused by the full load of the intelligent terminal request message in the peak period, thereby realizing connection permission control and overload control on the intelligent terminal.
It should be noted that, when one internal server node corresponding to a session is monitored to be fully loaded, the session is balanced to other internal server nodes, and when all internal server nodes corresponding to the session are monitored to be fully loaded, the method is switched to an 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 node and the standby server node.
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 stand-alone horse switches the request message of the intelligent terminal to be processed by the server node to the standby server node, so that the service of the intelligent terminal is not interrupted, the experience of a user is improved, and when the server node fails to repair, the server node is switched back from the standby server node, so that the time for using the standby server node is reduced, and the service life of the standby server node is prolonged.
Preferably, the load balancing unit comprises a storage unit for storing a load balancing algorithm and a judging unit for judging the weight value.
In this embodiment, the weight value calculation of each server node is obtained according to the difference value between the number of request messages and the number of response messages of the server node and the coefficient n, and the weight number corresponding to the internal server node with the smaller difference value is larger, if more than two internal partial server nodes correspond to the same weight value, the internal server nodes with the same minimum difference value are randomly selected, and the server node is selected according to the weight value, so that the data processing capability of the server node can be effectively judged, and the weight value is large to indicate that the data processing capability is good; 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 foregoing has described in detail the technical solutions provided by the embodiments of the present invention, and specific examples have been applied to illustrate the principles and implementations of the embodiments of the present invention, where the above description of the embodiments is only suitable for helping to understand the principles of the embodiments of the present invention; meanwhile, as for those skilled in the art, according to the embodiments of the present invention, there are variations in the specific embodiments and the application scope, and the present description should not be construed as limiting the present invention.