A kind of server cluster system and load-balancing method
Technical field
The present invention relates to a kind of server cluster system and load-balancing method.
Background technology
Along with the development of Internet technology, the type of service variation that becomes, the multimedia communication of multiple business such as developing into nowadays from the data communication of single business can support voice, video.For the system that forms by the separate unit server, because the restriction of aspects such as the central processing unit of separate unit server, input/output interface processing speed, the server cluster system of being made up of multiple servers is the substitute is in the requirement that can't satisfy the data volume of quick growth and handle multiple business simultaneously.
Server cluster system requires a kind of high-efficient carrier equalization methods reasonably to be dispensed to multiple servers to guarantee a plurality of message request.Existing load-balancing method based on weights polling dispatching algorithm has made full use of the resource of server cluster system according to the instant message request that the is not all select target server of server performance; The load-balancing method of existing dialogue-based numbering (Session ID) can be discerned the different instant message requests that same user terminal sends, these instant message requests are handled by same station server, saved actions such as repetition identification, parameter transmission.But above-mentioned load-balancing method has all been ignored the situation of user terminal requests identical services.
Summary of the invention
Do not consider the problem of user terminal requests identical services in order to solve above-mentioned existing server cluster system, the invention provides a kind of server cluster system and load-balancing method, use this server cluster system and load-balancing method to select only destination server for dissimilar instant message requests.
Technical scheme of the present invention is as follows:
The invention provides a kind of server cluster system.This system comprises load balancing subsystem and server cluster, and described load balancing subsystem is characterized in that according to the destination server of established methodology selection processing instant message request described load balancing subsystem comprises:
The request receiver module receives the instant message request;
The HTTP parsing module, the message header of analyzing instant messages request and message body;
The request forwarding module encapsulates instant message request after the described parsing according to the host-host protocol of destination server support, and the instant message request after the parsing that has encapsulated of sending is to described destination server;
The response receiver module, the reception response that the receiving target server sends;
The response forwarding module encapsulate described reception response according to HTTP, and the reception that transmission has encapsulated responds to the transmitting terminal of instant message request;
Memory management module, the memory source of distribution and load management equalization subsystem;
Server management module disposes described server cluster and the parameter that server in the described server cluster is set;
Destination server is selected module one, the business that comprises in the message body according to the instant message request after described parsing numbering select target server;
Destination server is selected module two, the session number select target server that comprises in the message header according to the instant message request after the described parsing;
Destination server is selected module three, according to the server performance select target server in the described server cluster;
Monitoring module is used for obtaining the operating state of described each station server of server cluster.
Above-mentioned server cluster system also comprises the reservation message ADMINISTRATION SUBSYSTEM, and described reservation message ADMINISTRATION SUBSYSTEM comprises:
The message sink module is used to receive the lastest imformation of non-instant message request or non-instant message request;
Message storage module is used to store the lastest imformation of described non-instant message request or described non-instant message request;
Data management module is used for the non-instant message request that detects the non-instant message request processing time of described message storage module and be used for upgrading described message storage module;
The message trigger module is converted into the instant message request in described non-instant message request processing time with described non-instant message request, sends described instant message request to described load balancing subsystem.
In the above-mentioned server cluster system, described message storage module comprises:
The database submodule is used to store from the non-instant message request of message sink module or the lastest imformation of non-instant message request;
The metadata cache submodule is used to store from the non-instant message request of database submodule or from the lastest imformation of the non-instant message request of message sink module.
In the above-mentioned server cluster system, non-instant message request processing time is meant in the described message storage module of described detection:
A, described data management module judge that every the once described database submodule of given time X visit the non-instant message request whether reservation is arranged in the described database submodule is in visit processing constantly;
If there is the non-instant message request of reservation to handle constantly in visit in the described database submodule of B, described data management module is sent to described message trigger module with the non-instant message request of described reservation;
If the non-instant message request of reservation is not in the processing of the visit moment in the described database submodule of C, described data management module is extracted into described metadata cache submodule with visiting the non-instant message request of handling between the moment constantly and next time about described visit in advance in the described database submodule;
D, described data management module judge that every the once described metadata cache submodule of given time Y visit the non-instant message request whether reservation is arranged in the described metadata cache submodule is in visit processing constantly;
If there is the non-instant message request of reservation to handle constantly in visit in the described metadata cache submodule of E, described data management module is sent to described message trigger module with the non-instant message request of described reservation;
If in the described metadata cache submodule of F not the non-instant message request of reservation handle constantly in visit, described data management module waits for that next visit visits described metadata cache submodule constantly;
Described given time Y is less than described given time X.
In the above-mentioned server cluster system, the non-instant message request in the described message storage module of described renewal is meant:
A, described message sink module receive the lastest imformation of non-instant message request;
B, described data management module are visited described metadata cache submodule, search the non-instant message request that whether has described lastest imformation correspondence in the described metadata cache submodule;
If there is the non-instant message request of described lastest imformation correspondence in the described metadata cache submodule of C, described data management module reads described lastest imformation to described metadata cache submodule, replacing needs the content that is updated in the non-instant message request of lastest imformation correspondence described in the described metadata cache submodule, and sends to upgrade successfully to described message sink module and indicate;
If there is not the non-instant message request of described lastest imformation correspondence in the described metadata cache submodule of D, described data management module is visited described database submodule, searches the non-instant message request that whether has described lastest imformation correspondence in the described database submodule;
If there is the non-instant message request of described lastest imformation correspondence in the described database submodule of E, described data management module reads described lastest imformation to described database submodule, replacing needs the content that is updated in the non-instant message request of lastest imformation correspondence described in the described database submodule, and sends to upgrade successfully to described message sink module and indicate;
If there is not the non-instant message request of described lastest imformation correspondence in the described database submodule of F, described data management module sends to described message sink module and upgrades the failure indication.
In the above-mentioned server cluster system, described established methodology is:
A, the request of reception instant message;
B, analyzing instant messages request judge whether the message header of the instant message request after resolving contains the path of destination server;
If the message header of the instant message request after the described parsing of C does not contain the path of destination server, judge whether the message body of the instant message request after resolving contains professional numbering;
If the message body of the instant message request after the described parsing of D contains professional numbering, according to described professional numbering select target server, encapsulate instant message request after the described parsing according to the host-host protocol of described destination server support, the instant message request after the parsing that has encapsulated of sending is to described destination server;
If the message body of the instant message request after the described parsing of E does not contain professional numbering or according to described professional numbering select target server failure, judge whether the message header of the instant message request after the described parsing contains session number;
If the message header of the instant message request after the described parsing of F contains session number, according to described session number select target server, encapsulate instant message request after the described parsing according to the host-host protocol of described destination server support, the instant message request after the parsing that has encapsulated of sending is to described destination server;
If the message header of the instant message request after the described parsing of G does not contain session number or according to described session number select target server failure, according to weights polling dispatching algorithm select target server, encapsulate instant message request after the described parsing according to the host-host protocol of described destination server support, the instant message request after the parsing that has encapsulated of sending is to described destination server;
If the message header of the instant message request after the described parsing of H contains the path of destination server, according to the described parsing of the host-host protocol encapsulation back instant message request that destination server is supported, the instant message request after the parsing that transmission has encapsulated is to described destination server;
I, the reception that receives from described destination server respond;
J, encapsulate described reception response, and send the reception response that encapsulated transmitting terminal to described instant message request by HTTP.
The transmitting terminal of this instant message request is for directly transferring immediate news requesting users terminal or send non-instant message requesting users terminal.
Beneficial effect of the present invention is:
(1) utilizes professional numbering select target server, the instant message of the identical services that calls request is handled by same destination server, improved treatment effeciency;
(2) merged according to business numbering select target server, according to session number select target server and according to multiple load-balancing methods such as weights polling dispatching algorithm select target servers, can select best destination server for dissimilar instant message requests;
(3) the instant message request can not only be handled, non-instant message request can also be handled.
In conjunction with the accompanying drawings, other characteristics of the present invention and advantage can be from below by becoming clearer the explanation of giving an example the preferred implementation that principle of the present invention is made an explanation.
Description of drawings
Fig. 1 illustrates the server cluster system Organization Chart that does not contain the reservation message ADMINISTRATION SUBSYSTEM;
Fig. 2 illustrates the server cluster system Organization Chart that contains the reservation message ADMINISTRATION SUBSYSTEM;
Fig. 3 illustrates the load-balancing method flow chart.
Embodiment
Below in conjunction with accompanying drawing, embodiments of the present invention are illustrated.
Embodiment one, and server cluster system as shown in Figure 1.User terminal 100 transfers immediate news and asks to load balancing subsystem 101.This instant message request is the HTTP request.Load balancing subsystem 101 receives this instant message request, and selects the destination server 108 of this instant message request of processing according to set load-balancing method.
Present embodiment has provided one destination server 108, but in actual applications, destination server is not that changeless, dissimilar instant message request may corresponding different destination servers.
The functional module of load balancing subsystem 101 as shown in Figure 1.Load balancing subsystem 101 comprises asks receiver module 211, request forwarding module 212, response receiver module 213, response forwarding module 214, HTTP parsing module 215, memory management module 216, server management module 217, destination server to select module 1, destination server selection module 2 219, destination server to select module 3 220 and monitoring module 221.
The instant message request that request receiver module 211 receives from user terminal 100.
HTTP parsing module 215 is resolved this instant message request, and this instant message request comprises request header and request body.According to the explanation document RFC2626 of HTTP, the message header of HTTP request comprises contents such as session number and destination server information, and the message body of HTTP request comprises professional numbering and request entity information.If the instant message request after resolving comprises the routing information of destination server, the instant message request after the parsing is sent to request forwarding module 212.If the instant message request after resolving does not comprise the routing information of destination server, the instant message request after the parsing is sent to destination server and selects module 1, destination server to select module 2 219 or destination server to select module 3 220.
The business numbering select target server that comprises in the message body after destination server selects module 1 according to 215 parsings of HTTP parsing module.The session number select target server that comprises in the message header after destination server selects module 2 219 according to 215 parsings of HTTP parsing module.Destination server selects module 3 220 according to the server performance select target server in the server cluster.
The host-host protocol that request forwarding module 212 is supported according to the destination server selected 108 encapsulates the instant message request after this parsings, and the instant message request after the parsing that encapsulated of transmission is to destination server 108.
The reception response that response receiver module 213 receiving target servers 108 send.Response forwarding module 214 encapsulates this reception response according to HTTP, and the reception response that transmission has encapsulated is to sending this instant message requesting users terminal 100.
The memory source of memory management module 216 distribution and load management equalization subsystem 101.
The platform number of server and the host-host protocol that server initial parameter and server are supported in the server cluster is set in the server management module 217 configuration server clusters.
Monitoring module 221 obtains the operating state of each station server in the server cluster, but according to the performance number of this operating state calculation server.
Embodiment two, and server cluster system as shown in Figure 2.Server cluster system removes load balancing subsystem 101 among this embodiment, outside the server cluster 107, also comprises reservation message ADMINISTRATION SUBSYSTEM 102.Wherein, reservation message ADMINISTRATION SUBSYSTEM 102 is made up of four functional modules: message sink module 103, message storage module 104, data management module 105 and message trigger module 106.Wherein, message storage module 104 is made up of database submodule 1041 and metadata cache submodule 1042.
The non-instant message request that message sink module 103 reception user terminals 200 send or the lastest imformation of non-instant message request.The lastest imformation of this non-instant message request or non-instant message request has comprised non-instant message request processing time.This non-instant message request is converted into the instant message request in this processing time.
Message storage module 104 is used to store the non-instant message request that user terminal 200 sends or the lastest imformation of non-instant message request.
The non-instant message request that data management module 105 is used for detect-message memory module 104 non-instant message request processing time and is used for updating message memory module 104.
Message trigger module 106 is converted into the instant message request in non-instant message request processing time with non-instant message request, sends this instant message request to load balancing subsystem 101.
The process of non-instant message request processing time is as follows in the data management module 105 detect-message memory modules 104: data management module 105 is set up two threads, one of them thread judges that every database submodule 1041 of given time X visit the non-instant message request whether reservation is arranged in this database submodule 1041 is in this visit processing constantly.If there is the non-instant message request of reservation to handle constantly in this visit in the database submodule 1041, this thread reads the non-instant message request of this reservation to message trigger module 106; If the non-instant message request of not preengaging in the database submodule 1041 is handled constantly in this visit, above-mentioned thread will ask that about the visit the moment and the non-instant message request of next time handling between the visit constantly are sent to metadata cache submodule 1042 in the database submodule 1041 in advance.Another thread of data management module 105 is visited once this metadata cache submodule 1042 every given time Y, judges that the non-instant message request whether reservation is arranged in this metadata cache submodule 1042 is in this visit processing constantly.If there is the non-instant message request of reservation to handle constantly in this visit in the metadata cache submodule 1042, this thread reads the non-instant message request of this reservation to message trigger module 106; If the non-instant message request of reservation is not in this visit processing constantly in the metadata cache submodule 1042, next visit of this thread waits is visit data cache sub-module 1042 constantly.Above-mentioned given time Y is less than described given time X.
The process of non-instant message request is as follows in the data management module 105 updating message memory modules 104: when message sink module 103 receives the lastest imformation of non-instant message request, data management module 105 is visit data cache sub-module 1042 at first, searches the non-instant message request that whether has this lastest imformation correspondence in the metadata cache submodule 1042.If there is the non-instant message request of this lastest imformation correspondence in the metadata cache submodule 1042, data management module 105 reads this lastest imformation to metadata cache submodule 1042, replacing needs the content that is updated in wherein corresponding with this lastest imformation non-instant message request, and sends to upgrade successfully to message sink module 103 and indicate; If there is not the non-instant message request of this lastest imformation correspondence in the metadata cache submodule 1042, data management module 105 accessing database submodules 1041 are searched the non-instant message request that whether has this lastest imformation correspondence in the database submodule 1041.If there is the non-instant message request of this lastest imformation correspondence in the database submodule 1041, data management module 105 reads this lastest imformation to database submodule 1041, replacing needs the content that is updated in wherein corresponding with this lastest imformation non-instant message request, and sends to upgrade successfully to message sink module 103 and indicate; If there is not the non-instant message request of this lastest imformation correspondence in the database submodule 1041, data management module 105 sends to message sink module 103 and upgrades the failure indication.
The request receiver module of load balancing subsystem 101 receives the instant message request from reservation message ADMINISTRATION SUBSYSTEM 102, and selects the destination server of this instant message request of processing from server cluster 107.Load balancing subsystem 101 is that the process of this instant message request select target server is the process from the instant message request select target server of user terminal 100 with load balancing subsystem among the embodiment one 101.Destination server receives response to 213 transmissions of response receiver module, and response forwarding module 214 should receive and be sent to user terminal 200 after response encapsulates according to HTTP.Response forwarding module 214 can directly be sent to user terminal 200 with receiving response, also can will receive response by reservation message ADMINISTRATION SUBSYSTEM 102 and be forwarded to user terminal 200.
In this embodiment, the request receiver module of load balancing subsystem 101 remove to receive instant message request from reservation message ADMINISTRATION SUBSYSTEM 102 and also receives instant message request from user terminal 100.In the present embodiment 101 pairs of load balancing subsystems from the instant message processing of request process of user terminal 100 with 101 pairs of processing procedures of load balancing subsystem among the embodiment one from the instant message of user terminal 100.
In above-mentioned two kinds of embodiment, the set load-balancing method of load balancing subsystem 101 select target servers as shown in Figure 3.This method starts from step S301.Then, in step S302, the instant message request that request receiver module 211 receives from user terminal 100 or reservation message ADMINISTRATION SUBSYSTEM 102.
In step S303, the 215 analyzing instant messages requests of HTTP parsing module judge whether the message header of the instant message request after resolving contains the path of destination server.
If the result of step S303 is a "Yes", then flow process enters step S311; Otherwise enter step S304.
In step S304, HTTP parsing module 215 judges whether the message body of the instant message request after resolving contains professional numbering.
When one of user terminal requests is professional, in the message body of the message request of its transmission, can be endowed a professional numbering.Ask the message body of same professional message request to contain identical business numbering.Such as, above-mentioned business is a multimedia conferencing, asks the message body of the message request of same multimedia conferencing to contain identical business numbering.
If the result of step S304 is a "Yes", then flow process enters step S305; Otherwise enter step S307.
In step S305, according to business numbering select target server.
This step selects module 1 to finish by destination server.Destination server is selected module 1 to search and was handled the instant message requested service device with identical services numbering in the cluster server 107.If find this server, destination server selects the instant message request after module 1 will be resolved to be sent to this server; If do not find this server, the instant message request that does not also have server process to cross to have this business numbering in the server cluster 107 is described, destination server selects module 1 to HTTP parsing module 215 signal of giving notice.Select server according to business numbering, the instant message request that will have after the parsing of identical services numbering is dispensed to same station server, has improved the treatment effeciency of server.
When server process has the instant message request of professional numbering, need search existing to having the instant message processing of request result of this business numbering.By professional numbering select target server, the instant message request that will have the identical services numbering is sent to same server, avoid visit, improved server process instant message request efficiency the different server of handling instant message request with this business numbering.
In step S306, whether determining step S305 successful select target server.
If the result of step S306 is a "Yes", then flow process enters step S311; Otherwise enter step S307.
In step S307, whether contain session number in the message header of the instant message request after 215 judgements of HTTP parsing module are resolved.
Session number (Session ID) refers to a unique identifier that sends the user terminal distribution of message request into each.This identifier is used between user terminal identity authentication, program state record and the page operations such as parameter transmission.
If the result of step S307 is a "Yes", then flow process enters step S308; Otherwise enter step S310.
In step S308, according to session number select target server.
This step selects module 2 219 to finish by destination server.Destination server is selected module 2 219 to search and was handled the instant message requested service device with same session numbering in the cluster server 107.If find this server, destination server selects the instant message request after module 2 219 will be resolved to be sent to this server; If do not find this server, destination server selects module 2 219 to target selection module 3 220 signal of giving notice.Select server according to session number, the message request that same user terminal sends is transferred to same station server processing, avoid this server carry out the operations such as terminal identity authentication of repetition from the message request of same user terminal.
In step S309, whether determining step S308 successful select target server.
If the result of step S309 is a "Yes", then flow process enters step S311; Otherwise enter step S310.
In step S310, according to weights polling dispatching algorithm select target server.
This step selects module 3 220 to finish by destination server.Destination server selects module 3 220 to calculate correspondingly server weights according to the operating state of each station server in the server cluster 107, and by the performance number of server weights calculation server.Destination server selects module 3 220 to dispatch each station server successively according to the performance number order from big to small of server, makes the instant message request after the big server priority treatment of performance number is resolved.According to weights polling dispatching algorithm select target server, reasonably utilized the resource of server cluster system.
After the step S310, flow process enters step S311.
In step S311, request forwarding module 212 encapsulates instant message request after the above-mentioned parsing according to the host-host protocol of the destination server support of selecting, and the instant message request after the parsing that has encapsulated of sending is to the destination server of selecting.
In step S312, response receiver module 213 receives the reception response from destination server.
The destination server of selecting sends reception and responds to the load balancing subsystem after the instant message request after the parsing that has encapsulated that receives 212 transmissions of request forwarding module.
In step S313, response forwarding module 214 receives this reception response and encapsulates this reception response by HTTP, sends the reception that has encapsulated and responds to the transmitting terminal of instant message request.The transmitting terminal of this instant message request is for directly transferring immediate news requesting users terminal 100 or send non-instant message requesting users terminal 200.
Flow process ends at step S314.
The above is preferred embodiment of the present invention only, is not to be used to limit protection scope of the present invention, and those of ordinary skills can make various changes and modifications within the scope of the appended claims.