Embodiment
The embodiment of the invention provides a kind of control method for equalizing load and system of message queue, in order to the flexibility of lifting control messages formation load balancing, and realizes the flexible switching of client to message queue.
Below in conjunction with Figure of description the preferred embodiments of the present invention are described; Be to be understood that; Preferred embodiment described herein only is used for explanation and explains the present invention; And be not used in qualification the present invention, and under the situation of not conflicting, embodiment and the characteristic among the embodiment among the present invention can make up each other.
The typical application scene of the load balancing controlling schemes of the message queue that at first, the embodiment of the invention is provided adopts the precision marketing system of elasticity computation structure to describe one by one.The elasticity computation structure of precision marketing system is based upon on the SOA (Service-Oriented Architecture, Service-Oriented Architecture Based) of employing based on message-oriented middleware.SOA is a kind of framework model, can carry out distributed deployment, combination and use through network to loosely-coupled coarseness application component according to demand; Service layer is the basis of SOA, can directly be employed to call, thereby effectively in the control system with the mutual artificial dependence of ageng.The framework of precision marketing system, as shown in Figure 2:
In the precision marketing system, each module is articulated to message-oriented middleware through the message encapsulation, and service or outwards request service externally are provided.Three types of critical pieces that elasticity is calculated: monitor service, Balance Control service and business service all are the basis with SOA, in the precision marketing system, all encapsulate and dispose with message based service form.Wherein, the functional entity of having disposed monitor service is called monitoring module, and the functional entity of having disposed the Balance Control service is called the Balance Control module, and the functional entity of having disposed business service is called application server, and message queue is deployed in the queue management device.
The IT incident that the signaling data of signaling acquisition system collection and BOSS system produce sends to the front end processor of precision marketing system; Processing module in the front end processor is filtered and processed the signaling data or the IT incident that receive, obtains business event; Distribution module in the front end processor is responsible for the business event that processing module obtains is distributed; Through the message encapsulation business event is distributed to the message queue in the queue management device, the business service in the application server is extracted business event again and is handled from the message queue of correspondence.
Business service is the service of the concrete business event processing logic of precision marketing system in package, will be deployed to one or more application servers.When the precision marketing system need increase the business event disposal ability, will start a plurality of business service instances, the computing capability that makes full use of application server is carried out distributed treatment.
Different with the business service of other system, each business service that need carry out flexible scheduling all will be to the Balance Control service report running status of precision marketing system, receives to start and cease and desist order.In the embodiment of the invention, designed service managerZ-HU and separated this partial function, as shown in Figure 3, be responsible for and the Balance Control service interaction by service managerZ-HU, accomplish the registration of business service, and start or stop business service.
To a certain specific business service in the application server, its register flow path is as shown in Figure 4, comprises the steps:
S401, service managerZ-HU initiate the register requirement of business service to the Balance Control module, wherein carry the identification information of business service;
S402, Balance Control module are according to the register requirement of business service; Issue the configuration messages that comprises the message queue link information through service managerZ-HU to business service, the message queue link information comprises the identification information of institute's connection message formation, the address information of institute's connection message formation place queue management device;
S403, business service are connected to the message queue of appointment according to the message queue link information in the configuration messages;
Follow-up, this specific business service can be obtained the needs processing from the message queue that is connected business event carries out Business Processing.
It is thus clear that the business service that through part is deployed on the application server of some can be used as cluster, the message queue that each business service is corresponding unique, the corresponding one or more business service of each message queue.
To registered business service, the Balance Control service can also start and cease and desist order to the issue of a certain specific business service, service managerZ-HU receive start or stop order after, start or stop corresponding business service.Wherein:
Start business service:
Service managerZ-HU starts business service as common thread, the issued state Notification of Changes has changed to starting state to this business service of Balance Control service report simultaneously;
Stop business service:
The service managerZ-HU calling external program normally withdraws from business service from circulation, and the issued state Notification of Changes has changed to halted state to this business service of Balance Control service report simultaneously.
Based on the elasticity computation structure of above-mentioned precision marketing system, the embodiment of the invention provides a kind of load balancing control system of message queue, and is as shown in Figure 5, comprises monitoring module 51 and RACS 52, and monitoring module 51 is connected to each message queue.Wherein:
Monitoring module 51; The current degree of depth that is used for each message queue of poll; When existing the current degree of depth to reach the overload message queue of preset queue depth's alarm threshold; Generate warning information and send to the Balance Control module, comprise the identification information and the current degree of depth thereof of respectively transshipping message queue in the said warning information;
For the ease of distinguishing, the message queue that in the embodiment of the invention the current degree of depth is reached preset queue depth's alarm threshold is called " overload message queue ";
RACS 52 is used for respectively transshipping the current degree of depth of message queue and the average treatment ability of business service according to warning information, the business service quantity that the message queue of confirming respectively respectively to transship need increase; Choose respective numbers and satisfy the business service of configuration condition, increase configuration and give and respectively transship the indicated overload message queue of identification information of message queue in the warning information.
In the practical implementation, a kind of possibility implementation of RACS 52 comprises Balance Control module 521 and service managerZ-HU 522, wherein:
Balance Control module 521 is used to inquire about the cpu busy percentage of each application server, confirms that cpu busy percentage is lower than the idle application server of the first utilance threshold value of setting; The Balance Control module initiate to start the control command of business service to service managerZ-HU, wherein indicates idle application server and carry respectively to transship the business service quantity that the identification information and needing of message queue increases;
Service managerZ-HU 522 is used for according to the control command that starts business service, is respectively each overload message queue and starts respective numbers and be deployed in the business service in the idle application server.
Preferable, Balance Control module 521 also is used for when the current depth recovery of certain overload message queue is arrived under its queue depth's alarm threshold, inquiring about the cpu busy percentage of each application server; If exist cpu busy percentage to be higher than the busy application server of the second utilance threshold value of setting; Initiate to stop the control command of business service to service managerZ-HU; Wherein indicate busy application server and carry the identification information of this overload message queue, the said second utilance threshold value is higher than the first utilance threshold value;
Service managerZ-HU 522 also is used for according to stopping the control command of business service, stop to dispose for this overload message queue and be deployed in the business service in the busy application server.
Respectively transship the identification information and the current degree of depth thereof of message queue except comprising in the warning information that monitoring module generates, can also comprise: the identification information of other message queue and the current degree of depth thereof; In this case, the another kind of RACS possibility implementation comprises Balance Control module 521 and service managerZ-HU 522, wherein:
Balance Control module 521; Be used to the pairing business service of message queue that each the overload message queue increase configuration respective numbers and the current degree of depth are lower than queue depth's scheduling threshold value of setting, said queue depth scheduling threshold value is lower than queue depth's alarm threshold; Issue the configuration update message that comprises the message queue link information through management server 522 to said business service, the message queue link information is used to indicate business service to be connected to the overload message queue of appointment.
Based on same technical conceive; The embodiment of the invention provides a kind of control method for equalizing load of message queue; The current degree of depth through message queue embodies data processing pressure, therefore needs in advance for each message queue is provided with queue depth's alarm threshold, and the queue depth's alarm threshold that is provided with for each message queue can be identical; Also can be inequality, can be provided with flexibly according to the actual requirements.As shown in Figure 6, the control method for equalizing load of the message queue that the embodiment of the invention provides comprises the steps:
The current degree of depth of S601, each message queue of poll; When existing the current degree of depth to reach the overload message queue of preset queue depth's alarm threshold; Generate warning information, comprise the identification information and the current degree of depth thereof of respectively transshipping message queue in the said warning information;
In the practical implementation, can be according to the current degree of depth of Fixed Time Interval (this Fixed Time Interval can be called monitoring period) each message queue of poll; Also can be when satisfying the trigger condition of setting, for example the user triggers the inquiry of queue depth, the current degree of depth of each message queue of poll.
S602, according to respectively transshipping the current degree of depth of message queue and the average treatment ability of business service in the warning information, the business service quantity that the message queue of confirming respectively respectively to transship need increase;
In the practical implementation, the average treatment ability of business service can be confirmed also pre-configured through following mode:
The application server that business service is provided is carried out POC (Proof of Concept) benchmark test; Draw under the typical services scene; The POC fiducial value of application server and business service maximum quantity, the POC fiducial value is meant the performance number of application server processes message, unit be generally the bar number/minute; The business service maximum quantity is meant the maximum quantity of the business service that application server can be disposed under the optimum performance; Need to prove, in the practical implementation, each application server performance basically identical of business service is provided.Based on POC benchmark test, can obtain the average treatment ability of business service, concrete computational methods are shown in formula [1]:
The average treatment ability of business service=POC fiducial value/business service maximum quantity [1]
Average treatment ability according to business service; And the current degree of depth (generally adopting the bar numerical table of message to show) of overload message queue; Can obtain the business service quantity that each overload message queue need increase; The quantity of supposing the overload message queue is N, then i (the business service quantity that the individual overload message queue of 1≤i≤N) need increase, concrete computational methods are shown in formula [2]:
Business service quantity=the P that needs increase
i/ T [2]
Wherein, P
iRepresent that (the current degree of depth of individual overload message queue of 1≤i≤N), T representes the average treatment ability of business service to i.
S603, choose respective numbers and satisfy the business service of configuration condition, increase configuration and give and respectively transship the indicated overload message queue of identification information of message queue in the warning information.
Below specify the load balancing controlling schemes of message queue through embodiment.
In order to reach the purpose of control messages formation load balancing; The control command of the startup business service that can initiate by service managerZ-HU receiving balance control module; Thereby guarantee that the precision marketing system is when facing the real time data of big data quantity and lack of balance; Can keep high real-time and high reliability, suppose that monitoring module presses the current degree of depth of each message queue of Fixed Time Interval poll.As shown in Figure 7, comprise the steps:
S701, when current monitoring period arrives, the current degree of depth of each message queue of monitoring module poll, and upgrade the current degree of depth of stored message formation in the monitoring module;
Reach preset queue depth's alarm threshold if the S702 monitoring module monitors the current degree of depth of some or a plurality of message queues, these one or more message queues are called the overload message queue, then carry out S703;
If monitoring module does not monitor the message queue that the current degree of depth reaches queue depth's alarm threshold of setting, then do not carry out any processing, wait for the arrival of next monitoring period;
S703, monitoring module generate warning information and send to the Balance Control module, need comprise the identification information and the current degree of depth thereof of respectively transshipping message queue in the warning information;
Describe for example:
Table 1
Suppose that monitoring module has connected four message queues, numbering is respectively 1,2,3,4, and the maximum queue depth of each message queue and queue depth's alarm threshold see also table 1.When current monitoring period arrived, it is as shown in table 1 that monitoring module inquires the current degree of depth of each message queue.Based on above-mentioned Query Result; The current degree of depth that monitoring module monitors message queue 1 and message queue 2 reaches preset queue depth's alarm threshold; Then generate warning information and send to the Balance Control module, need comprise the identification information and the current degree of depth thereof of transshipping message queue in the warning information.The identification information of message queue of wherein transshipping can adopt the numbering of message queue, also can adopt the title etc. of message queue; Can get final product by message queue of unique identification; Suppose to adopt the numbering of message queue, then comprise following information in the warning information: (1,1000000); (2,1000000);
After S704, Balance Control module receive warning information, according to the current degree of depth and the average treatment ability of business service of each overload message queue, the business service quantity that the message queue of confirming respectively respectively to transship need increase;
The business service quantity that supposing to determine message queue 1 needs to increase is M
1, the message queue 2 business service quantity that needs to increase is M
2
The cpu busy percentage of S705, each application server of Balance Control module inquiry; Obtain the idle application server that cpu busy percentage is lower than the first utilance threshold value of setting; The first utilance threshold value can be set according to actual conditions flexibly; For example be set at 10%, 5% or the like, be no more than 50% generally speaking;
S706, Balance Control module initiate to start the control command of business service to service managerZ-HU, wherein indicate idle application server and carry respectively to transship the business service quantity that the identification information and needing of message queue increases;
S707, service managerZ-HU are respectively the business service that each overload message queue starts respective numbers according to the control command of business service in idle application server; Need to prove that because the service managerZ-HU unified management is deployed in the business service in the application server, so service managerZ-HU can be known the business service distributed intelligence of each application server;
For example, be message queue 1 startup M according to the result of calculation of S704
1Individual business service is for message queue 2 starts M
2Individual business service.
S708, service managerZ-HU are to Balance Control module feedback states Notification of Changes, and the report corresponding business service has changed to starting state.
S704 and S705 are the load balancing control strategies of presetting, and according to the cpu busy percentage that inquires, obtain the idle application server of dispersion as far as possible, make new business service of opening be dispersed in each idle application server, help improving bandwidth availability ratio.S706 and S707 are the operating parts to the load balancing control strategy, make that the business service on the more application services device starts, and are connected to message queue parallel processing business event.
In order to realize inquiry to the cpu busy percentage of each application server, in the practical implementation, can use the Linux script that monitor message is write file, be uploaded to the Balance Control module by program through message queue again.
In the practical implementation, after the queue depth of overload message queue recovered normally, the Balance Control module can also be through the cpu busy percentage of each application server of inquiry, and the notification service manager stops corresponding business service, specifically comprises the steps:
Step 1, when the current depth recovery of certain overload message queue is under its queue depth's alarm threshold, the cpu busy percentage of each application server of Balance Control module inquiry;
If step 2 exists cpu busy percentage to be higher than the busy application server of the second utilance threshold value of setting; The Balance Control module initiates to stop the control command of business service to service managerZ-HU; Wherein indicate busy application server and carry the identification information of this overload message queue, the said second utilance threshold value is higher than the first utilance threshold value;
Step 3, service managerZ-HU be according to the control command that stops business service, stop to dispose for this overload message queue and be deployed in the business service in the busy application server.
In order to reach the purpose of control messages formation load balancing; Can be by the configuration update message that comprises the message queue link information of service managerZ-HU receiving balance control module initiation; Be updated to the business service of overload message queue service; Thereby guarantee that the precision marketing system in the face of the real time data of big data quantity and lack of balance the time, can keep high real-time and high reliability, suppose that monitoring module presses the current degree of depth of each message queue of Fixed Time Interval poll.As shown in Figure 8, comprise the steps:
S801, when current monitoring period arrives, the current degree of depth of each message queue of monitoring module poll, and upgrade the current degree of depth of stored message formation in the monitoring module;
Reach preset queue depth's alarm threshold if the S802 monitoring module monitors the current degree of depth of some or a plurality of message queues, these one or more message queues are called the overload message queue, then carry out S803;
If monitoring module does not monitor the message queue that the current degree of depth reaches queue depth's alarm threshold of setting, then do not carry out any processing, wait for the arrival of next monitoring period;
S803, monitoring module generate warning information and send to the Balance Control module, respectively transship the identification information and the current degree of depth thereof of message queue except comprising in the warning information, also comprise the identification information and the current degree of depth thereof of other message queue;
After S804, Balance Control module receive warning information, according to the current degree of depth and the average treatment ability of business service of each overload message queue, the business service quantity that the message queue of confirming respectively respectively to transship need increase;
S805, Balance Control module increase the pairing business service of message queue that the current degree of depth that disposes respective numbers is lower than queue depth's scheduling threshold value of setting for each overload message queue; Wherein, queue depth's scheduling threshold value is less than queue depth's alarm threshold;
S806, Balance Control module comprise the configuration update message of message queue link information to above-mentioned each business service issue through management server;
S807, corresponding business service are connected to the overload message queue of appointment according to the message queue link information in the configuration update message.
The control method for equalizing load of the message queue that the embodiment of the invention provides and system; Abandoned by the balanced pattern of major queue control load; The current degree of depth through each message queue of poll; When the queue depth of some or a plurality of message queues reaches the queue depth alarm threshold of setting, the business service quantity that the message queue of confirming respectively to transship need increase, and the business service that will satisfy configuration condition increases configuration to each overload message queue; Thereby reached the purpose of control messages formation load balancing, promoted flexibility; Business service is no longer extracted message and is carried out Business Processing from fixing message queue, but can realize the flexible switching of client to message queue according to actual conditions flexibly for the service of message queue configuration service.
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, belong within the scope of claim of the present invention and equivalent technologies thereof if of the present invention these are revised with modification, then the present invention also is intended to comprise these changes and modification interior.