Embodiment
In order that those skilled in the art more fully understand the technical scheme in the application, below in conjunction with the embodiment of the present application
Accompanying drawing, the technical scheme in the embodiment of the present application is clearly and completely described, it is clear that described embodiment is only
It is some embodiments of the present application, rather than whole embodiments.Based on the embodiment in the application, ordinary skill people
The every other embodiment that member is obtained under the premise of creative work is not made, it should all belong to the scope of the application protection.
Flow control methods described herein and device are described in detail below in conjunction with the accompanying drawings.Fig. 1 is the application proposition
Flow control methods a kind of embodiment method flow diagram.Although this application provides as shown in following embodiments or accompanying drawing
Method operating procedure or apparatus structure, but based on conventional or can be with methods described or device without performing creative labour
Including more or less operating procedure or modular structure.Necessary causality is not present in logicality the step of or structure
In, the execution sequence of these steps or the modular structure of device are not limited to execution sequence or module knot that the embodiment of the present application provides
Structure., can be according to embodiment or attached when the device in practice or end product of described method or modular structure perform
Method or modular structure connection carry out order execution shown in figure be either parallel to be performed (such as at parallel processor or multithreading
The environment of reason).
Specifically as shown in figure 1, a kind of embodiment for the flow control methods that the application provides can include:
S1:When it is determined that needing to carry out flow control, server end obtains the average response time convection current control threshold of current service request
Value carries out degradation processing;
The structure handled service request is carried in all computer networks and is construed as a system, once there is industry
Business request, then will also there is the problem of flow control, because if service set makes requests on, the carrying energy of server end
Power has a higher limit, therefore, if it is desired to all service requests are all handled, and rung in acceptable
Seasonable interior processing, just has to limit system entry flow, to be not easy occurring excess load, or some threads
Queuing is too long, can all influence systematic function, can also influence Consumer's Experience.
Therefore, during system is handled business, it is necessary to a judgement for whether carrying out flow control is carried out, with
Just server end is triggered when being necessary and carries out flow control, and in this example, the system can be inquiry system, data calculating
System, data handling system, data forwarding system etc., system here are the concept of a broad sense, accordingly, server
End is exactly the server of inquiry system, data computing system, data handling system, data forwarding system.
Specifically, when realizing, server end can be determined the need for by obtaining the active line number of passes of system entry into
Row flow controls, wherein, system entry can be understood as the input port of system, such as some application input connecing to the system
Mouthful, it can be sent in system and be handled by the request of this access service.
Thread be in process perform computing least unit, and execution processing unit scheduling base unit.If process is understood
Being completed for logically operating system for task, then thread represents to complete one of many possible subtasks of the task.Example
Such as, it is assumed that user starts the database application in a window, and operating system just will be expressed as one to the calling of database
Individual process.Assuming that user will produce a pay sheet form from database, and pass in a file, this is a subtask;
During pay sheet form is produced, user can be asked with defeated personal data library inquiry again, and this is a subtask again.So,
Operating system then asks each:Pay sheet form and the data query of new defeated people are expressed as the independent line in database process
Journey.Thread can independently dispatch execution on a processor.So-called active threads can be understood as also in the thread not being suspended of race,
Namely have been turned on and the not yet thread of fair termination or termination.
What therefore portal activity Thread Count showed is the current load of system, be can determine whether based on portal activity Thread Count
Flow control is carried out to system.Specifically, in the case where determining whether to carry out flow control, server end can be according to following
Mode judges:System in the active line number of passes and foregoing description scheduled duration of system entry thread pool in current scheduled duration is obtained to enter
The active line number of passes of mouth;The active line number of passes of system entry enters more than system in foregoing description scheduled duration in current scheduled duration
In the case of the active line number of passes preset multiple of mouth, it is determined that needing to carry out flow control.
For example, if preset duration is 5 minutes, preset multiple is 1.5 times, is detected when the active threads in first five minute
Number is 80, and the active line number of passes in first five minute is 40 (or the average Thread Count of first five minute is 8 per minute), and that is just
Show that the active line number of passes of current time period reaches the preset multiple of setting compared to the active line number of passes in previous cycle, this
When server end just need start dynamic flow control.
Be in the above-described embodiments with the total comparison that sum is carried out with the active threads in a upper cycle of the active threads of current period,
When actually realizing, an active line number of passes threshold value can also be preset, is somebody's turn to do if the active threads sum of current period is more than
Active line number of passes threshold value, then it is assumed that need to start dynamic flow control.It is specifically true using which kind of mode when actually performing
Fixed whether to carry out dynamic flow control, the application is not especially limited, can also being averaged using the active line number of passes of current period
Compared with the average value of the active line number of passes in previous cycle, specific manner of comparison can be actually needed to be selected value with actual set
Take.
S2:Server end carries out degradation processing according to the average response time convection current control threshold value;
It is after control threshold value is flowed in setting in view of existing stream prosecutor formula, this stream control threshold value just no longer changes, in flow control procedure
With regard to being intercepted always according to this stream control threshold value.However, the influence of the problems such as due to network processes speed, if always according to
This stream control threshold value fixed is handled, and may have inevitable congestion, so that the response time of service request
Become more and more long.In order to avoid the generation of this problem, server end can be according to the average response time of current service request
Convection current control threshold value carries out degradation processing, specifically, can include:Determine whether the average response time of current service request exceeds
Preset time threshold;If it was exceeded, convection current control threshold value carries out degradation processing, so as to ensure that the stand-by period of business was unlikely to
It is long.
That is, an acceptable response time is set, if detect the average response of the service request of current time period
Between be higher by default acceptable time (being namely higher by preset time threshold), then being considered as current set stream control threshold value is
It is irrational, it is necessary to carry out degradation processing to current stream control threshold value, so the response time of service request could be caused to shorten.
Can be that degradation processing is carried out to the stream control threshold value according to default degradation ratio when processing is degraded, such as:
X%, X% can be 10%, 20% etc., and specific value can select according to the system requirements and system load ability of reality,
The application is not construed as limiting to this.
S3:Server end carries out flow control using the stream control threshold value after degradation processing.
The processing of this degraded operation is nor the operation that can be settled at one go, it is also possible to next after first time degradation is carried out
Individual time cycle average response time is still above default acceptable time, and this when can carry out degradation processing again,
In follow-up degradation processing and it is non-required degrade processing identical degradation ratio fully according to first time, this ratio can be with
It is identical for the first time, can also be more lower than first time, such as first time degradation ratio is 10%, can be specifically 5%, so as to
So that whole demotion processes are more steady.That is, handled according to the default time cycle, until the response time can meet to want
Ask.That is, after the stream control threshold value after using degradation processing carries out flow control, server end can be obtained from using at degradation
Stream control threshold value after reason carries out the average response time of the service request in the preset duration after flow control;From using degradation
Stream control threshold value after processing carries out the average response time of the service request in the preset duration after flow control beyond described pre-
If in the case of time threshold, convection current control threshold value carries out degradation processing again, until the stream control threshold value after using degradation processing is carried out
The average response time of the service request in preset duration after flow control is less than preset time threshold.
The purpose handled that degrades is in order that default acceptable time can be returned to by obtaining the response time of service request, when business
The response time of request can meet after requirement, it is possible to which convection current control threshold value is upgraded automatically, until it is default to revert to stream control
Value.Certainly, specifically automatic escalation process be also the need to ensure that the response time be meet require, be one meet respond when
Between meet require on the premise of stream control threshold value escalation process.Upgrade proportion when upgrading can be very low, i.e., slow step by step
Slow upgrading, to prevent from needing adjusting back.Escalation process is carried out according to the average response time convection current control threshold value of current service request
Degradation processing is carried out afterwards, can be included:Determine the average response time of current service request whether less than or equal to described pre-
If time threshold;If less than or be equal to, convection current control threshold value carry out upgrading processing, until stream control threshold value recover to stream control preset value.
After system enters flow control mode, can currently there are flow control or service application to exist with proactive notification service application
Inquire about whether flowed control after getting the service request initiated using access personnel, it is specific by the way of active broadcast or passive
The mode of inquiry can be selected as needed, and the application is not construed as limiting to this.If the mode of passive query, then business should
After the service request in response to access personnel is inquired about, service request is handled according to stream control Query Result, if
Do not controlled by stream, then just business is handled, and request result is returned to the personnel of access, if controlled by stream, then just
Return to the personnel of access and controlled by stream.Specifically, can be in the average response time convection current control threshold value according to current service request
After carrying out degradation processing:Service request access has been detected whether, in the case where having detected service request access, server
Hold to the service application of service request and return to the current notification message for thering is flow to control, and the flow of control business application is degraded
Processing.
That is, when notice service application currently has stream to control, can also degrade ratio automatically for the business application setting controlled by stream,
This automatic degradation ratio can be identical or slightly larger than itself degradation ratio with the degradation ratio of system itself,
It can be selected according to being actually needed.Further, if controlled device in next cycle is still to be flowed control, then just after
It is continuous to degrade automatically, until after no longer being controlled by stream, then upgrading automatically, until reverting to stream control preset value.
Above-mentioned flow control methods are illustrated with reference to a specific embodiment, it is important to note, however, that the specific reality
Example is applied merely to the application is better described, does not form the improper restriction to the application.
It is only limitted to block the flow beyond threshold values primarily to solving flow control of the prior art in the embodiment of the present application
Cut and think that stream control is completed, some metric datas that can combine system in this example provide the automatic lifting level of stream control threshold value, with reality
Now to the more preferable protection of system.
To achieve these goals, the flow control system of the application can with as shown in Fig. 2 including:Data acquisition, metric data pipe
Reason, dynamic stream control tactical management and dynamic flow-control administration these modules, wherein, data acquisition module can be responsible for the degree of system
Data acquisition is measured, data aggregate is carried out in metric data management module after collection, dynamic stream control policy module is combined after data aggregate
The strategy of offer completes the dynamic promotion and demotion function of flow control valve value in dynamic flow-control administration module.
(1) dynamic stream interface driver
The configuration of dynamic stream interface driver can be completed by dynamic stream control policy management module by keeper, wherein, dynamic stream interface driver
Following components can be included:
1) strategy based on active threads number:
Current N minute active lines number of passes starts dynamic flow control mode before when M times of N minutes average value, i.e. logical
Active line number of passes is crossed to determine whether to start dynamic stream control.
2) strategy of the processing response time based on each service request:
For specific API (Application Programming Interface, application programming interface) current N minutes
When average response time exceeds tactful preset value, the flow control valve value of the specific API can be degraded automatically, degradation ratio
X% is could be arranged to, if next N minutes persistently exceed above-mentioned tactful preset value, then just on the basis of current flow control valve value
On continue automatic degradation X%, when recovering the response time, flow control valve value will upgrade automatically, until revert to stream control preset value.
3) strategy based on history stream control data:
When notifications service application has stream control to produce, can be degraded automatically to being set by the object of stream control, it is automatic to degrade
Ratio can also be X%, if continuing to be controlled by stream by stream control object next cycle, then just continue to degrade automatically, when being flowed
When controlling object not by stream control, automatic upgrading, until reverting to stream control preset value.
(2) data acquisition
It is responsible for the data acquisition of system loading conditions, in the embodiment of the present application, the data of collection can have:
1) system entry thread pool active threads number;
2) response times of each API of system to request processing.
3) to by the historical data of stream control.
(3) metric data is pushed to metric data management module
Metric data management module is responsible for carrying out polymerization processing to the data of collection.
(4) metric data of polymerization is pushed to dynamic flow-control administration module
Dynamic flow-control administration module is analyzed according to the metric data of polymerization, and combines dynamic stream interface driver and current dynamic stream
Control actual conditions generation additional flow strategy is applied in the stream control configuration of current system.
(5) request is initiated using access personnel
Service application calls whether dynamic flow-control administration module check is controlled by stream, if controlled by stream, dynamic flow-control administration module will
Record stream control data, and request is returned by the notification message of stream control to service application, if do not controlled by stream, service application will be entered
Row business processing simultaneously returns to request result to application access personnel.
In the above-described embodiments, by carrying out dynamic sensing to system load state, and stream control promotion and demotion processing is carried out automatically, can
, can be with when system goes wrong to solve the problems, such as that existing fluidics automatically adaptive system load condition can not change
Automatically convection current control carries out automatic upgrade or downgrade, has reached the technique effect of dynamic stream control.
For example, flow control system can with as shown in figure 3, including:The user terminal of server end and requested service, server end
Request is handled in response to the service request of user terminal.As shown in figure 3, server end is connected with multiple user terminals,
The species and type of user terminal are also different, and these user terminals all may be to server initiating business request, when multiple user terminals
Simultaneously during initiating business request, server end load can be caused excessive unavoidably, therefore, server end is to service request
When reason, it is possible to carry out dynamic stream control to service request according to above-mentioned stream prosecutor formula.
Volume control device in upper server end can with as shown in figure 4, including:Acquisition module 401, the and of degradation module 402
Stream control module 403, i.e. server end is handled by the volume control device the service request from user terminal and dynamic
Stream control, is illustrated to the structure below.
Acquisition module 401, it can be used in the case of it is determined that needing to carry out flow control, obtaining being averaged for current service request
Response time;
Degradation module 402, it can be used for carrying out degradation processing according to the average response time convection current control threshold value;
Stream control module 403, it can be used for carrying out flow control using the stream control threshold value after degradation processing.
In one embodiment, as shown in figure 5, above-mentioned volume control device can also include:Determining module 501, specifically
It can be used for being determined the need for carrying out flow control according to the active line number of passes of system entry.
In one embodiment, as shown in figure 5, determining module 501 can include:Acquiring unit 5011, for specifically using
In the active threads of system entry in the active line number of passes of system entry in the current scheduled duration of acquisition and foregoing description scheduled duration
Number;First determining unit 5012, the active line number of passes for the system entry thread pool in current scheduled duration are more than the foregoing description
In scheduled duration in the case of the active line number of passes preset multiple of system entry, it is determined that needing to carry out flow control.
In one embodiment, as shown in figure 5, degradation module 402 can include:Second determining unit 4021, for true
Whether the average response time for determining current service request exceeds preset time threshold;Processing unit 4022, for determining currently
In the case that the average response time of service request exceeds preset time threshold, convection current control threshold value carries out degradation processing.
In one embodiment, processing unit specifically can be used for dropping the stream control threshold value according to default degradation ratio
Level processing.
In one embodiment, above-mentioned volume control device can also include:Acquisition module, for obtaining from using at degradation
Stream control threshold value after reason carries out the average response time of the service request in the preset duration after flow control;Adjusting module, use
Yu Cong carries out the average response of the service request in the preset duration after flow control using the stream control threshold value after degradation processing
Time exceeds in the case of the preset time threshold, and convection current control threshold value carries out degradation processing again, until after using degradation processing
The average response time of service request that carries out in the preset duration after flow control of stream control threshold value be less than the preset time
Threshold value.
In one embodiment, above-mentioned volume control device can also include:Module is confirmed, for after using degradation processing
Stream control threshold value carry out flow control after, determine current service request average response time whether be less than or equal to it is described default
Time threshold;Upgraded module, for it is determined that the average response time of current service request is less than or equal to the preset time threshold
In the case of value, convection current control threshold value carries out upgrading processing, until stream control threshold value is recovered to control preset value to stream.
In one embodiment, above-mentioned volume control device can also include:Detection module, for after using degradation processing
Stream control threshold value carry out flow control after, detected whether service request access;Module is returned to, for detecting business
In the case of request access, the current notification message for having flow to control is returned to the service application of the service request;Control module,
For controlling the flow of the service application to carry out degradation processing.
It is similar to flow control methods to solve the principle of problem due to volume control device, therefore the implementation of volume control device can be with
Referring to the implementation of flow control methods, repeat part and repeat no more.It is used above, term " unit " or " module "
The combination of the software and/or hardware of predetermined function can be realized.Although described device is preferably realized with software, firmly
Part, or the realization of the combination of software and hardware is also what may and be contemplated.
The flow control methods and device that the application provides, in the case of it is determined that needing to carry out flow control to system, server
End determines the need for carrying out degradation processing to default stream control threshold value according to the average response time of current service request, i.e. stream
Control threshold value is the numerical value of a dynamic change, rather than from start to finish all by the way of a fixed numerical value.If for example,
The processing speed that average response time is long so to indicate that current business is too slow, and period of reservation of number is oversize, at this time can
Stream control threshold value is reduced, so that more business are processed simultaneously, to improve the processing speed of service request, reduces the sensation of interim card,
This is the existing effect for using fixed stream control threshold value not reached, and efficiently solves prior art through the above way using fixation
Stream control threshold value carry out flow control caused by system fluid control effect it is bad, can not automatically adaptive system load condition change technology
Problem, the technique effect of dynamic stream control is reached.
Foregoing description in the application involved by each embodiment is only the application in some embodiments in the application, in some marks
Embodiment amended slightly can also carry out the scheme of each embodiment of above-mentioned the application on the basis of standard, model, method.When
So, other deformations without creativeness of the process method step described in the application the various embodiments described above are being met, still can be with
Identical application is realized, will not be repeated here.
Although this application provides the method operating procedure as described in embodiment or flow chart, based on conventional or without creativeness
Work can include more or less operating procedures.The step of being enumerated in embodiment order is only numerous step execution sequences
In a kind of mode, do not represent unique execution sequence., can be according to reality when device or client production in practice performs
Applying example, either method order shown in the drawings performs or performs (such as environment of parallel processor or multiple threads) parallel.
The device or module that above-described embodiment illustrates, it can specifically be realized by computer chip or entity, or by with certain work(
Can product realize.For convenience of description, it is divided into various modules during description apparatus above with function to describe respectively.Implementing
The function of each module can be realized in same or multiple softwares and/or hardware during the application.It is of course also possible to certain will be realized
The module of function combines realization by multiple submodule or subelement.
Method, apparatus described herein or module can realize controller by any suitable in a manner of computer readable program code
When mode realize, for example, controller can take such as microprocessor or processor and storage can be by (micro-) processor
Computer-readable medium, gate, switch, the special collection of the computer readable program code (such as software or firmware) of execution
Into circuit (Application Specific Integrated Circuit, ASIC), programmable logic controller (PLC) and embedded microcontroller
Form, the example of controller include but is not limited to following microcontroller:ARC 625D、Atmel AT91SAM、Microchip
PIC18F26K20 and Silicone Labs C8051F320, the control that Memory Controller is also implemented as memory are patrolled
The part collected.It is also known in the art that in addition to realizing controller in a manner of pure computer readable program code,
Completely can by by method and step carry out programming in logic come controller with gate, switch, application specific integrated circuit, can compile
The form of journey logic controller and embedded microcontroller etc. realizes identical function.Therefore this controller is considered one kind
Hardware component, and what its inside was included is used to realize that the device of various functions can also to be considered as the structure in hardware component.Or
Even, it not only can be able to will be the software module of implementation method for realizing that the device of various functions is considered as but also can be hardware component
Interior structure.
Part of module in herein described device can be in the general context of computer executable instructions
Described in, such as program module.Usually, program module includes performing particular task or realizes the example of particular abstract data type
Journey, program, object, component, data structure, class etc..The application can also be put into practice in a distributed computing environment, at this
In a little DCEs, by performing task by communication network and connected remote processing devices.In Distributed Calculation
In environment, program module can be located in the local and remote computer-readable storage medium including storage device.
As seen through the above description of the embodiments, those skilled in the art can be understood that the application can be by soft
Part adds the mode of required hardware to realize.Based on such understanding, the technical scheme of the application is substantially in other words to existing skill
The part that art contributes can be embodied in the form of software product, can also be by being embodied in the implementation process of Data Migration
Out.The computer software product can be stored in storage medium, such as ROM/RAM, magnetic disc, CD, including some
Instruct to cause a computer equipment (can be personal computer, mobile terminal, server, or network equipment etc.)
Perform the method described in some parts of each embodiment of the application or embodiment.
Each embodiment in this specification is described by the way of progressive, and same or analogous part is mutual between each embodiment
Referring to what each embodiment stressed is the difference with other embodiment.The all or part of of the application can
For in numerous general or special purpose computing system environments or configuration.Such as:Personal computer, server computer, hold
Equipment or portable set, laptop device, mobile communication terminal, multicomputer system, the system based on microprocessor, can
Electronic equipment, network PC, minicom, the mainframe computer of programming include the distributed meter of any of the above system or equipment
Calculate environment etc..
Although depicting the application by embodiment, it will be appreciated by the skilled addressee that the application have it is many deformation and change and
Spirit herein is not departed from, it is desirable to which appended claim includes these deformations and changed without departing from spirit herein.