Invention content
The technical problem to be solved by the present invention is to provide a kind of business data processing method and device, overcome the prior art
In the message of distributed post-caused by subscription message system the defects of squeezing.
The technical solution adopted by the present invention is business data processing method, including:
For any Service Processing Unit at consumer end, detect subscription corresponding with Service Processing Unit in agent side and disappear
The message number in queue is ceased, wherein, each Service Processing Unit is corresponding one or more to subscribe to message queues, at business
Unit is managed for handling the message subscribed in message queue;
Judge whether to need the traffic handing capacity for adjusting Service Processing Unit according at least to the message number detected, if
It is then to adjust the traffic handing capacity of Service Processing Unit.
Further, the message number subscribed in message queue corresponding with Service Processing Unit, packet in agent side are detected
It includes:
Disappearing in message queue is subscribed to according to corresponding with Service Processing Unit in the detection cycle detection agent side of setting
Cease quantity;
Message number according to detecting judges whether the traffic handing capacity for needing to adjust Service Processing Unit, including:
In the first setting duration, if the message number detected is persistently more than or works as continuously less than Service Processing Unit
Number of threads used in preceding, then judgement need to adjust the traffic handing capacity of Service Processing Unit;First setting duration is more than
The detection cycle of setting.
Further, method further includes:In agent side is detected in subscription message queue corresponding with Service Processing Unit
Message number before, the loading configuration file in local memory;Service Processing Unit is set in configuration file and uses thread
Quantitative range;
The traffic handing capacity of Service Processing Unit is adjusted, including:
If the message number detected is persistently more than the currently used number of threads of Service Processing Unit, activate business place
The number of threads that uses of reason unit, until number of threads that Service Processing Unit uses is equal to message number, wherein, business
The upper limit for the number of threads that processing unit uses uses the maximum value of the quantitative range of thread for Service Processing Unit;
If the message number detected is shunk continuously less than the currently used number of threads of Service Processing Unit at business
The number of threads that uses of reason unit, until number of threads that Service Processing Unit uses is equal to message number, wherein, business
The lower limit for the number of threads that processing unit uses uses the minimum value of the quantitative range of thread for Service Processing Unit.
Further, if when Service Processing Unit uses a server in the second setting duration in processing message number
M is limited to, M is positive integer;It is positive integer that the number of servers upper limit N, N that Service Processing Unit uses are set in configuration file;
The traffic handing capacity of Service Processing Unit is adjusted, is further included:
If the message number increment detected in the first setting duration is more than or equal to n M, n is positive integer, then with N
For the upper limit, n+1 platform servers are used for Service Processing Unit extension;
If the message number decrement detected in the first setting duration is more than or equal to n M, then, using N as the upper limit, be
Service Processing Unit reduction uses n platform servers.
Further, method further includes:The load of server that detection Service Processing Unit uses;
Whether the load judgment of server that message number and Service Processing Unit according to detecting use needs to adjust
The traffic handing capacity of whole Service Processing Unit, if so, the traffic handing capacity of adjustment Service Processing Unit.
Further, the load judgment of server used according to the message number and Service Processing Unit that detect is
The no traffic handing capacity for needing to adjust Service Processing Unit, including:
Step A1:The server that detection cycle detection message number and Service Processing Unit according to setting use is born
It carries, if the message number detected in the first setting duration is persistently more than the currently used number of threads of Service Processing Unit
Or the load of at least one server that the Service Processing Unit detected in the first setting duration uses is more than setting
High load threshold then performs step A2;If the message number detected in the first setting duration is continuously less than business processing list
At least one clothes that the currently used number of threads of member and the Service Processing Unit detected in the first setting duration use
The load continuous of business device is less than the low-load threshold value of setting, then performs step A3;If the testing result in the first setting duration
Afore-mentioned is not met, then repeats step A1;
Step A2:It activates business the traffic handing capacity of processing unit, jump procedure A1;
Step A3:Shrink the traffic handing capacity of Service Processing Unit, jump procedure A1.
The present invention also provides a kind of service data processing apparatus, including:
Detection module, for being directed to any Service Processing Unit at consumer end, detect in agent side with business processing list
The corresponding message number subscribed in message queue of member, wherein, the corresponding one or more subscription of each Service Processing Unit
Message queue, Service Processing Unit subscribe to the message in message queue for processing;
Judgment module, for judging whether the industry for needing to adjust Service Processing Unit according at least to the message number detected
Business processing capacity, if so, calling adjustment module;
Module is adjusted, for adjusting the traffic handing capacity of Service Processing Unit.
Further, detection module is used for:According to setting detection cycle detection agent side in Service Processing Unit pair
That answers subscribes to the message number in message queue;
Judgment module is used for:First setting duration in, if the message number detected be persistently more than or continuously less than
The currently used number of threads of Service Processing Unit, then judgement need to adjust the traffic handing capacity of Service Processing Unit;The
One setting duration is more than the detection cycle of setting.
Further, device further includes:
Configuration module, in subscription message queue corresponding with Service Processing Unit in detection module detection agent side
Message number before, the loading configuration file in local memory;Service Processing Unit is set in configuration file and uses thread
Quantitative range;
Module is adjusted, is used for:
If the message number detected is persistently more than the currently used number of threads of Service Processing Unit, activate business place
The number of threads that uses of reason unit, until number of threads that Service Processing Unit uses is equal to message number, wherein, business
The upper limit for the number of threads that processing unit uses uses the maximum value of the quantitative range of thread for Service Processing Unit;
If the message number detected is shunk continuously less than the currently used number of threads of Service Processing Unit at business
The number of threads that uses of reason unit, until number of threads that Service Processing Unit uses is equal to message number, wherein, business
The lower limit for the number of threads that processing unit uses uses the minimum value of the quantitative range of thread for Service Processing Unit.
Further, if when Service Processing Unit uses a server in the second setting duration in processing message number
M is limited to, M is positive integer;It is positive integer that the number of servers upper limit N, N that Service Processing Unit uses are set in configuration file;
Module is adjusted, is additionally operable to:
If the message number increment detected in the first setting duration is more than or equal to n M, n is positive integer, then with N
For the upper limit, n+1 platform servers are used for Service Processing Unit extension;
If the message number decrement detected in the first setting duration is more than or equal to n M, then, using N as the upper limit, be
Service Processing Unit reduction uses n platform servers.
Further, detection module is additionally operable to:The load of server that detection Service Processing Unit uses;
Judgment module, the load of server for being used according to the message number and Service Processing Unit that detect are sentenced
The disconnected traffic handing capacity for whether needing to adjust Service Processing Unit.
Further, detection module, for detecting message number and Service Processing Unit according to the detection cycle of setting
The load of the server used;
Judgment module, if the message number for being detected in the first setting duration is persistently worked as more than Service Processing Unit
At least one service that number of threads used in preceding or the Service Processing Unit detected in the first setting duration use
More than the high load threshold of setting, then judgement needs to activate business the traffic handing capacity of processing unit, continues to adjust for the load of device
Use detection module;
If the message number detected in the first setting duration is continuously less than the currently used line of Service Processing Unit
The load continuous of at least one server that number of passes amount and the Service Processing Unit detected in the first setting duration use is small
In the low-load threshold value of setting, then judgement needs to shrink the traffic handing capacity of Service Processing Unit, continues to call detection module;
If the testing result in the first setting duration does not meet afore-mentioned, continue to call detection module.
Using above-mentioned technical proposal, the present invention at least has following advantages:
Business data processing method and device of the present invention, by the load to server used in Service Processing Unit with
And the corresponding message queue current message quantity of subscribing to of Service Processing Unit in distributed post-subscription message system is supervised
It surveys, extension or contraction and the expansion of lateral server node to the longitudinal thread of traffic handing capacity progress of Service Processing Unit
Exhibition is shunk.Mode in this way can make business processing more flexible, reduce server automatically when the business free time
Node, automatic expansion service device node, so as to fulfill the automatic telescopic of traffic handing capacity, avoids when heavy traffic
Distributed post-message caused by subscription message system squeezes.
Specific embodiment
The technological means and effect taken further to illustrate the present invention to reach predetermined purpose, below in conjunction with attached drawing
And preferred embodiment, the present invention is described in detail as after.
First embodiment of the invention, a kind of business data processing method, as shown in Fig. 2, including step in detail below:
Step S101, for any Service Processing Unit at consumer end, detect in agent side with Service Processing Unit pair
That answers subscribes to the message number in message queue;The per thread that Service Processing Unit uses can handle a piece of news, processing
The thread resources can discharge after complete.
Optionally, it in step S101, detects in agent side in subscription message queue corresponding with Service Processing Unit
Message number, including:
Disappearing in message queue is subscribed to according to corresponding with Service Processing Unit in the detection cycle detection agent side of setting
Cease quantity;
Step S102 judges whether according at least to the message number detected at the business for needing to adjust Service Processing Unit
Reason ability, if so, the traffic handing capacity of adjustment Service Processing Unit.
Optionally, in step s 102, judge whether to need to adjust Service Processing Unit according to the message number detected
Traffic handing capacity, including:
In the first setting duration, if the message number detected is persistently more than or works as continuously less than Service Processing Unit
Number of threads used in preceding, then judgement need to adjust the traffic handing capacity of Service Processing Unit;First setting duration is more than
The detection cycle of setting.
Optionally, the traffic handing capacity for adjusting Service Processing Unit includes:Extension or contraction Service Processing Unit are made
The quantity of thread and/or server.And first consider extension as possible or shrink thread used in Service Processing Unit, when logical
Thread used in crossing extension or contraction Service Processing Unit still cannot be close to the business processing energy needed for Service Processing Unit
In the case of power, consider further that extension or shrink number of servers used in Service Processing Unit.
The business data processing method of the embodiment of the present invention, by the business in distributed post-subscription message system
The corresponding message queue current message quantity of subscribing to of processing unit is monitored, to the traffic handing capacity of Service Processing Unit into
Row extension is shunk.Mode in this way can make business processing more flexible, reduce clothes automatically when the business free time
Business device node, automatic expansion service device node, so as to fulfill the automatic telescopic of traffic handing capacity, keeps away when heavy traffic
Exempt from distributed post-message caused by subscription message system to squeeze.
Second embodiment of the invention, a kind of business data processing method, as shown in figure 3, including step in detail below:
Step S201, the loading configuration file in local memory;Service Processing Unit is set in configuration file and uses line
The quantitative range of journey;
Step S202, for any Service Processing Unit at consumer end, detect in agent side with Service Processing Unit pair
That answers subscribes to the message number in message queue;
Optionally, it in step S202, detects in agent side in subscription message queue corresponding with Service Processing Unit
Message number, including:
Disappearing in message queue is subscribed to according to corresponding with Service Processing Unit in the detection cycle detection agent side of setting
Cease quantity.
Step S203 judges whether to need the business processing energy for adjusting Service Processing Unit according to the message number detected
Power, if so, the traffic handing capacity of adjustment Service Processing Unit.
Optionally, in step S203, judge whether to need to adjust Service Processing Unit according to the message number detected
Traffic handing capacity, including:
In the first setting duration, if the message number detected is persistently more than or works as continuously less than Service Processing Unit
Number of threads used in preceding, then judgement need to adjust the traffic handing capacity of Service Processing Unit;First setting duration is more than
The detection cycle of setting.
Why the embodiment of the present invention is not detecting that message number is currently made more than or less than Service Processing Unit
During number of threads just at once judgement need adjust Service Processing Unit traffic handing capacity, be because agent side in industry
The corresponding message number subscribed in message queue of processing unit be engaged in it is possible that not fluctuation quietly, if immediately following fluctuate into
The adjustment of row professional ability, adjustment excessively frequently, the resource consumption of Service Processing Unit will be increased.
Optionally, in step S203, the traffic handing capacity of Service Processing Unit is adjusted, including:
If the message number detected is persistently more than the currently used number of threads of Service Processing Unit, with quantity model
The maximum value enclosed be the upper limit, the number of threads that processing unit of activating business uses, until message number be equal to Service Processing Unit
Until the number of threads used;
If the message number detected is continuously less than the currently used number of threads of Service Processing Unit, with quantity model
The minimum value enclosed is lower limit, shrinks the number of threads that Service Processing Unit uses, until message number is equal to Service Processing Unit
Until the number of threads used.
Such as:The detection of the present embodiment and adjustment process can be according to following circulate operations:
Step A1:According to subscription message queue corresponding with Service Processing Unit in the detection cycle detection agent side of setting
In message number, if to be persistently more than Service Processing Unit currently used for the message number that detects in the first setting duration
Number of threads, then perform step A2;If the message number detected in the first setting duration is continuously less than business processing list
The currently used number of threads of member, then perform step A3;If the testing result in the first setting duration does not meet aforementioned feelings
Condition then repeats step A1;
Step A2:Using the maximum value of quantitative range as the upper limit, number of threads that processing unit of activating business uses redirects step
Rapid A1;
Step A3:Using the minimum value of quantitative range as lower limit, the number of threads that Service Processing Unit uses is shunk, redirects step
Rapid A1.
The embodiment of the present invention is roughly the same with first embodiment, and difference lies in an embodiment of the present invention provides by simple
The mode configuration service processing unit of configuration file use the quantitative range of thread, which can also configure for business
The detection of processing unit and professional ability adjustable strategies, are embodied in the concrete operations of step S202 and step S203.Separately
Outside, the embodiment of the present invention has been also provided to more detailed detection adjustment process.
The business data processing method of the embodiment of the present invention, by the business in distributed post-subscription message system
The corresponding message queue current message quantity of subscribing to of processing unit is monitored, to the traffic handing capacity of Service Processing Unit into
The extension or contraction of row longitudinal direction thread.Mode in this way can make business processing more flexible, when the business free time
Automatic reduction server node, automatic expansion service device node when heavy traffic, so as to fulfill traffic handing capacity
Automatic telescopic avoids distributed post-message caused by subscription message system and squeezes.
Third embodiment of the invention, a kind of business data processing method, as shown in figure 3, including step in detail below:
Step S201, the loading configuration file in local memory;Service Processing Unit is set in configuration file and uses line
The quantitative range of journey;
Step S202, for any Service Processing Unit at consumer end, detect in agent side with Service Processing Unit pair
That answers subscribes to the message number in message queue;
Optionally, it in step S202, detects in agent side in subscription message queue corresponding with Service Processing Unit
Message number, including:
Disappearing in message queue is subscribed to according to corresponding with Service Processing Unit in the detection cycle detection agent side of setting
Cease quantity.
Step S203 judges whether to need the business processing energy for adjusting Service Processing Unit according to the message number detected
Power, if so, the traffic handing capacity of adjustment Service Processing Unit.
Optionally, in step S203, judge whether to need to adjust Service Processing Unit according to the message number detected
Traffic handing capacity, including:
In the first setting duration, if the message number detected is persistently more than or works as continuously less than Service Processing Unit
Number of threads used in preceding, then judgement need to adjust the traffic handing capacity of Service Processing Unit;First setting duration is more than
The detection cycle of setting.
Optionally, in step S203, the traffic handing capacity of Service Processing Unit is adjusted, including:
If the message number detected is persistently more than the currently used number of threads of Service Processing Unit, with quantity model
The maximum value enclosed be the upper limit, the number of threads that processing unit of activating business uses, until message number be equal to Service Processing Unit
Until the number of threads used;
If the message number detected is continuously less than the currently used number of threads of Service Processing Unit, with quantity model
The minimum value enclosed is lower limit, shrinks the number of threads that Service Processing Unit uses, until message number is equal to Service Processing Unit
Until the number of threads used.
Such as:The detection of the present embodiment and adjustment process can be according to following circulate operations:
Step A1:According to subscription message queue corresponding with Service Processing Unit in the detection cycle detection agent side of setting
In message number, if to be persistently more than Service Processing Unit currently used for the message number that detects in the first setting duration
Number of threads, then perform step A2;If the message number detected in the first setting duration is continuously less than business processing list
The currently used number of threads of member, then perform step A3;If the testing result in the first setting duration does not meet aforementioned feelings
Condition then repeats step A1;
Step A2:Using the maximum value of quantitative range as the upper limit, number of threads that processing unit of activating business uses redirects step
Rapid A1;
Step A3:Using the minimum value of quantitative range as lower limit, the number of threads that Service Processing Unit uses is shunk, redirects step
Rapid A1.
Optionally, if Service Processing Unit uses handles the message number upper limit during server in the second setting duration
For M, M is positive integer;It is positive integer that the number of servers upper limit N, N that Service Processing Unit uses are set in configuration file;
In step S203, the traffic handing capacity of Service Processing Unit is adjusted, is further included:
If the message number increment detected in the first setting duration is more than or equal to n M, n is positive integer, then with N
For the upper limit, n+1 platform servers are used for Service Processing Unit extension;
If the message number decrement detected in the first setting duration is more than or equal to n M, then, using N as the upper limit, be
Service Processing Unit reduction uses n platform servers.
The embodiment of the present invention is roughly the same with second embodiment, and difference lies in the embodiment of the present invention is in adjustment business processing
Extension or receipts for server node used in Service Processing Unit are also provided during the traffic handing capacity of unit
Contracting, when the thread that a server can be provided has been not enough to the operation of one Service Processing Unit of support, it is necessary to expand
The server number that the Service Processing Unit uses is opened up, it is on the contrary, it is necessary to reduce.Such as:One Service Processing Unit uses
It is 100,000 to handle the message number upper limit in 3 minutes during one server, it is assumed that the current Service Processing Unit only used
One server, and the message number in currently detected agent side in subscription message queue corresponding with Service Processing Unit is
At 260000, it is necessary to increase two-server and be used for the Service Processing Unit.
The business data processing method of the embodiment of the present invention passes through the load to server used in Service Processing Unit
And the corresponding message queue current message quantity of subscribing to of Service Processing Unit in distributed post-subscription message system carries out
It monitors, the extension or contraction and lateral server node to the longitudinal thread of traffic handing capacity progress of Service Processing Unit
Extension is shunk.Mode in this way can make business processing more flexible, reduce service automatically when the business free time
Device node, automatic expansion service device node, so as to fulfill the automatic telescopic of traffic handing capacity, avoids when heavy traffic
Distributed post-message caused by subscription message system squeezes.
Fourth embodiment of the invention, a kind of business data processing method, as shown in figure 4, including step in detail below:
Step S301, the loading configuration file in local memory;Service Processing Unit is set in configuration file and uses line
The number of servers upper limit N, N that the quantitative range and Service Processing Unit of journey use are positive integer;
Step S302 for any Service Processing Unit at consumer end, detects the server that Service Processing Unit uses
Load and agent side in it is corresponding with Service Processing Unit subscribe to message queue in message number;
Optionally, in step s 302, it detects in agent side in subscription message queue corresponding with Service Processing Unit
Message number, including:
In the load of server that detection cycle detection Service Processing Unit according to setting uses and agent side with industry
The message number being engaged in the corresponding subscription message queue of processing unit.
Step S303 is according to the load judgment of server that the message number and Service Processing Unit that detect use
The no traffic handing capacity for needing to adjust Service Processing Unit, if so, the traffic handing capacity of adjustment Service Processing Unit.
Optionally, in step S303, the server that is used according to the message number and Service Processing Unit that detect
Load judgment whether need adjust Service Processing Unit traffic handing capacity, including:
Step B1:According to subscription message queue corresponding with Service Processing Unit in the detection cycle detection agent side of setting
In the load of server that uses of message number and Service Processing Unit, if the message detected in the first setting duration
Quantity is persistently more than the currently used number of threads of Service Processing Unit or the business detected in the first setting duration
The load of at least one server that processing unit uses then performs step B2 more than the high load threshold of setting;If first
The message number detected in setting duration is set continuously less than the currently used number of threads of Service Processing Unit and first
The load continuous of at least one server that the Service Processing Unit detected in timing is long uses is less than the low-load threshold of setting
Value, then perform step B3;If the testing result in the first setting duration does not meet afore-mentioned, step B1 is repeated;
Step B2:It activates business the traffic handing capacity of processing unit, jump procedure B1;
Step B3:Shrink the traffic handing capacity of Service Processing Unit, jump procedure B1.
The embodiment of the present invention is roughly the same with 3rd embodiment, and difference lies in the embodiment of the present invention will be combined in agent side
The server that the message number subscribed in message queue corresponding with Service Processing Unit and Service Processing Unit use is born
It carries, it is common to determine whether the traffic handing capacity of adjustment Service Processing Unit is needed, due to the industry of Service Processing Unit processing
The type of business is different, and logic complexity is also different, the consumption degree of server resource is also differed, server resource
Including CPU usage, memory source etc., in practical business operation, it is likely that will appear subscription corresponding with Service Processing Unit
Message number in message queue is few, but the feelings for loading excess load of certain server that Service Processing Unit uses
Condition should carry out number of servers extension according to the loading condition of server at this time;It, should when for reduction number of servers
This had both considered the situation of the message number in subscription message queue corresponding with Service Processing Unit it is further contemplated that Service Processing Unit
The loading condition of the server used to codetermine the quantity for whether needing to reduce server, can accurately just reflect in this way
The traffic handing capacity of Service Processing Unit actual needs.
The method for processing business of the embodiment of the present invention, by the load to server used in Service Processing Unit and
The corresponding message queue current message quantity of subscribing to of Service Processing Unit in distributed post-subscription message system is supervised
It surveys, extension or contraction and the expansion of lateral server node to the longitudinal thread of traffic handing capacity progress of Service Processing Unit
Exhibition is shunk.Mode in this way can make business processing more flexible, reduce server automatically when the business free time
Node, automatic expansion service device node, so as to fulfill the automatic telescopic of traffic handing capacity, avoids when heavy traffic
Distributed post-message caused by subscription message system squeezes.
Fifth embodiment of the invention, corresponding with first embodiment, the present embodiment introduces a kind of service data processing apparatus, such as
Shown in Fig. 5, including consisting of part:
1) detection module 501, for being directed to any Service Processing Unit at consumer end, detect in agent side at business
Manage the corresponding message number subscribed in message queue of unit.The per thread that Service Processing Unit uses can handle one and disappear
Breath, the thread resources can discharge after having handled.
Optionally, detection module 501 are used for:According to setting detection cycle detection agent side in Service Processing Unit
Message number in corresponding subscription message queue.
2) judgment module 502, for judging whether to need according at least to the message number detected to adjust business processing list
The traffic handing capacity of member, if so, calling adjustment module 503;
Optionally, judgment module 502 are used for:First setting duration in, if the message number detected be persistently more than or
Person needs to adjust at the business of Service Processing Unit continuously less than the currently used number of threads of Service Processing Unit, then judgement
Reason ability;First setting duration is more than the detection cycle of setting.
3) module 503 is adjusted, for adjusting the traffic handing capacity of Service Processing Unit.
Optionally, adjustment module 503 is used to extending or shrinking thread used in Service Processing Unit and/or server
Quantity.
The service data processing apparatus of the embodiment of the present invention, by the business in distributed post-subscription message system
The corresponding message queue current message quantity of subscribing to of processing unit is monitored, to the traffic handing capacity of Service Processing Unit into
Row extension is shunk.Mode in this way can make business processing more flexible, reduce clothes automatically when the business free time
Business device node, automatic expansion service device node, so as to fulfill the automatic telescopic of traffic handing capacity, keeps away when heavy traffic
Exempt from distributed post-message caused by subscription message system to squeeze.
Sixth embodiment of the invention, corresponding with second embodiment, the present embodiment introduces a kind of service data processing apparatus, such as
Shown in Fig. 6, including consisting of part:
1) configuration module 601, for the loading configuration file in local memory;Business processing list is set in configuration file
Member uses the quantitative range of thread.The per thread that Service Processing Unit uses can handle a piece of news, the line after having handled
Cheng Ziyuan can discharge.
2) detection module 602, for being directed to any Service Processing Unit at consumer end, detect in agent side at business
Manage the corresponding message number subscribed in message queue of unit.
Optionally, detection module 602 are used for:According to setting detection cycle detection agent side in Service Processing Unit
Message number in corresponding subscription message queue.
2) judgment module 603, for being judged whether to need according to the message number detected to adjust Service Processing Unit
Traffic handing capacity, if so, calling adjustment module 604;
Optionally, judgment module 603 are used for:First setting duration in, if the message number detected be persistently more than or
Person needs to adjust at the business of Service Processing Unit continuously less than the currently used number of threads of Service Processing Unit, then judgement
Reason ability;First setting duration is more than the detection cycle of setting.
Why the embodiment of the present invention is not detecting that message number is currently made more than or less than Service Processing Unit
During number of threads just at once judgement need adjust Service Processing Unit traffic handing capacity, be because agent side in industry
The corresponding message number subscribed in message queue of processing unit be engaged in it is possible that not fluctuation quietly, if immediately following fluctuate into
The adjustment of row professional ability, adjustment excessively frequently, the resource consumption of Service Processing Unit will be increased.
3) module 604 is adjusted, for adjusting the traffic handing capacity of Service Processing Unit.
Optionally, module 604 is adjusted, is used for:
If the message number detected is persistently more than the currently used number of threads of Service Processing Unit, with quantity model
The maximum value enclosed be the upper limit, the number of threads that processing unit of activating business uses, until message number be equal to Service Processing Unit
Until the number of threads used;
If the message number detected is continuously less than the currently used number of threads of Service Processing Unit, with quantity model
The minimum value enclosed is lower limit, shrinks the number of threads that Service Processing Unit uses, until message number is equal to Service Processing Unit
Until the number of threads used.
Such as:Adjustment module 604 performs following circulate operation:
Step A1:According to subscription message queue corresponding with Service Processing Unit in the detection cycle detection agent side of setting
In message number, if to be persistently more than Service Processing Unit currently used for the message number that detects in the first setting duration
Number of threads, then perform step A2;If the message number detected in the first setting duration is continuously less than business processing list
The currently used number of threads of member, then perform step A3;If the testing result in the first setting duration does not meet aforementioned feelings
Condition then repeats step A1;
Step A2:Using the maximum value of quantitative range as the upper limit, number of threads that processing unit of activating business uses redirects step
Rapid A1;
Step A3:Using the minimum value of quantitative range as lower limit, the number of threads that Service Processing Unit uses is shunk, redirects step
Rapid A1.
The embodiment of the present invention is roughly the same with the 5th embodiment, and difference lies in an embodiment of the present invention provides by simple
The mode configuration service processing unit of configuration file use the quantitative range of thread, which can also configure for business
The detection of processing unit and professional ability adjustable strategies are embodied in the specific of detection module, judgment module and adjustment module
In operation.In addition, the embodiment of the present invention has been also provided to more detailed detection adjustment process.
The service data processing apparatus of the embodiment of the present invention, by the business in distributed post-subscription message system
The corresponding message queue current message quantity of subscribing to of processing unit is monitored, to the traffic handing capacity of Service Processing Unit into
The extension or contraction of row longitudinal direction thread.Mode in this way can make business processing more flexible, when the business free time
Automatic reduction server node, automatic expansion service device node when heavy traffic, so as to fulfill traffic handing capacity
Automatic telescopic avoids distributed post-message caused by subscription message system and squeezes.
Seventh embodiment of the invention, corresponding with 3rd embodiment, the present embodiment introduces a kind of service data processing apparatus, such as
Shown in Fig. 6, including consisting of part:
1) configuration module 601, for the loading configuration file in local memory;Business processing list is set in configuration file
Member uses the quantitative range of thread.The per thread that Service Processing Unit uses can handle a piece of news, the line after having handled
Cheng Ziyuan can discharge.
2) detection module 602, for being directed to any Service Processing Unit at consumer end, detect in agent side at business
Manage the corresponding message number subscribed in message queue of unit.
Optionally, detection module 602 are used for:According to setting detection cycle detection agent side in Service Processing Unit
Message number in corresponding subscription message queue.
3) judgment module 603, for being judged whether to need according to the message number detected to adjust Service Processing Unit
Traffic handing capacity, if so, calling adjustment module 604;
Optionally, judgment module 603 are used for:First setting duration in, if the message number detected be persistently more than or
Person needs to adjust at the business of Service Processing Unit continuously less than the currently used number of threads of Service Processing Unit, then judgement
Reason ability;First setting duration is more than the detection cycle of setting.
Why the embodiment of the present invention is not detecting that message number is currently made more than or less than Service Processing Unit
During number of threads just at once judgement need adjust Service Processing Unit traffic handing capacity, be because agent side in industry
The corresponding message number subscribed in message queue of processing unit be engaged in it is possible that not fluctuation quietly, if immediately following fluctuate into
The adjustment of row professional ability, adjustment excessively frequently, the resource consumption of Service Processing Unit will be increased.
4) module 604 is adjusted, for adjusting the traffic handing capacity of Service Processing Unit.
Optionally, module 604 is adjusted, is used for:
If the message number detected is persistently more than the currently used number of threads of Service Processing Unit, with quantity model
The maximum value enclosed be the upper limit, the number of threads that processing unit of activating business uses, until message number be equal to Service Processing Unit
Until the number of threads used;
If the message number detected is continuously less than the currently used number of threads of Service Processing Unit, with quantity model
The minimum value enclosed is lower limit, shrinks the number of threads that Service Processing Unit uses, until message number is equal to Service Processing Unit
Until the number of threads used.
Such as:Adjustment module 604 performs following circulate operation:
Step A1:According to subscription message queue corresponding with Service Processing Unit in the detection cycle detection agent side of setting
In message number, if to be persistently more than Service Processing Unit currently used for the message number that detects in the first setting duration
Number of threads, then perform step A2;If the message number detected in the first setting duration is continuously less than business processing list
The currently used number of threads of member, then perform step A3;If the testing result in the first setting duration does not meet aforementioned feelings
Condition then repeats step A1;
Step A2:Using the maximum value of quantitative range as the upper limit, number of threads that processing unit of activating business uses redirects step
Rapid A1;
Step A3:Using the minimum value of quantitative range as lower limit, the number of threads that Service Processing Unit uses is shunk, redirects step
Rapid A1.
Optionally, if Service Processing Unit uses handles the message number upper limit during server in the second setting duration
For M, M is positive integer;It is positive integer that the number of servers upper limit N, N that Service Processing Unit uses are set in configuration file;
Module 604 is adjusted, is additionally operable to:
If the message number increment detected in the first setting duration is more than or equal to n M, n is positive integer, then with N
For the upper limit, n+1 platform servers are used for Service Processing Unit extension;
If the message number decrement detected in the first setting duration is more than or equal to n M, then, using N as the upper limit, be
Service Processing Unit reduction uses n platform servers.
The embodiment of the present invention is roughly the same with sixth embodiment, and difference lies in the embodiment of the present invention is in adjustment business processing
Extension or receipts for server node used in Service Processing Unit are also provided during the traffic handing capacity of unit
Contracting, when the thread that a server can be provided has been not enough to the operation of one Service Processing Unit of support, it is necessary to expand
The server number that the Service Processing Unit uses is opened up, it is on the contrary, it is necessary to reduce.Such as:One Service Processing Unit uses
It is 100,000 to handle the message number upper limit in 3 minutes during one server, it is assumed that the current Service Processing Unit only used
One server, and the message number in currently detected agent side in subscription message queue corresponding with Service Processing Unit is
At 260000, it is necessary to increase two-server and be used for the Service Processing Unit.
The service data processing apparatus of the embodiment of the present invention passes through the load to server used in Service Processing Unit
And the corresponding message queue current message quantity of subscribing to of Service Processing Unit in distributed post-subscription message system carries out
It monitors, the extension or contraction and lateral server node to the longitudinal thread of traffic handing capacity progress of Service Processing Unit
Extension is shunk.Mode in this way can make business processing more flexible, reduce service automatically when the business free time
Device node, automatic expansion service device node, so as to fulfill the automatic telescopic of traffic handing capacity, avoids when heavy traffic
Distributed post-message caused by subscription message system squeezes.
Eighth embodiment of the invention, corresponding with fourth embodiment, the present embodiment introduces a kind of service data processing apparatus, such as
Shown in Fig. 6, including consisting of part:
1) configuration module 601, for the loading configuration file in local memory;Business processing list is set in configuration file
Member is positive integer using the number of servers upper limit N, N that the quantitative range and Service Processing Unit of thread use.Business processing
The per thread that unit uses can handle a piece of news, and the thread resources can discharge after having handled.
2) detection module 602, for being directed to any Service Processing Unit at consumer end, detection Service Processing Unit uses
Server load and agent side in it is corresponding with Service Processing Unit subscribe to message queue in message number;.
Optionally, detection module 602 are used for:According to setting detection cycle detection agent side in Service Processing Unit
The load of server that message number and Service Processing Unit in corresponding subscription message queue use.
3) judgment module 603, the server that the message number and Service Processing Unit detected for basis uses
Whether load judgment needs to adjust the traffic handing capacity of Service Processing Unit, if so, calling adjustment module 604;
Optionally, judgment module 603, if the message number for being detected in the first setting duration is persistently more than business
The currently used number of threads of processing unit or in the first setting duration the Service Processing Unit that detects use to
More than the high load threshold of setting, then judgement needs to activate business the business processing energy of processing unit for the load of a few server
Power continues to call detection module 602;
If the message number detected in the first setting duration is continuously less than the currently used line of Service Processing Unit
The load continuous of at least one server that number of passes amount and the Service Processing Unit detected in the first setting duration use is small
In the low-load threshold value of setting, then judgement needs to shrink the traffic handing capacity of Service Processing Unit, continues to call detection module
602;
If the testing result in the first setting duration does not meet afore-mentioned, continue to call detection module 602.
4) module 604 is adjusted, for adjusting the traffic handing capacity of Service Processing Unit.
Optionally, the traffic handing capacity for adjusting Service Processing Unit includes:Extension or contraction Service Processing Unit are made
The quantity of thread and/or server.And first consider extension as possible or shrink thread used in Service Processing Unit, when logical
Thread used in crossing extension or contraction Service Processing Unit still cannot be close to the business processing energy needed for Service Processing Unit
In the case of power, consider further that extension or shrink number of servers used in Service Processing Unit.
The embodiment of the present invention is roughly the same with the 7th embodiment, and difference lies in the embodiment of the present invention will be combined in agent side
The server that the message number subscribed in message queue corresponding with Service Processing Unit and Service Processing Unit use is born
It carries, it is common to determine whether the traffic handing capacity of adjustment Service Processing Unit is needed, due to the industry of Service Processing Unit processing
The type of business is different, and logic complexity is also different, the consumption degree of server resource is also differed, server resource
Including CPU usage, memory source etc., in practical business operation, it is likely that will appear subscription corresponding with Service Processing Unit
Message number in message queue is few, but the feelings for loading excess load of certain server that Service Processing Unit uses
Condition should carry out number of servers extension according to the loading condition of server at this time;It, should when for reduction number of servers
This had both considered the situation of the message number in subscription message queue corresponding with Service Processing Unit it is further contemplated that Service Processing Unit
The loading condition of the server used to codetermine the quantity for whether needing to reduce server, can accurately just reflect in this way
The traffic handing capacity of Service Processing Unit actual needs.
The service data processing apparatus of the embodiment of the present invention passes through the load to server used in Service Processing Unit
And the corresponding message queue current message quantity of subscribing to of Service Processing Unit in distributed post-subscription message system carries out
It monitors, the extension or contraction and lateral server node to the longitudinal thread of traffic handing capacity progress of Service Processing Unit
Extension is shunk.Mode in this way can make business processing more flexible, reduce service automatically when the business free time
Device node, automatic expansion service device node, so as to fulfill the automatic telescopic of traffic handing capacity, avoids when heavy traffic
Distributed post-message caused by subscription message system squeezes.
Ninth embodiment of the invention, the present embodiment are on the basis of above-described embodiment, and one is introduced with reference to attached drawing 7~8
The application example of the present invention.
As shown in fig. 7, the embodiment of the present invention provides a kind of device for avoiding consumer end service process performance bottleneck, with solution
After certainly big data message desk (kafka) is subscribed to the problem of the messaging service process performance bottleneck of consumer end.By this device certainly
The automatic horizontal stroke of the dynamic Longitudinal Extension and server node that thread is carried out according to Service Processing Unit current subscription message queue depth
To extension.
After Service Processing Unit starts, the device for avoiding consumer end service process performance bottleneck of the embodiment of the present invention
Just start immediately.The corresponding software product of the device can include Service Processing Unit, can not also include Service Processing Unit.
This programme biggest advantage is, the side that Service Processing Unit passes through interface inheritance by method, that is, device that realization device provides
Formula so that Service Processing Unit has horizontal and vertical extended capability.In addition, device has general high concurrent processing knot
Structure, the server node quantity that professional ability can be realized by simple configuration file extend automatically, and Message Processing is avoided to accumulate
Pressure, the appearance for situations such as server resource exorbitant expenditure and Message Processing is not prompt enough.
Server state detection module:For detection service device present load, can server be obtained by shell modes
The information for the Service Processing Unit currently supported.For Service Processing Unit, it can obtain used in the Service Processing Unit
Server loading condition.
Message queue detection module:Depth, i.e. current subscription queue message are squeezed for detecting current subscription queue message
Quantity.
Thread pool:Realize thread dynamic expansion in individual server node.
Message subscribing module:For subscribing to message queue for Service Processing Unit from agent side, Service Processing Unit need not
Repeated encoding is uniformly processed by the device.
Server list module:Server list is provided, comprising current server cluster maximum service device number of nodes, is also used
In dynamic expansion server node.
Cache module:For the configurations in configuration file to be loaded into local memory, comprising real in the configurations
The method and common data of existing business, share use for other modules,
Server thread load detecting module:For detecting the Thread Count under Service Processing Unit.
Service Processing Unit:In a manner that method, that is, device that realization device provides is by interface inheritance, to subscribing to
Message carry out normal business processing so that Service Processing Unit has horizontal and vertical extended capability.It is not required here
High concurrent and function extending transversely are paid close attention to, developer only needs to realize for the business processing flow of message progress subscribed to i.e.
It can.
As shown in figure 8, laterally --- the management of server:
Step 1, after Service Processing Unit 1 starts, the device of consumer end service process performance bottleneck is avoided also to open therewith
It is dynamic.
Step 2, initiation message subscribing module, message subscribing module need to use caching when pulling message from agent side first
The common data of configured in advance in module, and thread process message is occupied, thread pool starts at this time, and is loaded by server thread
Detection module detects the thread service condition of Service Processing Unit 1.
Step 3, start queue depth's detection module and server state detection module.
Step 4, pass through queue depth's detection module, server state detection module and the server list in the device
Module decision whether need to extend new server node come it is extending transversely.
Step 5, it when above-mentioned decision-making module, which detects, to be needed to extend new server node, is carried out by way of script
The automatic startup of server 2- processing units 1.So as to fulfill the dynamic expansion of server node.
Similarly, when decision-making module, which detects, to be needed to reduce the server node of the processing unit 1, by way of script
The closing of server 2- Service Processing Units 1 is carried out, so as to fulfill the reasonable utilization of the resource of server node.
The server node released can also be distributed to other Service Processing Units, be deleted by script corresponding
The lock file of Program Generating, lower portion have lock file checking finger daemon to be responsible for detecting whether to stop present node process.Stop
Corresponding heap memory and cpu resource can be discharged after only, after this, you can give the resource allocation to other processing units.
The management of longitudinal direction --- -- thread:
Be limited with the minimum and maximum Thread Count for the thread pool being configured in current configuration file, carry out the extension of thread pool with
It shrinks.
The embodiment of the present invention avoids the device of consumer end service process performance bottleneck from realizing to kafka message by this
It subscribes to, operation layer only needs to realize that the automatic of message pulls according to the configuration of configuration file.
By the detection to message queue depth, the detection of server state is realized the dynamic expansion of server node, is made
Operation layer can be absorbed in business processing, without paying close attention to the complicated realization under high concurrent in terms of dynamic expansion.
By the encapsulation of the Service Processing Unit to multithreading, shielding operation layer realizes multithreading.Realize single server
The realization of high concurrent in node traffic processing unit.
By the explanation of specific embodiment, should can to the present invention for reach technological means that predetermined purpose is taken and
Effect is able to more go deep into and specific understanding, however appended diagram is only to provide reference and description and is used, and is not used for originally
Invention limits.