Summary of the invention
The application's technical problem to be solved provides a kind of methods, devices and systems of agent processes data; Simplified the logical architecture of front-end server; Solved between a plurality of agencies because network connects the problem that the request that causes can't be handled, and reduced machine cost and maintenance cost.
In order to address the above problem, the application discloses a kind of method of agent processes data, comprising:
Resolve the access request that agency place front-end server sends, obtain to comprise the solicited message of service numbers and processing logic;
Search the configuration information of the corresponding service server cluster of said service numbers through service numbers;
Send packet each server to the corresponding service server cluster of service numbers according to said configuration information, said packet comprises the request of obtaining each server ruuning situation information; And analyze the ruuning situation information in the packet that said each server returns;
From said each server, select a normal destination server of operation, and said processing logic is sent to said destination server;
Obtain result that destination server returns and said result is returned front-end server.
Preferably, before the access request of receiving front-end server, also comprise:
The configuration file of loaded with traffic server cluster, said configuration file comprises the number information of service of service server cluster, the IP information of each server in port information and the said cluster.
Preferably,, the processing logic with described request also comprises before sending to said destination server:
With the type conversion of the processing logic of described request is the type of the processing logic of destination server.
Preferably, also comprise during loading configuration file:
Load the processing logic of said professional cluster, and load will be different with this professional cluster the processing logic type conversion be the translation-protocol with the same processing logic type of this services sets faciation.
Preferably, the processing logic type conversion that loading will be different with this professional cluster be with this services sets faciation with the translation-protocol of processing logic type the time:
Processing logic type conversion that will be different with this professional cluster through the loading external scripts is and this services sets faciation processing logic type together.
Preferably, said ruuning situation information comprises each server load information of said service server cluster, and/or master server group and the heartbeat message that is equipped with the server group in the said service server cluster.
When preferably, from said each server, selecting the normal destination server of operation:
When the heartbeat of master server group stops or load when excessive, from being equipped with normal destination server of operation of server group selection.
Preferably, the agency is connected with back-end server through socket.
Accordingly, disclosed herein as well is a kind of device of agent processes data, comprising:
Parsing module is used to resolve the access request that agency place front-end server sends, and obtains to comprise the solicited message of service numbers and processing logic;
Search module, be used for searching the configuration information of the corresponding service server cluster of said service numbers through service numbers;
The operating analysis module is used to send packet to arrive each server of the corresponding service server cluster of service numbers, and said packet comprises the request of obtaining each server ruuning situation information; And analyze the ruuning situation information in the packet that said each server returns;
Select module, be used for selecting a normal destination server of operation, and said processing logic is sent to said destination server from said each server;
Return module, be used to obtain result that destination server returns and said result is returned front-end server.
Preferably, before receiver module, also comprise:
Load-on module is used for the configuration file of loaded with traffic server cluster, and said configuration file comprises the service numbers of service server cluster, the IP information of each server in port information and the said cluster.
Preferably, before sending module, also comprise:
Modular converter is the type of the processing logic of destination server with the type conversion of the processing logic of described request.
Preferably, also comprise during loading configuration file:
Load the processing logic of said professional cluster, and load will be different with this professional cluster the processing logic type conversion be the translation-protocol with the same processing logic type of this services sets faciation.
Preferably, the processing logic type conversion that loading will be different with this professional cluster be with this services sets faciation with the translation-protocol of processing logic type the time:
Processing logic type conversion that will be different with this professional cluster through the loading external scripts is and this services sets faciation processing logic type together.
Preferably, said ruuning situation information comprises each server load information of said service server cluster, and/or master server group and the heartbeat message that is equipped with the server group in the said service server cluster.
When preferably, from said each server, selecting the normal destination server of operation:
When the heartbeat of master server group stops or load when excessive, from being equipped with normal destination server of operation of server group selection.
Preferably, the agency is connected with back-end server through socket.
Accordingly, disclosed herein as well is a kind of system of agent processes data, comprising:
Front-end server and at least one service server cluster;
Said front-end server comprises the agent processes module; Said agent processes module comprises:
Analyzing sub-module is used to resolve the access request that agency place front-end server sends, and obtains to comprise the solicited message of service numbers and processing logic;
Search submodule, be used for searching the configuration information of the corresponding service server cluster of said service numbers through service numbers;
The operating analysis submodule; Be used to send each server that ping wraps the corresponding service server cluster of service numbers; Said ping comprises the request of obtaining each server ruuning situation information, and analyzes the ruuning situation information in the ping bag that said each server receive returns;
The chooser module is used for selecting a normal destination server of operation from said each server, and said processing logic is sent to said destination server;
Return submodule, be used to obtain result that destination server returns and said result is returned front-end server.
Compared with prior art, the application comprises following advantage:
The application is through being provided with proxy module on front-end server; Each backend services server cluster of the unified visit of interface that front-end server provides through this proxy module can carry out functions such as load adjustment, disaster tolerance through this proxy module realization simultaneously to the backend services server cluster.Through the application, at first, can each agent functionality be concentrated on the proxy module of front-end server, making front end only need visit home agent module can carry out alternately with the backend services server cluster; Secondly, the application is arranged on the agency in the front-end server, need not a plurality of independent hardware devices and goes to realize agent functionality separately, has reduced machine cost and maintenance cost; Once more, the deal with data of various agent functionalitys is to communicate in process inside, can not cause various agent functionalitys to inherit because of the network reason, thereby causes asking the problem that can't handle.
Embodiment
For above-mentioned purpose, the feature and advantage that make the application can be more obviously understandable, the application is done further detailed explanation below in conjunction with accompanying drawing and embodiment.
The internet, applications more complicated is various, provides the program of service or the service will be many accordingly, and if under such situation front-end server such as web/im with other back-end server (storage of service is provided; Complex logic is calculated; The third party is mutual) all take place alternately, the framework of logical server is required just than higher, and mutual logic can become increasingly complex; If add the cluster load; Hash, the processing of situation such as disaster tolerance, logical architecture is a very big challenge.The application's agency mainly is accomplished leading portion logical AND rear end stand-alone service function mutual; Be the mutual of front-end server and backend services server cluster; Avoid the leading portion logic too too fat to move, can also carry out cluster load, hash; Situation such as disaster tolerance make that the logical services of leading portion is that front-end server only need be paid close attention to the processing logic of oneself and disposable mutual with what act on behalf of.
With reference to Fig. 1, show the schematic flow sheet of the method for a kind of agent processes data of the application, comprising:
Step 110 is resolved the access request that agency place front-end server sends, and obtains to comprise the solicited message of service numbers and processing logic.
Receive the request of client at front-end server after; When logical process is carried out in the request of client; Generally need corresponding rear end to provide the service server (such as storage, complex logic is calculated, and the third party is mutual etc.) of respective service that service is provided; Will send respective request so and go to handle, to obtain corresponding data to the respective rear ends server.And the application's front-end server only need get final product the agency that request sends in the book server.
After acting on behalf of the access request of the front-end server transmission that receives its place, resolve its received access request, obtain to comprise the information that call request such as service numbers and processing logic.
In reality, before this step, also comprise:
Load step, the configuration file of loaded with traffic server cluster, said configuration file comprises the number information of service of service server cluster, the IP information of each server in port information and the said cluster.
In reality, for the miscellaneous service server cluster,, need in the agency, load the configuration file that comprises said service server cluster information if carry out alternately with front end through the agency, make the agency know the information of service server cluster.Wherein, said configuration file comprises the number information of service of service server cluster, the IP information of each server in port information and this cluster.In reality, in order to carry out disaster tolerance, each server also is provided with the master server group and is equipped with the server group, also comprises the active and standby situation information of each server in the so described configuration file.
In addition, if added new service server cluster, only need should the business cluster configuration file be loaded among the agency and get final product, front-end server also can carry out with the service server cluster of new interpolation through the agency alternately.
Step 120 is searched the configuration information of the corresponding service server cluster of said service numbers through service numbers.
In reality, the configuration file of each professional cluster server is loaded in advance as previously mentioned, in the agency, promptly there is the configuration information of corresponding service server cluster so.Wherein, the service server cluster is as the sign of its configuration information with corresponding business number.After getting access to the service numbers of access request so, can search the configuration information with the corresponding professional cluster of service numbers, comprise the port of professional cluster, IP, and/or information such as active and standby situation according to service numbers.
Step 130 is sent packet each server to the corresponding service server cluster of service numbers according to said configuration information, and said packet comprises the request of obtaining each server ruuning situation information; And analyze the ruuning situation information in the packet that said each server returns.
As previously mentioned, described configuration comprises the port of service server cluster, IP, and information such as active and standby situation can be known the information such as port, IP of each server of service server cluster through configuration information.So can be according to the port and the IP of each server, packet is sent in each server with service numbers corresponding service server cluster.Wherein, described packet comprises the request of obtaining each server ruuning situation information, such as the loading condition of each server, and/or master server group and the heartbeat message that is equipped with the server group in the said service server cluster.
After each server receives the described request packet,, self information such as loading condition, heartbeat message is sent to the agency according to the request in the packet.In reality; If a station server does not have heartbeat; The general packet that does not just have load information and heartbeat message returns, and promptly the agency sends to the not response of packet of this station server, in certain hour section threshold value, does not also receive said packet so; Can judge that so this station server stops heartbeat, when follow-up selection server, get rid of this station server.
The agency is for its loading condition that comprised of each server that receives, and the packet of information such as heartbeat message is analyzed, and analyzes loading condition and disaster tolerance situation of each server etc.
In reality, the agency sends through the form of timed sending ping bag and comprises the request of obtaining each server ruuning situation information, and receives the ping bag that each server returns.
In addition, in reality, the agency is connected with each server of backend services server cluster through socket.
A plurality of TCP connect or a plurality of program process possibly need through same Transmission Control Protocol port transmission data.In order to distinguish different program process and to be connected, computer operating system is that application program and ICP/IP protocol provide the interface that is called socket (Socket) alternately.
3 kinds of Socket types of ICP/IP protocol commonly used are as follows:
Stream Socket (SOCK_STREAM): Stream Socket is used to provide towards connection, reliable data transport service.This service will guarantee that data can realize zero defect, not have and repeat to send, and receive in order.Why Stream Socket can realize reliable data, services, and reason is that it has used transmission control protocol, i.e. TCP (The Transmission Control Protocol) agreement.
Datagram Socket (SOCK_DGRAM): Datagram Socket provides a kind of connectionless service.This service can not guarantee reliability of data transmission, and data might lose or occur data and repeat in transmission course, and can't guarantee sequentially to receive data.Datagram Socket uses UDP (User Datagram Protocol) agreement to carry out the transmission of data.
Raw socket (SOCK_RAW): the difference of raw socket and standard socket (the standard socket refers to Stream Socket and the Datagram Socket that the front is introduced) is: raw socket can be read and write the IP packet that kernel does not have processing; And Stream Socket can only read the data of Transmission Control Protocol, and Datagram Socket can only read the data of udp protocol.Therefore, must use raw socket if visit other agreements transmission data.
Distinguish between the different application process network service be connected, mainly contain 3 parameters: the port numbers of the purpose IP address of communication, the transport layer protocol of use (TCP or UDP) and use.
Step 140 is selected a normal destination server of operation from said each server, and said processing logic is sent to said destination server.
Analyzed through abovementioned steps with request corresponding business cluster in the ruuning situation of each server after, from said each server, select a normal destination server of operation, and said processing logic sent to said destination server.
In reality, for front end for a large amount of access request of a professional cluster, can carry out load balance process in this step.Generally be to carry out load balancing through hash (Hash) algorithm.Such as, if it is normal to have analyzed the load of N station server, can select in the service of N platform one that an access request is distributed in the N station server through following steps so:
A1, with the various situation of various integer divisions with the remainder that arrives of N, average corresponding each station server.
Such as, during N=4, various integer divisions are 0,1,2,3 with the situation of 4 remainders that obtain, so the corresponding station server of each remainder.
A2 carries out the hash computing with an access request through the hash function and obtains an integer value.
A3 divided by N, obtains the remainder after the computing with said integer value.
A4 according to the corresponding relation of remainder after the said computing and server, sends to the processing logic of described request the destination server of correspondence.
Wherein, said ruuning situation information comprises each server load information of said service server cluster, and/or master server group and the heartbeat message that is equipped with the server group in the said service server cluster.
Preferably, stop or load when excessive, when the heartbeat of master server group from being equipped with normal destination server of operation of server group selection.
Such as, if when the load of master server group is excessive, can be from being equipped with normal destination server of operation of server group selection.
Again such as, if a certain machine heartbeat of master server group stops, promptly hanging, can call the standby machine polishing so.If the heartbeat of whole master server group stops, will being equipped with the lifting of server group so and handling for the master server group.
In addition, preferred,, the processing logic with described request also comprises before sending to said destination server:
With the type conversion of the processing logic of described request is the type of the processing logic of destination server.
In some cases; Such as carrying out the third party when mutual; Processing logic in the access request of front-end server possibly carry out the processing logic difference of third party's interactive server cluster with the rear end; Username and password such as the processing logic in the front-end server access request is the text type; And the username and password of rear end third party's interactive server cluster processing logic is 256 key types, need convert the text type processing logic of front end into rear end key type processing logic so, and the processing logic type conversion that is about to front end is consistent with the processing logic type of rear end.
For above-mentioned conversion, in reality, can conversion method be loaded in load step, promptly also comprise during loading configuration file:
Load the processing logic of said professional cluster, and load will be different with this professional cluster the processing logic type conversion be the translation-protocol with the same processing logic type of this services sets faciation.
In addition, the processing logic type conversion that loading will be different with this professional cluster be with this services sets faciation with the translation-protocol of processing logic type the time:
Processing logic type conversion that will be different with this professional cluster through the loading external scripts is and this services sets faciation processing logic type together.
Step 150 is obtained result that destination server returns and said result is returned front-end server.
After the destination server of the rear end that the processing logic of the access request of front-end server is sent to corresponding service number through abovementioned steps was handled, the respective objects server can return a result.Then the agency can get access to the result that destination server returns, and after getting access to result, can front-end server be returned in said result arrangement.
In addition; In step 110; Access request for a front-end server; Possible its needs a plurality of professional cooperations to handle, and can parse the processing logic of a plurality of service numbers and corresponding service number so, then in subsequent step to service numbers and handled logic carry out steps 120 equally; Step 130 and step 140, the data processed result of returning for the server at least one service server cluster then rearrange by the order of access request requirement and return to front-end server.
In said process, front-end server carries out disposable mutual as for the agency, can obtain the result for access request.And in this process, agency's various functions are carried out in same process, and the deal with data between the various functions is through intercom the broken string between the various functions that the instability of having avoided network to connect causes mutually in-process.
With reference to Fig. 2, the device that it shows a kind of agent processes data of the application comprises:
Parsing module 210 is used to resolve the access request that agency place front-end server sends, and obtains to comprise the solicited message of service numbers and processing logic;
Search module 220, be used for searching the configuration information of the corresponding service server cluster of said service numbers through service numbers;
Operating analysis module 230 is used to send packet to arrive each server of the corresponding service server cluster of service numbers, and said packet comprises the request of obtaining each server ruuning situation information; And analyze the ruuning situation information in the packet that said each server returns;
Select module 240, be used for selecting a normal destination server of operation, and said processing logic is sent to said destination server from said each server;
Return module, be used to obtain result that destination server returns and said result is returned front-end server.
Wherein, before receiver module, also comprise:
Load-on module is used for the configuration file of loaded with traffic server cluster, and said configuration file comprises the service numbers of service server cluster, the IP information of each server in port information and the said cluster.
Wherein, before sending module, also comprise:
Modular converter is the type of the processing logic of destination server with the type conversion of the processing logic of described request.
Accordingly, said load-on module also is used to load the processing logic of said professional cluster, and load will be different with this professional cluster the processing logic type conversion be the translation-protocol with the same processing logic type of this services sets faciation.
In addition, said load-on module also is used for through loading the processing logic type that the processing logic type conversion is and this services sets faciation is same that external scripts will be different with this professional cluster.
Preferably, said ruuning situation information comprises each server load information of said service server cluster, and/or master server group and the heartbeat message that is equipped with the server group in the said service server cluster.
When preferably, from said each server, selecting the normal destination server of operation:
When the heartbeat of master server group stops or load when excessive, from being equipped with normal destination server of operation of server group selection.
Wherein, the agency is connected with back-end server through socket.
With reference to Fig. 3, the system that it shows a kind of agent processes data of the application comprises:
Front-end server and at least one service server cluster;
Said front-end server comprises agent processes module S320; Said agent processes module comprises:
Analyzing sub-module 321 is used to resolve the access request that agency place front-end server sends, and obtains to comprise the solicited message of service numbers and processing logic;
Search submodule 322, be used for searching the configuration information of the corresponding service server cluster of said service numbers through service numbers;
Operating analysis submodule 323; Be used to send each server that ping wraps the corresponding service server cluster of service numbers; Said ping comprises the request of obtaining each server ruuning situation information, and analyzes the ruuning situation information in the ping bag that said each server receive returns;
Chooser module 324 is used for selecting a normal destination server of operation from said each server, and said processing logic is sent to said destination server;
Return submodule 325, be used to obtain result that destination server returns and said result is returned front-end server.
Like figure, service server cluster A is arranged, service server cluster B etc.The customer side sends to front-end server with the request of its application, and front-end server is needing the backend services server cluster to provide when service that access request is sent to self proxy module, and proxy module carries out with the rear end more alternately.
For system embodiment, because it is similar basically with method embodiment, so description is fairly simple, relevant part gets final product referring to the part explanation of method embodiment.
Each embodiment in this specification all adopts the mode of going forward one by one to describe, and what each embodiment stressed all is and the difference of other embodiment that identical similar part is mutually referring to getting final product between each embodiment.
More than to the methods, devices and systems of the agent processes data that the application provided; Carried out detailed introduction; Used concrete example among this paper the application's principle and execution mode are set forth, the explanation of above embodiment just is used to help to understand the application's method and core concept thereof; Simultaneously, for one of ordinary skill in the art, according to the application's thought, the part that on embodiment and range of application, all can change, in sum, this description should not be construed as the restriction to the application.