Summary of the invention
Main purpose of the present invention is to disclose a kind of web station system and communication means thereof, is used to solve existing web station system and is not easy to problems such as expansion, carrying visit capacity and access efficiency are low.
For reaching above-mentioned purpose, the present invention discloses a kind of web station system, comprises being used for WEB server that the PHP page appears and the application server cluster that separates with it; Said application server cluster is made up of the two levels server and the common database that connects thereof of C language code at least; The first order is the access server that is mainly used in to the service request distributing application servers; The second level is the two or more application servers by functional classification, and said application server cluster connects into a local area network (LAN); Wherein said WEB server establishes communication with the PHP interpreter and is connected, and said PHP interpreter establishes communication with the PHP expansion module and is connected, and said PHP expansion module establishes communication with the access server of said application server cluster and is connected.
According to above-mentioned web station system, the present invention also discloses a kind of corresponding with it communication means, may further comprise the steps:
The user sends service request through the PHP page;
WEB server calls PHP interpreter is to explain this service request;
Said PHP interpreter calls the PHP expansion module and converts this service request to service request that application server cluster can be discerned;
Said PHP expansion module is selected an access server and is distributed said service request from said application server cluster, and the service request after this access server sends conversion;
This access server is selected the said service request of an application server processes according to the type of service request;
After finishing dealing with, this application server returns to the PHP page with the reverse path of the said service request in result edge.
Compared with prior art, web station system disclosed by the invention and communication means thereof have the following advantages at least:
1, because the efficient of the code of C language is the highest in the code of all language, and ripe code also is maximum, can expand also is the most flexibly; Therefore background server adopts the code of C language to improve communication and data processing efficiency in the web station system framework disclosed by the invention, for the stable operation of web station system provides guarantee, has reduced the cost of safeguarding.
2, the service application function is separated from the WEB server; And adopt the code of C language to realize; And come communicating by letter between bridge joint background application server cluster and the WEB server through the PHP expansion module; When the user increases a self-defined application newly, only need in application server cluster, increase an application server newly and just become; And the PHP expansion module need not especially to know the backstage is how to carry out data processing.Therefore this framework is that the expansion of business function provides great convenience.
3, because the load of the application server cluster on backstage is extendible; And also have high concurrent characteristic based on the WEB server of PHP; And the application server cluster on backstage can alleviate the service processing pressure of separate unit application server through load-balancing mechanism, thereby makes disclosed web station system of the present invention and communication means thereof satisfy big capacity, high concurrent and high efficiency requirements for access.
4, because the present invention adopts the application server cluster request of managing business; So long as not whole application servers machine of delaying that breaks down, then can guarantee the stable operation of whole system through the coordination mechanism between server cluster inner fault detect, Restoration Mechanism and the application server.
5, the disclosed web station system of the present invention presents the PHP page in the PHP+mysql framework that function and service application function are integrated in one than existing WEB server; The variation more of the conversion link of user's request; The processing mode of background server is variation more also; With related data in the storehouse of asking to read and write data according to the user is example, and then the arbitrary server in this server cluster can carry out handled to this user's request, and can the related data of handling be buffered in this locality earlier; With alleviation data of database processing pressure, thereby make that this web station system flexibility is high, the also corresponding raising of treatment effeciency.
Embodiment
The present invention provides a kind of high concurrent, extendible web station system and communication means thereof, elaborates below in conjunction with the Figure of description specific embodiments of the invention.
Embodiment one
As shown in Figure 1, web station system disclosed by the invention comprises: based on the WEB server 1 of PHP, and PHP expansion module 2 and application server cluster 3.Wherein:
(it is the online application service by its specific business needs of completion of enterprise's issue to WEB server 1; Other companies or application software can visit and use this online service through Internet); Being used for the PHP page appears and receives the service request that the user sends through PHP (Hypertext Preprocessor, the supertext preliminary treatment language) page; In the present embodiment, this WEB server 1 also embeds has the PHP interpreter, and this PHP interpreter is used to carry out the PHP program, and PHP is generated HTML (Hyper Text Mark-up Language, HTML or HTML); When the user sent service request through the PHP page, this WEB server can call this service request of PHP interpreter interprets.In other embodiments, this this PHP interpreter also can be deployed on another server that separates with the WEB server, and this kind conversion belongs to protection scope of the present invention too.
PHP expansion module 2 is used for accomplishing communicating by letter between WEB server 1 and the application server cluster 3 jointly with the PHP interpreter, to realize the conversion and the transmission of service request, data.In the present embodiment, this PHP expansion module 2 is mainly used in the service request that the PHP interpreter interprets is gone out and converts the service request that application server cluster 3 can be discerned to, and this request after will changing is transmitted to the application server cluster 3 on backstage; And convert the result that application server cluster 3 returns to content that the PHP page can appear, and the result after will changing is transmitted to WEB server 1.
Application server cluster 3, comprise the access server 31,32 that connects into a local area network (LAN), database 33 (comprise according to data structure organize, the database server of storage and management data) andapplication server 35,36,37,38.Wherein this access server 31,32 is used to the service request distributing application servers, and communicates by letter with 2 completion of PHP expansion module, is the first order server of this application server cluster.In the present embodiment, be shared as target with file data, need to supply in the local area network (LAN) the shared document storage of many computers in a computer, this computer just is called as the file-sharing service device.Wherein, the switch/router in this document share service device and the local area network (LAN) is all not shown in Fig. 1, and this is all the prior art of building local area network (LAN) that those skilled in the art can realize easily, does not give unnecessary details at this.
In the present embodiment, above-mentioned access server 31,32 is mainly used in the application server of allocation process service request; When distributing application servers, can distribute according to the type of service request, be example with a voice-enabled chat chamber web station system, the service request from user type includes but not limited to following several kinds:
Logging in chat room, authentication, read-write user materials for registration looks for the people to chat, service request types such as chatroom management.
For this reason, in the disclosed application server cluster of present embodiment, the application server of handling the different kinds of business request is pressed functional classification; As shown in Figure 1, theapplication server 35,36,37,38 of pressing functional classification is the second level server of this application server cluster.Wherein with the WEB server be mainly used in handle HTTP request (request) different be that it is application program provider industry logic that application server comes through a lot of agreements, therefore claims apps server again.In the present embodiment, corresponding with the request type of service request from user, eachapplication server 35,36,37,38 can divide the work to realize following a kind of, two or more function:
Logging in chat room, authentication, read-write user materials for registration is joined with machine speed, Audio Processing, chatroom management, chatroom information issue etc.
In the present embodiment; This application server cluster 3 is provided with two access servers 31,32; Wherein access server 31 is main access server; Access server 32 is subsequent use access server, when main access server 31 breaks down, carries out corresponding data processing by subsequent use access server 32.Adopt the mechanism of active and standby access server, effectively solve the web station system problem of service interruption that is caused when single access server breaks down.
In other embodiments; This application server cluster 3 can also be provided with the access server more than three or three; When the quantity of access server increases; Data transmission link between PHP expansion module 2 and the access server is also corresponding to be increased, so the user that this web station system can concurrent processing request also increases thereupon.Wherein this PHP expansion module 2 can distribute according to mode at random when distributing access server for service request, also can give the poll scheduling algorithm and distribute, and also can carry out flow equalization according to the current loading condition of each access server and distribute.
In the present embodiment, the code of each application server in the above-mentioned application server cluster 3 is by the C language.On the development history of computer, the assembly of C language has accumulated a large amount of experiences and ripe code, and efficient is the highest, and extensibility also is the most flexibly.And between the inner stages server of above-mentioned application server cluster 3 and and PHP expansion module 2 between all be through UDP (User Datagram Protocol; User Datagram Protocol) mode is set up communication; Efficient program means through the C language; The service request that the user is sent is divided into the UDP object accesses of opposition, rather than adopts TCP (Transmission Control Protocol, a transmission control protocol) mode of being used to connect; Just can not set up communication because UDP need not connect, further improve the access efficiency of web station system with the application server cluster of rear end.
The framework of the disclosed web station system of present embodiment has extensibility very flexibly; When this system need increase an application newly; Mass-send the message of Added Business types to application server cluster 3 formerly by newly-increased application server; In internal memory, preserve this Added Business type and should increase the mapping relations between the application server newly by this application server cluster 3 eachserver 31,32,35,36,37,38 formerly then; Whenarbitrary server 31,32,35,36,37,38 formerly when receiving the service request that the PHP page sends; Type and the mapping relations in the internal memory according to this service request judge whether it is handled by this newly-increased service server, if, to this Added Business server forwards corresponding business request.Make thus in the native system; Application server 1~4 has also had the function of transmitting service request by type of access server; Thereby arbitrary application server 1~4 can be used as the backup of access server; Guaranteed that service request sends to corresponding application server exactly, improved the stability and the extensibility of system.
To sum up, but present embodiment discloses PHP+PHPExtend+C+UDP+MYSQL (MYSQL is a kind of database of the open source code) web site architecture of the flexible expansion of a kind of access efficiency that improves the website and application, and this framework is called for short PPCUM.Wherein application server cluster 3 is made up of the two levels server and the common database that connects thereof of C language code at least; The first order is the access server 31,32 that is mainly used in to the service request distributing application servers; The second level is the two ormore application servers 35,36,37,38 by functional classification, and application server cluster connects into a local area network (LAN); Wherein the WEB server establishes to communicate by letter with the PHP interpreter and is connected, and the PHP interpreter establishes communication with the PHP expansion module and is connected, and the PHP expansion module establishes communication with the access server of application server cluster and is connected.Make this PPCUM web station system have the following advantages thus:
1, because the efficient of the code of C language is the highest in the code of all language, and ripe code also is maximum, can expand also is the most flexibly; Therefore background server adopts the code of C language to improve communication and data processing efficiency in the web station system framework disclosed by the invention, for the stable operation of web station system provides guarantee, has reduced the cost of safeguarding.
2, the service application function is separated from the WEB server; And adopt the code of C language to realize; And come communicating by letter between bridge joint background application server cluster and the WEB server through the PHP expansion module; When the user increases a self-defined application newly, only need in application server cluster, increase an application server newly and just become; And the PHP expansion module need not especially to know the backstage is how to carry out data processing.Therefore this framework is that the expansion of business function provides great convenience.
3, because the load of the application server cluster on backstage is to expand (for example expanding through the mode that increases application server and/or access server); And also have high concurrent characteristic based on the WEB server of PHP; And the application server cluster on backstage can alleviate the service processing pressure of separate unit server through load-balancing mechanism, thereby makes disclosed web station system of the present invention and communication means thereof satisfy big capacity, high concurrent and high efficiency requirements for access.
4, because the present invention adopts the application server cluster request of managing business; Above-mentioned application server cluster connects into a local area network (LAN), and (what be worth explanation is; Above-mentioned WEB server and PHP expansion module also can be regarded as the part of this local area network (LAN); Wherein this WEB server is connected with public network through fire compartment wall); So long as not whole application servers machine of delaying that breaks down, then can guarantee the stable operation of whole system through the coordination mechanism between server cluster inner fault detect, Restoration Mechanism and the application server.
5, the disclosed web station system of present embodiment presents the PHP page in the PHP+mysql framework that function and service application function are integrated in one than existing WEB server; The variation more of the conversion link of user's request; The processing mode of background server is variation more also; With related data in the storehouse of asking to read and write data according to the user is example, and then the arbitrary server in this server cluster can carry out handled to this user's request, and can the related data of handling be buffered in this locality earlier; With alleviation data of database processing pressure, thereby make that this web station system flexibility is high, the also corresponding raising of treatment effeciency.
What be worth explanation is that among the present invention, the PHP expansion module can be the external module of PHP interpreter, also can be that the interior modeling piece of this PHP interpreter is perhaps directly expanded in Zend engine the inside.Wherein external module can move SO () function at script and is written into, and this function is written into a shared object and its function bound and make it with the script that calls this function from disk and comes into force.Among the present invention; Preferably in the php.ini file, use extension tag to create the PHP expansion module of an outside; This PHP expansion module separates with the PHP interpreter fully, and the mode that its advantage is this PHP interpreter through " outsourcing " lets the volume of oneself keep very little.In adopting during the modeling piece; This PHP expansion module is advanced the PHP interpreter by direct compilation and is present in each PHP to handle in the request; Its shortcoming is when revising this PHP expansion module, need recompilate PHP, and the PHP binary file can become big and can consume more internal memory.As for expanding PHP through the Zend engine, then cause incompatible with other code easily, should avoid usually as far as possible.
Embodiment two
To embodiment one disclosed web station system framework, present embodiment discloses the inner communication process of this web station system, and as shown in Figure 2, the communication process of this web station system may further comprise the steps:
Step S1, user send service request through the PHP page.
Step S2, WEB server calls PHP interpreter are to explain this service request.
Step S3, PHP interpreter call the PHP expansion module and convert this service request to service request that application server cluster can be discerned.
Step S4, PHP expansion module are selected an access server distribution service request from application server cluster, and the service request after this access server sends conversion.
In this step; The quantity of access server is two or more in the application server cluster of this web station system, and the PHP expansion module is selected an access server distribution service request from application server cluster the mode of selecting can be to be selected or polling mode is selected at random.
When between the above-mentioned application server cluster and with the PHP expansion module between set up when communicating by letter through the UDP mode; Preferably; This PHP expansion module is packaged into this service request the UDP object and binds a dynamic port before the service request after this application server sends conversion; And after sending above-mentioned service request through this dynamic port, this PHP expansion module is also waited for the result that application server and access server return through synchronous or port block mode on this dynamic port.
Step S5, this access server are selected an application server processes service request according to the type of service request.Wherein, In this locality of the database of this web station system or file-sharing service device or this access server, store the load condition of current each server of application server cluster, access server can be selected the light application server processes corresponding business request of load according to request type.Further; This access server also should be according to the existing state distribution service request of each application server; For this reason, this access server is safeguarded the server list that each application server existing state of reaction is arranged, and regularly detects and/or go to detect according to Event triggered the existing state of each application server; When arbitrary application server breaks down when delaying machine, in server list, be survival with this application server identifier; Then, this application server is informed access server through UDP behind the machine recovering state of delaying, and in server list, is survival with this application server identifier by access server again; So that access server is selected the application server processes corresponding business request that load is light and survive according to request type.
Preferably, in the forwarding and processing procedure of this service request, the PHP expansion module that access server and above-mentioned steps S4 mention generates a unique session according to this service request, and in the first-class result of treating that application server returns of this session port.So, then the server of each between the application server cluster has possessed a synchronization mechanism, has guaranteed the uniqueness of service request that each application server is handled through conversation mechanism, has effectively avoided data service to cause confusion.
Step S6, finish dealing with after, this application server returns to the PHP page with result along the reverse path of service request.
In the present embodiment, when network system increased an application server newly, above-mentioned communication means also comprised the steps S7~S9:
Step S7, this newly-increased service server are to application server cluster mass-sending Added Business kind of message.
Preferably, this newly-increased application server can also be further be saved in its Added Business type and the type and the mapping relations of self in server cluster institute data shared storehouse or the file-sharing service device, obtains for formerly each server.
Step S8, this application server cluster each server is formerly preserved this Added Business type and should be increased the mapping relations between the application server newly in internal memory.
Step S9, arbitrary server formerly are when receiving the service request of PHP page transmission; Type and above-mentioned mapping relations according to this service request judge whether it is handled by this newly-increased service server; If, to this Added Business server forwards corresponding business request.Make thus in the native system; Application server has also had the function of transmitting service request by type of access server; Thereby arbitrary application server can be used as the backup of access server; Guaranteed that service request sends to corresponding application server exactly, improved the stability and the extensibility of system.
Meanwhile, this newly-increased application server also can obtain the traffic type information of each server formerly from database or file-sharing service device, and transmits the corresponding business request according to this information.
Above-mentioned communication means disclosed by the invention has the following advantages at least:
1, because the efficient of the code of C language is the highest in the code of all language, and ripe code also is maximum, can expand also is the most flexibly; Therefore background server adopts the code of C language to improve communication and data processing efficiency in the web station system framework disclosed by the invention, for the stable operation of web station system provides guarantee, has reduced the cost of safeguarding.
2, the service application function is separated from the WEB server; And adopt the code of C language to realize; And come communicating by letter between bridge joint background application server cluster and the WEB server through the PHP expansion module; When the user increases a self-defined application newly, only need in application server cluster, increase an application server newly and just become; And the PHP expansion module need not especially to know the backstage is how to carry out data processing.Therefore this framework is that the expansion of business function provides great convenience.
3, because the load of the application server cluster on backstage is extendible; And also have high concurrent characteristic based on the WEB server of PHP; And the application server cluster on backstage can alleviate the service processing pressure of separate unit application server through load-balancing mechanism, thereby makes disclosed web station system of the present invention and communication means thereof satisfy big capacity, high concurrent and high efficiency requirements for access.
4, because the present invention adopts the application server cluster request of managing business; So long as not whole application servers machine of delaying that breaks down, then can guarantee the stable operation of whole system through the coordination mechanism between server cluster inner fault detect, Restoration Mechanism and the application server.
5, the disclosed web station system of the present invention presents the PHP page in the PHP+mysql framework that function and service application function are integrated in one than existing WEB server; The variation more of the conversion link of user's request; The processing mode of background server is variation more also; With related data in the storehouse of asking to read and write data according to the user is example, and then the arbitrary server in this server cluster can carry out handled to this user's request, and can the related data of handling be buffered in this locality earlier; With alleviation data of database processing pressure, thereby make that this web station system flexibility is high, the also corresponding raising of treatment effeciency.
To sum up; The disclosed communication means of present embodiment has the high concurrent treatment mechanism of user; Can the dynamic expansion application service and guarantee the uniqueness of each application server processes service request; And can, application server in time find and solve fault when breaking down through the survival testing mechanism of access server.Thereby having solved existing web station system existingly is not easy to expansion, carries problems such as visit capacity and access efficiency are low.
More than disclosedly be merely several specific embodiment of the present invention, still, the present invention is not limited thereto, any those skilled in the art can think variation all should fall into protection scope of the present invention.