Disclosure of Invention
The invention provides a server cluster processing system and a method, which process view registration type client events through a front-end server connected with a connection server, realize that the front-end server shares the work load of the connection server directly facing a client, improve the processing efficiency of a server system, and ensure the processing speed and the service quality of the client events.
In one aspect, the present invention provides a server cluster processing system, including: the system comprises a connection server, a message server and at least one front-end server, wherein the front-end server comprises a front-end server cache engine and a front-end server session control model;
the connection server is used for receiving a client event sent by a client, if the client event is a view registration event, judging whether the connection server has a view registration event processor corresponding to the client event, and if not, sending the client event to the message server;
the front-end server cache engine is configured to monitor the message server, obtain the client event, process the client event to obtain a client event processing result list, and send the client event and the client event processing result list to the front-end server session control model;
the front-end server session control model is used for respectively processing the client event and the client event processing result list to obtain a client event processing result and sending the client event processing result to the message server;
the connection server is also used for monitoring the message server, acquiring the client event processing result and sending the client event processing result to the client.
The invention has the beneficial effects that: the connection server sends the received view registration client events to the message server, the front-end server processes the view registration client events after monitoring the view registration client events and respectively processes different types of client events according to different conditions, so that the work load of the connection server is shared, and the processing quality of the server system on the client events is ensured.
In another aspect, the present invention further provides a server cluster processing method, including:
step 1: a connection server receives a client event sent by a client, if the client event is a view registration event, whether a view registration event processor corresponding to the client event exists in the connection server is judged, and if not, the client event is sent to the message server;
step 2: a front-end server cache engine monitors the message server, acquires the client event, processes the client event to obtain a client event processing result list, and sends the client event and the client event processing result list to the front-end server session control model;
and step 3: the session control model of the front-end server respectively processes the client event and the client event processing result list to obtain a client event processing result and sends the client event processing result to the message server;
and 4, step 4: and the connection server monitors the message server, acquires the client event processing result and sends the client event processing result to the client.
The invention has the beneficial effects that: the connection server sends the received view registration client events to the message server, the front-end server processes the view registration client events after monitoring the view registration client events and respectively processes different types of client events according to different conditions, so that the work load of the connection server is shared, and the processing quality of the server system on the client events is ensured.
Detailed Description
The principles and features of this invention are described below in conjunction with the following drawings, which are set forth by way of illustration only and are not intended to limit the scope of the invention.
Fig. 1 is a block diagram of a server cluster processing system according to an embodiment of the present invention. As shown in fig. 1, the system includes a connection server 110, a message server 120, and at least one front-end server 130.
Fig. 2 is a schematic structural diagram of a front-end server of a server cluster processing system according to an embodiment of the present invention. As shown in fig. 2, the front-end server 130 includes a front-end server caching engine 131 and a front-end server session control model 132.
The connection server 110 is configured to receive a client event sent by the client 140, determine whether the connection server 110 has a view registration event handler corresponding to the client event if the client event is a view registration event, and send the client event to the message server 120 if the client event is not a view registration event.
The front-end server cache engine 131 is configured to monitor the message server 120, obtain the client event, send the client event to the front-end server session control model 132 if the client event is a direct-class event, first process the client event to obtain a client event processing result list if the client event is a cache-class event, and then send the client event processing result list to the front-end server session control model 132.
The front-end server session control model 132 is configured to process the client event and the client event processing result list respectively to obtain a client event processing result, and send the client event processing result to the message server 120.
The connection server 110 is further configured to monitor the message server 120, obtain the client event processing result, and send the client event processing result to the client 140.
It should be noted that there are multiple independent processing threads in the front-end server session control model 132, some of which are used to process the received event, and some of which are used to send the processing result to the message server 120.
In this embodiment, the connection server sends the received view registration type client event to the message server, and the front-end server processes the view registration type client event after monitoring the view registration type client event, and processes different types of client events according to different conditions, such as processing a direct type event and a cache type event, respectively, which not only shares the workload of the connection server, but also ensures the processing quality of the server system on the client event.
Fig. 3 is a schematic structural diagram of a front-end server of a server cluster processing system according to a second embodiment of the present invention. On the basis of the first embodiment, in this embodiment, the front-end server cache engine 131 includes a cache engine unit 135 and a front-end server cache class event handler 133.
The cache engine unit 135 is configured to monitor the message server 120 and obtain the client event; and according to the client event indicating the cache type event, acquiring a front-end server cache type event processor corresponding to the client event, and forming a front-end server cache type event processor list.
The front-end server cache type event handlers 133 in the front-end server cache type event handler list are configured to respectively handle the client events, so as to obtain the client event handling result list.
The cache engine unit 135 is further configured to send the client event processing result list to the front-end server session control model 132.
Specifically, the view registration class client events that the front-end server cache engine 131 hears from the message server 120 include direct class events and cache class events. For direct class events, such as a page enter button, a screen sliding event, etc. sent by the client, the direct class events are sent to the front-end server session control model 132 for processing. For the cache-type event, such as the view change request event, the corresponding front-end server cache-type event handler list is first obtained in a loop, and the front-end server cache-type event handlers 133 in the list respectively process the cache-type event and obtain the client event processing result list, and then send the client event processing result list to the front-end server session control model 132.
The front-end server cache engine 131 presets a client event theme and a corresponding relationship between the client event theme and the front-end server cache event handler 133, and after acquiring a client event, the front-end server cache engine 131 finds the front-end server cache event handlers 133 corresponding to the theme one by one according to the client event theme, and obtains a front-end server cache event handler list. The front-end server cache type event handlers 133 in the front-end server cache type event handler list respectively handle the client event. Therefore, the client event is processed by the front-end server cache type event handler 133 to obtain a client event processing result list.
Preferably, the front-end server session control model 132 includes a session control unit 136 and a front-end server view data model 134.
The session control unit 136 is configured to assign the client event and the client event processing result list to the front-end server view data model 134.
The front-end server view data model 134 is used for processing the client event to obtain a first processing result; and processing the client event processing result list to obtain a second processing result.
The session control unit 136 is further configured to send the first processing result and the second processing result to the message server, respectively, where the first processing result is the view initial content, and the second processing result is the changed part of the view initial content.
Specifically, a client event indicating a direct class event and a client event processing result list indicating a cache class event are respectively sent to the corresponding view data models. The session control models correspond one-to-one to the clients, and thus the number of front-end server session control models 132 in the front-end server 130 depends on the number of client connections.
Since the front-end server 130 is mainly responsible for processing the view class client event, the front-end server session control model 132 includes a front-end server view data model 134, and for the direct class event, the front-end server session control model 132 processes to obtain a first processing result, which is the view initial content. For the cache class event, the front-end server session control model 132 processes the cache class event to obtain a second processing result, where the second processing result is a modified portion of the view initial content. For example, the a client event is monitored and acquired from the message server 120 by the front-end server cache engine 131, and is sent to the front-end server session control model 132 by the front-end server cache engine 131, and the front-end server view data model 134 in the front-end server session control model 132 processes the client event to obtain a result, that is, the view initial content, that is, the first processing result. When the a client event is monitored and acquired from the message server 120 again by the front-end server cache engine 131, and the front-end server session control model 132 receives the client event again, the front-end server view data model 134 processes the event to obtain a b result, and a difference between the a result and the b result is a changed content of the view initial content, that is, a second processing result, and the front-end server session control model 132 encapsulates the changed content into a model message and pushes the model message to the message server 120 through an update thread.
Preferably, the front-end server 130 further comprises a front-end server registration module and a front-end server session control model creation module.
The front-end server registration module is configured to, after the front-end server 130 monitors the view registration event of the client in the message server 120, invoke a login processing method to process the view registration event, and obtain and return a login processing result to the message server 120.
The front-end server session control model creating module is configured to create the front-end server session control model 132 corresponding to the client 140 after the client 140 successfully logs in.
In this embodiment, the connection server sends the received view registration type client event to the message server, and the front-end server processes the view registration type client event after monitoring the view registration type client event, and separately processes different types of client events according to different situations, such as separately processing a direct type event and a cache type event, which shares the workload of the connection server and ensures the processing quality of the server system for the client event.
On the basis of the above-described embodiment, as a preferred embodiment of the present invention, in the preferred embodiment, the connection server 120 includes a connection server cache engine, a connection server session control model, and a front-end server heartbeat monitor.
And the connection server cache engine is used for monitoring and acquiring the client event processing result and sending the client event processing result to the connection server session control model.
The connection server session control model is used to send the client event processing result to the client 140 corresponding to the connection server session control model.
The front-end server heartbeat monitor is configured to monitor communication time of the connection server 120 and the front-end server 130, generate a front-end server connection failure server event if an interval between the current communication time and the latest communication time is greater than a preset time interval, and send the front-end server connection failure server event to the connection server session control model.
The connection server session control model is further configured to generate a front-end server connection failure notification event according to the front-end server connection failure server event, and send the front-end server connection failure notification event to the client 140 corresponding to the connection server session control model.
Specifically, the front-end server heartbeat monitor determines whether the connection between the front-end server 130 and the connection server 120 for sharing the view-type event processing burden of the connection server 120 fails by checking whether the two adjacent communication times of the connection server 120 and the front-end server 130 exceed a preset time interval at intervals, generates connection failure information and sends the connection failure information to the client 140 if the connection fails, and deletes the front-end server identifier in the client event processing result.
In this embodiment, the front-end server heartbeat monitor is arranged to monitor whether the front-end server is disconnected from the connection server, so as to avoid the occurrence of a situation that a client event cannot be processed in time due to the downtime of the front-end server or other reasons.
On the basis of the foregoing embodiment, as another preferred embodiment of the present invention, in this preferred embodiment, the connection server 110 is further configured to receive the client event and the client event processing result corresponding to the client event, which are sent by the client 140, and send the client event and the client event processing result to the message server 120.
The front-end server 130 is further configured to monitor the message server 120, obtain the client event and the client event processing result, process the client event to obtain an updated client event processing result, and send the updated client event processing result to the message server 120.
The connection server 110 is further configured to monitor the message server 120, obtain the updated client event processing result, and send the updated client event processing result to the client 140.
Specifically, if one connection server goes down or cannot process the client event any more, all the clients performing the client event processing by the connection server receive the processed client event processing result and the connection server connection failure information. At this time, the client may again generate a client event while transmitting a client event processing result with respect to the client event. After the client time is monitored, other standby front-end servers can be started, the client events and the corresponding client event processing results are processed, updated client event processing results are generated, and new front-end server identifications are added to the updated client event processing results.
In this embodiment, when one front-end server cannot continue to process the client event, the client may send the client event and the corresponding client event processing result again, and the standby front-end server processes the client event and the client event processing result to obtain an updated client event processing result, and finally sends the updated client event processing result to the client. Therefore, when part of the front-end servers are down, other front-end servers still process the client events in time, the service continuous function is achieved, and the processing quality of the server system to the client events is guaranteed.
Fig. 4 is a schematic flowchart of a server cluster processing method according to a third embodiment of the present invention. As shown in fig. 4, the method includes:
step 1: the connection server receives a client event sent by a client, if the client event is a view registration event, whether a view registration event processor corresponding to the client event exists in the connection server is judged, and if not, the client event is sent to the message server.
Step 2: and the front-end server cache engine monitors the message server, acquires the client event, processes the client event to obtain a client event processing result list, and sends the client event and the client event processing result list to the front-end server session control model.
And step 3: and the session control model of the front-end server respectively processes the client event and the client event processing result list to obtain a client event processing result and sends the client event processing result to the message server.
And 4, step 4: and the connection server monitors the message server, acquires the client event processing result and sends the client event processing result to the client.
Preferably, the front-end server cache engine includes a cache engine unit and a front-end server cache-like event handler, and step 2 includes:
step 2.1: and the cache engine unit monitors the message server to acquire the client event.
Step 2.2: and the cache engine unit acquires a front-end server cache type event processor corresponding to the client event.
Step 2.3: and the front-end server cache type event processor respectively processes the client events to obtain a client event processing result list.
Step 2.4: and the cache engine unit sends the client event processing result list to the front-end server session control model.
Preferably, the front-end server session control model includes a session control unit and a front-end server view data model, and the step 3 includes:
step 3.1: and the session control unit distributes the client event and the client event processing result list to the front-end server view data model.
Step 3.2: and the front-end server view data model processes the client event to obtain a first processing result.
Step 3.3: and the front-end server view data model processes the client event processing result list to obtain a second processing result.
Step 3.4: and the session control unit respectively sends the first processing result and the second processing result to the message server, wherein the first processing result is the initial content of the view, and the second processing result is the changed part of the initial content of the view.
Preferably, the connection server comprises a connection server caching engine, a connection server session control model and a front-end server heartbeat monitor, and the step 4 comprises:
step 4.1: and the connection server cache engine monitors and acquires the client event processing result and sends the client event processing result to the connection server session control model.
Step 4.2: and the connection server session control model sends the client event processing result to the client corresponding to the connection server session control model.
Step 4.3: the front-end server heartbeat monitor monitors the communication time of the connection server and the front-end server, if the interval between the current communication time and the latest communication time is larger than the preset time interval, a front-end server connection failure server event is generated, and the front-end server connection failure server event is sent to the connection server session control model.
Step 4.4: and the connection server session control model generates a front-end server connection failure notification event according to the front-end server connection failure server event and sends the front-end server connection failure notification event to the client corresponding to the connection server session control model.
In this embodiment, the connection server sends the received view registration type client event to the message server, and the front-end server processes the view registration type client event after monitoring the view registration type client event, and separately processes different types of client events according to different situations, such as separately processing a direct type event and a cache type event, which shares the workload of the connection server and ensures the processing quality of the server system for the client event. In addition, the front-end server heartbeat monitor can monitor whether the front-end server is disconnected with the connection server or not, so that the condition that the client events cannot be processed in time due to the downtime of the front-end server or other reasons is avoided.
Fig. 5 is a schematic flowchart of a server cluster processing method according to a fourth embodiment of the present invention. As shown in fig. 5, on the basis of the above embodiment, the method further includes:
and 5: and the connection server receives the client event sent by the client and the client event processing result corresponding to the client event, and sends the client event and the client event processing result to the message server.
Step 6: the front-end server monitors the message server, acquires the client event and the client event processing result, processes the client event and the client event processing result to obtain an updated client event processing result, and sends the updated client event processing result to the message server.
And 7: and the connection server monitors the message server, acquires the updated client event processing result and sends the updated client event processing result to the client.
In this embodiment, when one front-end server cannot continue to process the client event, the client may send the client event and the corresponding client event processing result again, and the standby front-end server processes the client event and the client event processing result to obtain an updated client event processing result, and finally sends the updated client event processing result to the client. Therefore, when part of the front-end servers are down, other front-end servers still process the client events in time, the service continuous function is achieved, and the processing quality of the server system to the client events is guaranteed.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.