Background technology
Network Load Balance (Windows NLB, Windows Network LoadBalance) system based on Windows uses trooping of two or more host computers compositions of working together, for server provides high availability and high scalability.The Internet client uses an IP address or group address visit to troop.Client need not difference and troops and single server.The network load balancing cluster server has very big difference with the individual host of operation individual server application program, even because under the situation that certain server (node) breaks down in trooping, other nodes also can provide continual service in trooping.It is also fast than individual host to the response of client-requested to troop.
NLB is being by distributing to the network service that distribution is imported between one or more virtual ip address of network load balancing cluster (the IP address of trooping), thereby brought transformable performance.Then, each node in trooping can be made response to different client-requested even from a plurality of requests of same client simultaneously.For example, Web browser can the different nodes from network load balancing cluster obtains the multiple image in all individual webpages.This has just improved processing speed, and has shortened the time of client being made response.
NLB makes that all nodes can detect the network service of importing the IP address of trooping into simultaneously in the trooping of single subnet.On each cluster node, the NLB driver serves as the filter between cluster adapter driver and tcpip stack, so as between each node allocate communications.
For instance, when client is sent a request to trooping, troop in for example host ip that each node comprises in will asking, the load-balancing algorithm that host port imports setting into, after in algorithm, carrying out hash calculating, determine the node of final this request of processing, that is to say, when node judges according to result of calculation to determine it oneself is when being responsible for the node of this request of processing, receive the message of this request, otherwise then abandon this message.Like this, all requests that are derived from same IP and port all can be assigned to same node and handle.
In the prior art, by being set, different relation (Affinity) adjustment imports the parameter of load-balancing algorithm into, except the None that introduces above (using the source port number and the IP address of request), also have Single (only using host ip) and Class C (only use host ip preceding 24).Relation (Affinity) has defined the relation before source host and the destination node.Wherein:
None:
Which NLB node the source port number of client-requested and IP address all are used to determine to receive this message.As long as the source port in the request is counted difference, different nodes can be handled the request from same IP address client.
Single:
When which NLB node of decision can be received this message, only use source IP address.In this case, the request from same source IP is sent to same node all the time.
Class?C:
Similar with Single, different is that it does not use the entire I P address, only uses the W in the IP address, X, Y byte.Request each time is when setting up, and allowing anyly has the IP address of 24 of identical high positions to be connected with same node.As: IP address 222.222.222.10 and 222.222.222.69 can be assigned to same NLB node, because preceding 24 of their IP is identical.
In actual application, if application system has adopted the Network Load Balance system, but there is partial service to need to handle on some therein nodes on this application system, and only carry out result's output and displaying, then need asking these professional HTTP requests to carry out special orientation at this node.For example a kind of operation system based on the B/S framework, wherein some service logic is very complicated, when handling, need consume a large amount of system resource, so when distributed deployment, often all can handle on the server all disposing preferably at a certain with the professional relevant HTTP request of this class, and according to the method for present Network Load Balance distribution network flow, can't when realizing Network Load Balance, can all be directed to the HTTP/HTTPS request of the same specific transactions of request on the MLB node of same appointment.
Embodiment
The method of the specific request directional process of the realization that the embodiment of the invention provides is applied to the Network Load Balance system, as shown in Figure 1, comprises following several steps:
Node in step S101, the Network Load Balance system receives the service request that client is initiated.
Step S102, this node calculate according to the Network Load Balance algorithm that sets in advance, and judge according to result calculated whether self is responsible for handling the node of this request; Otherwise execution in step S103; Be then to carry out following step S104.
Step S103, abandon the request of reception.
Step S104, further determine that whether this request is the request of specific business function, when definite result when being, carry out following step S105, when definite result is when denying, carry out following step S106.
Step S105, the request that will receive are forwarded to the node of this specific transactions function correspondence.
After this request arrives the node of this specific transactions function correspondence, handle by the node of correspondence.
Step S106, the request that receives is handled.
Below in conjunction with accompanying drawing, a kind of method of specific request directional process and device realized provided by the invention is described in detail with specific embodiment.
In the method for the specific request directional process of the realization that the embodiment of the invention provides, application system can be formed to N platform (N on be limited to 32) application server by 2, each application server deploy has corresponding application system, and each application server support has also been installed Network Load Balance NLB function, and the application system that makes each application server form can realize the Network Load Balance function.
Each application server also should possess the function of HTTP request interception, HTTP request interception is meant in the Web application system, HTTP (or HTTPS) access request that client is initiated is carried out preliminary treatment, promptly carry out the parameter of obtaining in the access request, access request such as is transmitted at operation.
In embodiments of the present invention, each application server in the application system can carry out networking according to network topological diagram shown in Figure 2, each application server (being designated Radius server 1, Radius server 2, Radius server 3......Radius server N among Fig. 2) is deployed in the same subnet, and can communicate each other, in network topology shown in Figure 2, the switch that links to each other with each application server also should possess the network enabled load-balancing function.
After each application server is opened its Network Load Balance function, further, each application server is carried out following configuration:
With each application server configuration in the application system among the trooping of same Network Load Balance system, like this when carrying out network service, this application system just becomes a Network Load Balance system, and each application server is also with regard to corresponding each node that becomes in this Network Load Balance system.
The port of each node and relation (affinity settings) settings for example can select to adopt any one in existing None relation, Single relation and the Class C relation.
The operator scheme of the Network Load Balance of each application server in the Network Load Balance system, also can be according to selecting to be set to unicast or multicast operator scheme, the method to set up that unicast or multicast operator scheme is concrete belongs to the category of prior art, does not repeat them here.
Also need to dispose corresponding IP address for each node in the Network Load Balance system.
Except the configuration that above-mentioned each application server is used always, the method of the specific request directional process of the realization that the embodiment of the invention provides, before carrying out network service, also need every needs are carried out the specific business function corresponding setting of directional process, in the embodiment of the invention, can adopt following two kinds of set-up modes.
First kind of mode, can set in advance every specific business function and the corresponding relation between the node IP address, and specific business function and unified resource identifier (Universal Resource Identifier, URI) corresponding relation between that every needs carry out directional process be set.
For instance, if this application system business function 1 relevant request need unify to be handled by node A, business function 2 relevant requests need unify to be handled by Node B, then need to set in advance the corresponding relation between the IP address of business function 1 and node A, and the corresponding relation between the IP address of business function 2 and Node B etc., these corresponding relations can adopt database, file or other data modes to be stored in each node, also can be stored in the network entity that each node can visit.
Equally, for these specific business functions, also need to set in advance the URI of every business function correspondence, for instance, the URI that business function 1 correspondence is set for " http: // (contextpath)/func1 ", the URI that business function 2 correspondences are set for " http: // (contextpath)/func2 ", similarly, every specific business function can adopt database, file or other data modes to be stored in each node with corresponding URI, also can be stored in the network entity that each node can visit.
Under the more situation of specific business function, especially occur preferably, can adopting first kind of set-up mode under the situation of the corresponding same node of a plurality of functions, this mode helps information stores and maintenance.
Another kind of alternative set-up mode (following second kind of set-up mode), be applicable under the less situation of specific business function, in second kind of set-up mode, the IP addresses of nodes of directional process specific transactions function and URI directly can be carried out correspondingly, just be provided with and store the IP addresses of nodes and the URI of specific transactions function.
Discuss the specific implementation process of step S103 and S104 in the method for the specific request directional process of realization as shown in Figure 1 below respectively in detail at above-mentioned first kind of set-up mode and second kind of set-up mode.
As shown in Figure 3, as adopt above-mentioned first kind of set-up mode, then node determines that whether this request is the request of specific business function, and when determining that the result is that the process that this request is forwarded to when being the node of specific transactions function correspondence specifically comprises following each step:
Step S301, determine it self is when be responsible for handling the node of this request, to obtain the URI that carries in this request according to existing load-balancing algorithm when node.
Step S302, URI that node will carry in will asking and specific business function and the URI in the corresponding relation between the URI mate; If coupling is unsuccessful, execution in step S303; If the match is successful, execution in step S304.
The corresponding storage area of node visit obtains the specific business function that sets in advance and the corresponding relation between the URI, and the URI that this request is carried and the URI in the corresponding relation mate.When the match is successful, just can judge that this request is the request of specific transactions function.
Step S303, this request is handled.
Step S304, according to the specific business function of the URI correspondence of carrying in this request, and specific business function that sets in advance and the corresponding relation between the node IP address are determined the IP addresses of nodes of this URI correspondence.
The corresponding storage area of node visit obtains the specific business function that sets in advance and the corresponding relation between the node IP address, determines the URI that carries in the request, in stored relation, and corresponding node IP address.Determine after the IP address of corresponding node execution in step S305 and step S306.
The IP addresses of nodes that step S305, use are determined is replaced the purpose IP address in this request.
Step S306, this request is forwarded to the node of the IP address correspondence after the replacement.
To step S306, the node in the SiteServer LBS for example can use J2EE WEB container or .NET application framework to realize the function of HTTP request interception at above-mentioned steps S301.With the J2EEWEB container is example, can use the handling implement of existing HTTP Servlet as URI.Servlet is positioned at the key-course of Web container, can the access request of URI be intercepted processing and forwarding.Servlet mates the URI URI corresponding with specific function that is truncated to, process for the result who meets coupling (promptly visiting the request of this function), revise the IP address, destination of access request, request is forwarded to the node of amended address correspondence, the node processing that this request can be set in advance the most at last.
As shown in Figure 4, as adopt above-mentioned second kind of set-up mode, then node determine this request whether be specific business function request and when definite result when being, the process of node that this request is forwarded to specific transactions function correspondence is as follows:
Step S401, determine it self is when be responsible for handling the node of this request, to obtain the URI that carries in this request according to existing load-balancing algorithm when node.
URI in the corresponding relation of step S402, the URI that carries in will asking and the IP addresses of nodes of handling the specific transactions function and URI mates.
The corresponding storage area of node visit obtains the IP addresses of nodes of the processing specific transactions function that sets in advance and the corresponding relation of URI.
URI in URI that carries in this request and the corresponding relation that gets access to is mated, when the match is successful, execution in step S403 and step 404, otherwise, when coupling is unsuccessful, execution in step S405.
The IP addresses of nodes of the URI correspondence of carrying in step S403, the use request is replaced the purpose IP address in this request.
Step S404, this request is forwarded to the node of the IP address correspondence after the replacement.
Step S405, this request is handled.
With the similar process of above-mentioned steps S301 to step S306, to step S405, the node in the SiteServer LBS also can use J2EE WEB container or .NET application framework to realize the function of HTTP request interception at above-mentioned steps S401.Embodiment does not repeat them here.
The method of the specific request directional process of realization that provides according to the embodiment of the invention, the embodiment of the invention also provides a kind of device of realizing specific request directional process, as shown in Figure 5, comprising: determiningunit 501 andretransmission unit 502; Wherein:
Determiningunit 501 when determine to need handling the request that client initiates, determines that whether this request is the request of specific business function.
Retransmission unit 502, when definite result of determiningunit 501 when being, this request is forwarded to the node of this specific business function correspondence.
The device of the specific request directional process of the realization that the embodiment of the invention provides as shown in Figure 5, can also comprise:memory cell 503;
Memory cell 503, be used for storing the every specific business function that sets in advance and the corresponding relation between the Network Load Balance system node IP address, and every specific business function and the corresponding relation between the unified resource identifiers, URIs, the perhaps IP addresses of nodes of the specific business function of the processing that sets in advance of storage and the corresponding relation of URI.
In cell stores is the corresponding relation between the node IP address in every specific business function and the Network Load Balance system, and under the situation of every specific business function and the corresponding relation between the unified resource identifiers, URIs, really orderunit 501 in the device of the specific request directional process of the realization that the embodiment of the invention provides, as shown in Figure 6, specifically can also comprise: obtainsubelement 601, thefirst coupling subelement 602 and firstdefinite subelement 603, wherein:
Obtainsubelement 601, be used for the URI that the request of obtaining is carried.
Thefirst coupling subelement 602, the URI that is used for this request is carried mates with the specific business function ofmemory cell 503 storages and the URI in the corresponding relation between the URI; And when the match is successful, according to the specific business function of this URI correspondence, and the specific business function ofmemory cell 503 storage and the corresponding relation between the node IP address, determine the IP addresses of nodes of URI correspondence.
First determinessubelement 603, is used for determining that according to the matching result of thefirst coupling subelement 602 whether this request is the request of specific business function.
Accordingly,retransmission unit 502 also is used for the IP addresses of nodes of determining is replaced the purpose IP address of this request; And the node that request is forwarded to the IP address correspondence after the replacement.
Inmemory cell 503 storage is to handle under the situation of corresponding relation of the IP addresses of nodes of specific business function and URI, really order unit in the device of the specific request directional process of the realization that the embodiment of the invention provides, can comprise following submodule: obtain subelement, the second coupling subelement and second definite subelement, the syndeton of each submodule is similar among each submodule connection diagram and Fig. 6.The function declaration that obtains subelement, the second coupling subelement and second definite subelement is as follows:
Obtain subelement, be used for the URI that the request of obtaining is carried;
The second coupling subelement, the URI that is used for obtaining in the corresponding relation of the IP addresses of nodes of the specific business function of the processing of URI that request that subelement gets access to carries and cell stores and URI mates, when the match is successful, determine the IP addresses of nodes of this URI correspondence;
Second determines subelement, is used for determining that according to the matching result of the second coupling subelement whether this request is the request of specific business function.
Accordingly, in these cases,retransmission unit 502 also is used for the IP addresses of nodes of this URI correspondence is replaced the purpose IP address of this request, and the node that request is forwarded to the IP address correspondence after the replacement.
The method and the device of the specific request directional process of the realization that the embodiment of the invention provides, when the node in the Network Load Balance system is determined its request that need handle the client initiation according to existing Network Load Balance algorithm, further, determine that whether this request is the request of specific business function, when definite result when being, this request is forwarded to the node of predefined this specific transactions function correspondence.The method and the device of the specific request directional process of the realization that the embodiment of the invention provides, on the basis of existing network load-balancing technique, flow process to the node processing request is improved, to carrying out the request of directional process by the node of appointment, the node that is forwarded to setting is handled, and, then carry out normal process according to the flow process of existing network load balancing method for the request that does not need directional process.Like this, not only can guarantee the effect of Network Load Balance for the equilibrium distribution of network traffics, and realized may command to the flow of the specific business function of a part, better with the directional process combination of Network Load Balance and Business Stream, it is more flexible to make Network Load Balance use, and the scope of application is more extensive.
Obviously, those skilled in the art can carry out various changes and modification to the present invention and not break away from the spirit and scope of the present invention.Like this, if of the present invention these are revised and modification belongs within the scope of claim of the present invention and equivalent technologies thereof, then the present invention also is intended to comprise these changes and modification interior.