[go: up one dir, main page]

CN107402810A - Thread distribution method and device - Google Patents

Thread distribution method and device Download PDF

Info

Publication number
CN107402810A
CN107402810A CN201610342244.7A CN201610342244A CN107402810A CN 107402810 A CN107402810 A CN 107402810A CN 201610342244 A CN201610342244 A CN 201610342244A CN 107402810 A CN107402810 A CN 107402810A
Authority
CN
China
Prior art keywords
thread
time
cluster
destination request
response time
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201610342244.7A
Other languages
Chinese (zh)
Other versions
CN107402810B (en
Inventor
赵凯
朱志强
杜华兵
王力
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201610342244.7A priority Critical patent/CN107402810B/en
Publication of CN107402810A publication Critical patent/CN107402810A/en
Application granted granted Critical
Publication of CN107402810B publication Critical patent/CN107402810B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention provides a kind of thread distribution method and device, the maximum query rate per second for relying on cluster and allowing relied on by obtaining target cluster, when destination request distributes thread, the current thread number being used according to the response time between maximum query rate per second, target cluster and dependence cluster and target cluster, obtain target cluster distributes Thread Count, obtain the required Thread Count of destination request, when Thread Count needed for destination request is less than or equal to that Thread Count can be distributed, then corresponding thread is distributed for destination request.In the present embodiment; target cluster distributes number of passes according to relying on the maximum query rate per second that is allowed of cluster limit itself; realize that itself is limited concurrent request quantity; play a part of protection and rely on cluster; the impact to caused by relying on cluster is reduced, reduces and relies on the risk that cluster occurs shaking or collapsed.

Description

Thread distribution method and device
Technical field
The invention belongs to computer application field, more particularly to a kind of thread distribution method and device.
Background technology
Cluster computing carrys out a focus of referred to as computer circle research in recent years.Cluster is not only able to make full use of now Some computing resources, and the computer system of superior performance can be realized by relatively low software and hardware cost.
In the environment of more clusters are run simultaneously, the performance of each cluster has differences.For example, high performance cluster A can Can exist to another cluster B and rely on, and cluster B performance is less than cluster A performance.When cluster A operates in height simultaneously In the environment for sending out request, and cluster A, frequently to cluster B concurrent requests, in this case, the request of cluster A high concurrents has Cluster B shake or collapse are likely to result in, the offer service of cluster B not stabilizabilities is provided, ultimately results in disaster accident Occur.
At present, in order to ensure that cluster B can provide stable service for cluster A, the number of machines in cluster B can be increased Amount, so when cluster A frequently will be significantly to frequency phenomena such as during cluster B transmission requests, cluster B occurs shaking or collapsed Reduce, but it is this improve the method for cluster B performances by increasing machine resources, and the request sent to cluster B as cluster A When being not frequent, wasting phenomenon that increased machine resources just occur.
The content of the invention
The present invention provides a kind of thread distribution method and device, and the machine for solving to rely on cluster by increase provides Source, the risk that the cluster to reduce relied on occurs shaking or collapsed, it frequently can lead to the waste problem of machine resources.
To achieve these goals, the invention provides a kind of thread distribution method, including:
Obtain the maximum query rate per second for relying on cluster and allowing that target cluster is relied on;
When distributing thread to pending destination request, the target cluster and the sound relied between cluster are obtained Between seasonable;
Obtain the current thread number that the target cluster is used;
Based on maximum query rate per second, the response time and the current thread number, target cluster is obtained Thread Count can be distributed;
Obtain the required Thread Count of the destination request;
Judge Thread Count needed for the destination request can distribute Thread Count described in whether being less than or equal to;
It is corresponding for destination request distribution if Thread Count needed for described can distribute Thread Count described in being less than or equal to Thread.
To achieve these goals, the invention provides a kind of thread distributor, including:
Query rate acquisition module, the maximum query rate per second for relying on cluster and allowing relied on for obtaining target cluster;
Time-obtaining module, for when distributing thread to pending destination request, take the target cluster with it is described Rely on the response time between cluster;
Current thread acquisition module, obtain the current thread number that the target cluster is used;
Distribute thread acquisition module, for based on maximum query rate per second, the response time and it is described currently Thread Count, obtain target cluster distributes Thread Count;
Required thread acquisition module, for obtaining the required Thread Count of the destination request;
Judge module, for judging Thread Count needed for the destination request can distribute Thread Count described in whether being less than or equal to;
Distribute module, for judging that the required Thread Count can distribute thread described in being less than or equal in the judge module During number, then corresponding thread is distributed for the destination request.
Thread distribution method and device provided by the invention, what the dependence cluster relied on by obtaining target cluster allowed Maximum query rate per second, when destination request distributes thread, according to maximum query rate per second, target cluster and dependence cluster it Between the current thread number that is used of response time and target cluster, obtain the Thread Count that distributes of target cluster, obtain The required Thread Count of destination request, then it is destination request point when Thread Count needed for destination request is less than or equal to that Thread Count can be distributed With corresponding thread.In the present embodiment, target cluster limits itself according to the maximum query rate per second that is allowed of cluster is relied on Distribute number of passes, that is, realize that itself is limited concurrent request quantity, play a part of protection rely on cluster, reduce to according to Impact caused by relying cluster, reduce and rely on the risk that cluster occurs shaking or collapsed.
Brief description of the drawings
Fig. 1 is the schematic flow sheet of the thread distribution method of the embodiment of the present invention one;
Fig. 2 is the schematic flow sheet of the thread distribution method of the embodiment of the present invention two;
Fig. 3 is the schematic flow sheet of the thread distribution method of the embodiment of the present invention three;
Fig. 4 is the structural representation of the thread distributor of the embodiment of the present invention four;
Fig. 5 is the structural representation of the required thread acquisition module in the embodiment of the present invention four;
Fig. 6 is the structural representation of the thread distributor of the embodiment of the present invention five.
Embodiment
Thread distribution method provided in an embodiment of the present invention and device are described in detail below in conjunction with the accompanying drawings.
Embodiment one
As shown in figure 1, its schematic flow sheet for the thread distribution method of the embodiment of the present invention one.The thread distribution method Comprise the following steps:
S101, obtain the maximum query rate per second for relying on cluster and allowing that target cluster is relied on.
In the present embodiment, target cluster obtains the relied on maximum query rate per second for relying on cluster and allowing.Wherein, it is per second Query rate (Query Per Second, abbreviation QPS) is specifically to inquire about server handled stream at the appointed time to one Measure how many criterions.QPS correspondingly obtains the second (fetches/sec), i.e., respond request number per second, that is to say maximum throughput Ability.
When target cluster to rely on cluster concurrent request quantity, no more than rely on cluster allowed number of requests when, then Target cluster, which will not cause, to be relied on cluster and the unstable phenomenon such as occurs shaking.And when target cluster is to relying on cluster concurrent request Quantity, beyond when relying on number of requests that cluster is allowed, then target cluster, which may cause, relies on cluster and occurs shaking etc. no Stable phenomenon.Wherein, the number of requests that relying on cluster is allowed can be got by the maximum query rate per second of permission.
Alternatively, after the maximum query rate per second for relying on cluster is got, for the concurrent request quantity to itself Limited, the maximum query rate per second that target cluster can be allowed, be arranged to the maximum inquiry per second of the dependence cluster Rate, concurrent number of requests can thus be limited from target cluster side, avoid the occurrence of concurrent request excessive number, it is right Rely on the risk that cluster impacts.
S102, when distributing thread to pending destination request, obtain target cluster and rely on the response between cluster Time.
Preferably, by way of sampling, the historical responses time is obtained, when extracting response according to the historical responses time Between.Specifically, the historical responses time in preset duration is obtained, it is regular to carry out data to the historical responses time, first can be with The exceptional sample in the historical responses time is first rejected, to obtain the remaining historical responses time, remaining history is then calculated and rings Arithmetic mean of instantaneous value between seasonable, using the arithmetic mean of instantaneous value as response time (Response Time, abbreviation RT).
For example, being based on standard deviation formula, the standard deviation sigma and arithmetic mean of instantaneous value μ of historical responses time are obtained, utilizes mark Accurate poor σ and arithmetic mean of instantaneous value μ, the normal distribution of historical responses time is obtained, the history outside (μ -3 σ, μ+3 σ) will be fallen and rung It is used as the exception response time, after the exception response time is weeded out, obtain remaining historical responses time, Ran Hou between seasonable The arithmetic mean of instantaneous value of remaining historical responses time is calculated, using the arithmetic mean of instantaneous value as response time RT.
Alternatively, a dedicated thread of target cluster is enabled, the response time is specially measured in real time using the thread, is set In real time after measurement RT dedicated thread, certain test parameter can be pre-set, is then based on test parameter according to the time It is spaced the Dependency Set relied on to target cluster and has mass-sended calling, records after repeatedly test, what special county town measured in real time Measure the response time meeting stable value in one, region, the response time RT using the amount response time after stabilization as target cluster.
S103, obtain the current thread number that target cluster is used.
In the running of target cluster, the host node (Master Node) in target cluster can be to being used Current thread number recorded, the current thread number that the target cluster is used can be got from host node.
S104, based on maximum query rate, response time and current thread number per second, obtain target cluster distributes line Number of passes.
When pending processing destination request, in order to perform the destination request, it is necessary to distribute thread for destination request.Tool Body, single thread query rate per second is calculated according to the response time, it is then per second according to maximum query rate per second and single thread Query rate, obtain maximum thread.Maximum thread=maximum query rate/single thread query rate per second per second.Further, root According to maximum thread and current thread number, the Thread Count that distributes of target cluster is calculated, i.e., by maximum thread and current The difference of Thread Count, Thread Count is distributed as target cluster.
Specific formula is as follows:
N=(M-Qt*Ct)/Qt;
Wherein, N represents that Thread Count can be distributed;M represents maximum query rate per second;Ct represents current thread number;Qt represents single Thread query rate per second, Qt=1/RT, RT represent the response time.
According to above-mentioned formula as can be seen that M/Qt ratio is the maximum thread of target cluster.
In the present embodiment, the max line of the target cluster is limited according to the maximum query rate per second that is allowed of cluster is relied on Number of passes, so as to play the purpose that target cluster is limited concurrent request quantity itself, and then it can reduce to relying on Impact caused by cluster.
S105, the required Thread Count for obtaining destination request.
In the present embodiment, destination request can be disassembled, obtain disassembling task amount corresponding to destination request.Specifically Ground, data volume corresponding to destination request is obtained, by the data volume of destination request data volume corresponding with default individual task Radix does ratio, and task amount is disassembled using the ratio as destination request.It is possible to further preset each task by more Few thread goes to be executed concurrently, you can with the default Thread Count performed needed for individual task, destination request is disassembled into task amount Product is done with the Thread Count needed for individual task, it is possible to obtains the required Thread Count of destination request.
Alternatively, in order to avoid occurring impacting to relying on cluster, a maximum task amount can be preset, is being got After disassembling task amount, judge that this disassembles whether task amount exceeds default maximum task amount, if it is judged that to disassemble task Amount exceeds the maximum task amount, then the goal task amount using the maximum task amount as destination request, then according to default list The Thread Count and goal task amount of individual required by task, calculate the required Thread Count of the destination request.
Further, if it is judged that to disassemble task amount without departing from maximum task amount, then according to needed for individual task Thread Count and disassemble task amount, calculate the required Thread Count of destination request.
In distributed type assemblies, it can fix each task is gone to be executed concurrently by how many thread, for example, list can be set The Thread Count of individual required by task is 4, is that 4 threads concurrently perform completion individual task by this.The data volume of destination request is 80005, data volume radix corresponding to individual task is 10000, then the task amount of disassembling of destination request is 80005/10000= 8.0005, it is 9 after value.In order to ensure that larger impact is not caused to relied on cluster, the maximum task amount pre-set is 6, then the goal task amount of the destination request be arranged to 6, then the Thread Count taken needed for the pending request is 4*6=24, i.e., Need to distribute 24 threads, to perform the destination request.
S106, judge whether Thread Count needed for destination request is less than or equal to that Thread Count can be distributed.
After Thread Count needed for destination request is got, in order to guarantee to be processed, it is necessary to there is foot for destination request Enough distributes Thread Count, it is therefore desirable to by Thread Count needed for destination request compared with it can distribute Thread Count, judges target Whether Thread Count needed for request is less than or equal to that Thread Count can be distributed.If Thread Count needed for destination request is less than or equal to that line can be distributed During number of passes, then S107 is performed.If Thread Count needed for destination request performs S108 more than when can distribute Thread Count.
S107, it is that destination request distributes corresponding thread.
When Thread Count needed for destination request is less than or equal to that Thread Count can be distributed, illustrate that target cluster can currently distribute thread Number is more, is limited due to that can distribute Thread Count by the maximum query rate per second of cluster is relied on, so target cluster is the target After request distribution thread, the destination request will not impact to relying on cluster, then to destination request according to its required Thread Count It is allocated thread.
S108, destination request is placed into waiting list and ranked, wait next thread to distribute.
When Thread Count needed for destination request be more than can distribute Thread Count when, illustrate target cluster can currently distribute Thread Count compared with It is few, limited due to Thread Count can be distributed by the maximum query rate per second of cluster is relied on, so target cluster is the destination request After distributing thread, the destination request may impact to relying on cluster, now thread will not be distributed to destination request, by mesh Mark request, which is placed into waiting list, ranks, and waits next thread to distribute.
The thread distribution method that the present embodiment provides, the maximum for relying on cluster and allowing relied on by obtaining target cluster Query rate per second, when destination request distributes thread, according between maximum query rate per second, target cluster and dependence cluster The current thread number that response time and target cluster are used, the Thread Count that distributes of target cluster is obtained, obtains target The required Thread Count of request, when Thread Count needed for destination request is less than or equal to that Thread Count can be distributed, then distribute phase for destination request The thread answered.In the present embodiment, target cluster according to rely on the maximum query rate per second that is allowed of cluster can come limit itself Number of passes is distributed, that is, realizes that itself is limited concurrent request quantity, plays a part of protection and relies on cluster, reduce to Dependency Set Impact caused by group, reduce and rely on the risk that cluster occurs shaking or collapsed.
Embodiment two
As shown in Fig. 2 its schematic flow sheet for the thread distribution method of the embodiment of the present invention two.In above-described embodiment On basis, judge thread needed for destination request be more than or equal to it is described can distribute thread, then be destination request distribution Its respective thread, comprise the following steps:
S201, when Thread Count is less than or equal to that Thread Count can be distributed needed for judge, obtain needed for processing destination request Processing time.
On before the step of, here is omitted, reference can be made in above-described embodiment one related content record, herein not Repeat again.
After ensureing destination request distribution thread, destination request will not impact to relying on cluster, can be further Ground obtains the processing time needed for processing destination request.Specifically, single thread query rate per second is calculated according to the response time, so Obtain single thread query rate per second afterwards and the product of Thread Count can be distributed, by the corresponding data volume of destination request and the product Do ratio, it is possible to the processing time of destination request.
Specifically formula is:
T=RS/N*Qt;
Wherein, T represents processing time, and RS represents the sample size of destination request, and N represents that Thread Count can be distributed, and Qt represents single The query rate per second of individual thread, Qt=1/RT, RT represent the response time.
S202, by processing time compared with default time threshold.
In the present embodiment, the time needed for the processing of historical requests can be obtained, according to the time needed for these history, system Meter obtains the required time of an experience, using the required time of the experience as time threshold.
After processing time is got, by processing time compared with default time threshold, when treated between be less than During time threshold, S203 is performed;When being more than or equal to time threshold between when treated, S204 is performed.
If S203, processing time are less than time threshold, corresponding thread is distributed for destination request.
When being less than time threshold between when treated, then it represents that for destination request distribute thread after, destination request will not to according to Bad cluster impacts, and target cluster distributes its respective thread to destination request, completes being operated when secondary for user.
If S204, processing time is more than or equal to time threshold, destination request is placed into waiting list and ranked, Wait thread distribution next time.
When being more than or equal to time threshold between when treated, then it represents that target cluster is that destination request distributes corresponding thread, Participate in calculate will break through rely on cluster safety line number of passes, can to rely on cluster produce large effect, may result according to Rely the unstable of cluster, phenomena such as occurring shaking or collapse, now destination request will not be allocated its respective thread, destination request Waiting list can only be placed into, waits thread distribution next time.Alternatively, can be with when destination request is placed into waiting list The busy reminder message of a system is returned to user, in order to which user carries out other operations within the stand-by period, improves user Experience.
S205, when destination request waits in line the distribution of next thread, will when meeting that default priority sets condition The priority of destination request is arranged to highest.
In the present embodiment, in order that destination request is performed or handled as much as possible earlier, pre-set certain excellent First level sets condition, during destination request waits in line next thread distribution, when meeting that default priority sets bar After part, the priority of destination request is arranged to highest, it is enough when distributing thread in order to have, it is preferably destination request point With its respective thread.
Wherein, it can be that the time length that destination request waits exceeds regular hour length that priority, which sets condition, or The number that destination request waits exceedes default number, or the distribution instruction of destination request decays to minimum value.When in appearance One of situation is stated, just meets the condition that priority is set, then the priority of destination request is arranged to highest.
S206, when that can distribute Thread Count and be more than or equal to required Thread Count, directly for destination request distribute corresponding to thread.
After the priority of destination request is arranged into highest, when Thread Count can be distributed more than or equal to required Thread Count, Then it is directly thread corresponding to destination request distribution due to the highest priority of destination request.
The thread distribution method that the present embodiment provides, by when distributing thread to destination request, per second looked into based on maximum Inquiry rate acquisition target cluster distributes Thread Count, is less than or equal to that Thread Count can be distributed in Thread Count needed for destination request, enters one Step obtains the processing time performed needed for the destination request, and when processing time being less than time threshold, phase is distributed for destination request The thread answered, preferably Dependency Set group can be played a protective role.In the present embodiment, target cluster is permitted according to cluster is relied on Perhaps maximum query rate per second limits the number of passes that distributes of itself, that is, realizes that itself is limited concurrent request quantity, rises To protection rely on cluster effect, and by the processing time needed for destination request ensure for destination request distribute thread Afterwards, destination request, which will not trigger, relies on phenomena such as cluster occurs shaking or collapsed, and further reduces target cluster to Dependency Set Impact caused by group.
Embodiment three
As shown in figure 3, its schematic flow sheet for the thread distribution method of the embodiment of the present invention three.In above-described embodiment It is further comprising the steps of after corresponding thread is distributed for destination request on basis:
S301, performance objective ask during, monitor the current response time in real time.
After distributing corresponding thread to destination request, then performance objective please in the thread parallel by distribution for can Ask, during performance objective is asked, the current response time can be monitored in real time.
If S302, current response time are more than the response time in duration time interval, using between the time Every the current response time of interior monitoring, a revised response time is calculated.
In practical application, in the case where thread is certain, when monitoring that the current response time exceeds the response time When, illustrate that current point in time relies on the process performance reduction of cluster or is deteriorated, in the present embodiment, the response time is above-mentioned Response time for being obtained in embodiment according to the historical responses time or to be measured in real time by dedicated thread in above-described embodiment Response time.
Specifically, by the current response time monitored in duration time interval compared with the response time, if worked as When the preceding response time is more than the response time in duration time interval, illustrate the place that cluster is relied in this time interval Rationality can be reduced or be deteriorated, and stable service is enough provided for target cluster in order to ensure Dependency Set group energy,
In the present embodiment, enough current response times real-time monitored are obtained by duration time interval, utilized The current response time real-time monitored in duration time interval is got, calculates a revised response time, will The revised response time is as the new response time.
S303, acquisition response time make ratio with the revised response time, using the ratio as correction factor.
The response time and the revised response time that calculate when can distribute Thread Count are done into ratio, using the ratio as repairing Positive coefficient.
S304, using correction factor the thread needed for individual task is adjusted.
Correction factor and the Thread Count needed for default individual task before are done into product, a new line can be obtained Number of passes is as the Thread Count needed for individual task, and so as to reduce the Thread Count needed for individual task, target cluster is right again The Thread Count of itself is limited, and can alleviate the pressure for relying on cluster.
S305, using correction factor the maximum query rate per second of target cluster is adjusted.
, will after the maximum query rate per second for relying on cluster and allowing that target cluster is relied on is obtained in the present embodiment The maximum query rate per second itself allowed of the target cluster is arranged to rely on the maximum query rate per second of cluster.
Query rate per second can be determined according to the Thread Count and response time of setting in practice, by default thread Number and the ratio of response time are as query rate per second.In order to save the process performance for relying on cluster, avoid finally leading Cause dependence cluster to collapse, after correction factor is got, the correction factor is done with maximum query rate per second before and multiplied Product, the maximum query rate per second after an adjustment can be obtained, and the maximum query rate value per second after adjustment is utilized into network Host node of the communication synchronization to cluster.
In the present embodiment, target cluster limits dividing for itself according to the maximum query rate per second that is allowed of cluster is relied on With number of passes, that is, realize that itself is limited concurrent request quantity, play a part of protection and rely on cluster, and in performance objective During request, by monitoring the change of response time, to understand the situation of change for the process performance for relying on cluster, work as appearance When process performance is reduced or is deteriorated, saved in time using the current response time monitored, Dependency Set can be reduced The probability for phenomena such as group occurs shaking or collapsed, reduce the impact to caused by relying on cluster of target cluster.
Example IV
As shown in figure 4, its structural representation for the thread distributor of the embodiment of the present invention four.The thread distributor Including:Query rate acquisition module 11, response time acquisition module 12, current thread acquisition module 13, distribution threading models 14, institute Need thread acquisition module 15, judge module 16 and distribute module 17.
Query rate acquisition module 11, the maximum inquiry per second for relying on cluster and allowing relied on for obtaining target cluster Rate.
Response time acquisition module 12, for when distributing thread to pending destination request, obtaining the object set Group and the response time relied between cluster.
Current thread acquisition module 13, the current thread number being used for obtaining the target cluster.
Distribute thread acquisition module 14, for based on maximum query rate per second, the response time and it is described ought Preceding Thread Count, obtain target cluster distributes Thread Count.
Required thread acquisition module 15, for obtaining the required Thread Count of the destination request.
Judge module 16, for judging Thread Count needed for the destination request can distribute thread described in whether being less than or equal to Number.
Distribute module 17, for judging that the required Thread Count can distribute line described in being less than or equal in the judge module During number of passes, then corresponding thread is distributed for the destination request.
Thread acquisition module 14 is distributed, Thread Count can be distributed specifically for being obtained based on equation below;
N=(M-Qt*Ct)/Qt;
Wherein, Thread Count can be distributed described in N expressions;M represents the maximum query rate per second;Ct represents current thread number; Qt represents single thread query rate per second, and Qt=1/RT, RT represent the response time.
In the present embodiment, response time acquisition module 12, specifically for obtaining the historical responses time in preset duration, base The response time is obtained in the historical responses time.
Response time acquisition module 12, specifically for rejecting the exception history response time in the historical responses time, To obtain the remaining historical responses time, the arithmetic mean of instantaneous value of the remaining historical responses time is calculated, and by the calculation Art average value is as the response time.
Alternatively, response time acquisition module 12, specifically for starting the dedicated thread for being used for measuring the response time in real time, Measured in real time by the dedicated thread, to obtain the response time.
As shown in figure 5, a kind of alternatively frame mode of thread acquisition module 15 needed for the present embodiment, including:Disassemble TU task unit 151, judging unit 152, setting unit 153 and computing unit 154.
Wherein, TU task unit 151 is disassembled, task amount is disassembled corresponding to the destination request for obtaining.
Judging unit 152, for judging described to disassemble whether task amount exceeds default maximum task amount.
Setting unit 153, exceed the maximum task for the judged result in the judging unit to disassemble task amount During amount, then the goal task amount using the maximum task amount as the destination request.
Computing unit 154, for the Thread Count according to needed for default individual task and the goal task amount, calculate institute State the required Thread Count of destination request.
Further, computing unit 154, be additionally operable to the judged result in judging unit 152 for disassemble task amount without departing from During the maximum task amount, then the Thread Count according to needed for the individual task and it is described disassemble task amount, calculate the target The required Thread Count of request.
TU task unit 151 is disassembled, specifically for data volume corresponding to destination request is corresponding with default individual task Data volume radix does ratio, using the ratio as disassembling task amount.
The thread distribution method that the present embodiment provides, the maximum for relying on cluster and allowing relied on by obtaining target cluster Query rate per second, when destination request distributes thread, according between maximum query rate per second, target cluster and dependence cluster The current thread number that response time and target cluster are used, the Thread Count that distributes of target cluster is obtained, obtains target The required Thread Count of request, when Thread Count needed for destination request is less than or equal to that Thread Count can be distributed, then distribute phase for destination request The thread answered.In the present embodiment, target cluster according to rely on the maximum query rate per second that is allowed of cluster can come limit itself Number of passes is distributed, that is, realizes that itself is limited concurrent request quantity, plays a part of protection and relies on cluster, reduce to Dependency Set Impact caused by group, reduce and rely on the risk that cluster occurs shaking or collapsed.
Embodiment five
As shown in fig. 6, its structural representation for the thread distributor of the embodiment of the present invention five.The thread distributor Processing includes query rate acquisition module 11, response time acquisition module 12, current thread acquisition module in above-described embodiment four 13rd, distribute outside thread acquisition module 14, required thread acquisition module 15, judge module 16 and distribute module 17, in addition to:Place Reason time-obtaining module 18, comparison module 19, queue module 20, priority setup module 21, setup module 22, mould is monitored in real time Block 23, response time correcting module 24, correction factor acquisition module 25 and adjusting module 26.
Processing time acquisition module 18, it is described for judging that the required Thread Count is less than or equal in the judge module When can distribute Thread Count, the processing time handled needed for the destination request is obtained.
Comparison module 19, for by the processing time compared with default time threshold.
Distribute module 17, if being additionally operable to the processing time is less than the time threshold, for the destination request point With corresponding thread.
Queue module 20, for when the processing time being more than or equal to the time threshold, then by the destination request It is placed into waiting list and ranks, waits thread distribution next time.
Priority setup module 21, it is default when meeting for when the destination request waits in line the distribution of next thread Priority set condition when, the priority of the destination request is arranged to highest;
Distribute module 17, be additionally operable to when it is described distribute Thread Count be more than or equal to it is described needed for Thread Count when, be directly institute State thread corresponding to destination request distribution.
Processing time acquisition module 18, specifically for calculating single thread query rate per second according to the response time, obtain Take single thread query rate per second and the product for distributing Thread Count;Obtain the sample size of the destination request with it is described Can product ratio, using the ratio as the processing time.
Setup module 22, the cluster that relies on relied on for query rate acquisition module acquisition target cluster allow most After big query rate per second, the maximum query rate per second itself allowed of the target cluster is arranged to the dependence cluster Maximum query rate per second.
Real-time monitoring modular 23, for during the destination request is performed, monitoring the current response time in real time.
Response time correcting module 24, if being more than the response in duration time interval for the current response time During the time, using the current response time monitored in the time interval, a revised response time is calculated.
Correction factor acquisition module 25, ratio is done with the revised response time for obtaining the response time, And using the ratio as correction factor.
Adjusting module 26, for being adjusted using coefficient after the amendment to the thread needed for the individual task, with And repair coefficient described in utilizing and the maximum query rate per second of the target cluster is adjusted.
In the present embodiment, target cluster limits dividing for itself according to the maximum query rate per second that is allowed of cluster is relied on With number of passes, that is, realize that itself is limited concurrent request quantity, play a part of protection and rely on cluster, and in performance objective During request, by monitoring the change of response time, to understand the situation of change for the process performance for relying on cluster, work as appearance When process performance is reduced or is deteriorated, saved in time using the current response time monitored, Dependency Set can be reduced The probability for phenomena such as group occurs shaking or collapsed, reduce the impact to caused by relying on cluster of target cluster.
One of ordinary skill in the art will appreciate that:Realizing all or part of step of above-mentioned each method embodiment can lead to The related hardware of programmed instruction is crossed to complete.Foregoing program can be stored in a computer read/write memory medium.The journey Sequence upon execution, execution the step of including above-mentioned each method embodiment;And foregoing storage medium includes:ROM, RAM, magnetic disc or Person's CD etc. is various can be with the medium of store program codes.
Finally it should be noted that:Various embodiments above is merely illustrative of the technical solution of the present invention, rather than its limitations;To the greatest extent The present invention is described in detail with reference to foregoing embodiments for pipe, it will be understood by those within the art that:Its according to The technical scheme described in foregoing embodiments can so be modified, either which part or all technical characteristic are entered Row equivalent substitution;And these modifications or replacement, the essence of appropriate technical solution is departed from various embodiments of the present invention technology The scope of scheme.

Claims (26)

  1. A kind of 1. thread distribution method, it is characterised in that including:
    Obtain the maximum query rate per second for relying on cluster and allowing that target cluster is relied on;
    When distributing thread to pending destination request, when obtaining the response between the target cluster and the dependence cluster Between;
    Obtain the current thread number that the target cluster is used;
    Based on maximum query rate per second, the response time and the current thread number, dividing for target cluster is obtained With Thread Count;
    Obtain the required Thread Count of the destination request;
    Judge Thread Count needed for the destination request can distribute Thread Count described in whether being less than or equal to;
    If Thread Count needed for described can distribute Thread Count described in being less than or equal to, corresponding line is distributed for the destination request Journey.
  2. 2. according to the method for claim 1, it is characterised in that based on maximum query rate per second, the response time And the current thread number, the specific formula for distributing Thread Count for obtaining the target cluster are:
    N=(M-Qt*Ct)/Qt;
    Wherein, Thread Count can be distributed described in N expressions;M represents the maximum query rate per second;Ct represents current thread number;Qt tables Show single thread query rate per second, Qt=1/RT, RT represent the response time.
  3. 3. according to the method for claim 1, it is characterised in that it is described obtain the target cluster and the dependence cluster it Between response time, including:
    Obtain the historical responses time in preset duration;
    The response time is obtained based on the historical responses time.
  4. 4. according to the method for claim 1, it is characterised in that it is described obtain the target cluster and the dependence cluster it Between response time, including:
    Start the dedicated thread for measuring the response time in real time;
    Measured in real time by the dedicated thread, to obtain the response time.
  5. 5. according to the method for claim 3, it is characterised in that described that the response is obtained based on the historical responses time Time, including:
    The exception response time in the historical responses time is rejected, to obtain the remaining historical responses time;
    Calculate the arithmetic mean of instantaneous value of the remaining historical responses time;
    Using the arithmetic mean of instantaneous value as the response time.
  6. 6. according to the method for claim 1, it is characterised in that the required Thread Count for obtaining the destination request, bag Include:
    Obtain and disassemble task amount corresponding to the destination request;
    Disassemble whether task amount exceeds default maximum task amount described in judgement;
    If it is judged that exceed the maximum task amount to disassemble task amount, then using the maximum task amount as the target The goal task amount of request;
    Thread Count and the goal task amount according to needed for default individual task, calculate the required thread of the destination request Number.
  7. 7. according to the method for claim 6, it is characterised in that also include:
    If it is judged that to disassemble task amount without departing from the maximum task amount, then the thread according to needed for the individual task Number and the required Thread Count disassembled task amount, calculate the destination request.
  8. 8. according to the method for claim 1, it is characterised in that if Thread Count can less than or equal to described in needed for described Thread Count is distributed, then distributes corresponding thread for the destination request, including:
    When judging that the required Thread Count can distribute Thread Count less than or equal to described in, obtain and handle needed for the destination request Processing time;
    By the processing time compared with default time threshold;
    If the processing time is less than the time threshold, corresponding thread is distributed for the destination request.
  9. 9. according to the method for claim 8, it is characterised in that also include:
    If the processing time is more than or equal to the time threshold, the destination request is placed into waiting list and carried out It is lined up, waits thread distribution next time.
  10. 10. according to the method for claim 9, it is characterised in that also include:
    When the destination request waits in line next thread distribution, when meeting that default priority sets condition, by described in The priority of destination request is arranged to highest;
    When it is described distribute Thread Count be more than or equal to it is described needed for Thread Count when, directly be the destination request distribution corresponding to line Journey.
  11. 11. according to the method for claim 8, it is characterised in that judging that it is described that the required Thread Count is less than or equal to When can distribute Thread Count, the processing time handled needed for the destination request is obtained, including:
    Single thread query rate per second is calculated according to the response time;
    Obtain single thread query rate per second and the product for distributing Thread Count;
    Obtain the ratio of data volume corresponding to the destination request and the product;
    Using the ratio as the processing time.
  12. 12. according to the method for claim 1, it is characterised in that the dependence cluster that the acquisition target cluster is relied on is permitted Perhaps after maximum query rate per second, in addition to:
    The maximum query rate per second itself allowed of the target cluster is arranged to the maximum inquiry per second of the dependence cluster Rate.
  13. 13. according to the method for claim 12, it is characterised in that also include:
    During the destination request is performed, the current response time is monitored in real time;
    If the current response time is more than the response time in duration time interval, using being supervised in the time interval The current response time surveyed, calculate a revised response time;
    Obtain the response time and the revised response time does ratio, and using the ratio as correction factor;
    The thread needed for the individual task is adjusted using the correction factor;
    The maximum query rate per second of the target cluster is adjusted using the correction factor.
  14. A kind of 14. thread distributor, it is characterised in that including:
    Query rate acquisition module, the maximum query rate per second for relying on cluster and allowing relied on for obtaining target cluster;
    Response time acquisition module, for when distributing thread to pending destination request, obtaining the target cluster and institute State the response time between dependence cluster;Current thread acquisition module, obtain the current thread that the target cluster is used Number;
    Thread acquisition module is distributed, for based on maximum query rate per second, the response time and the current thread Number, obtain target cluster distributes Thread Count;
    Required thread acquisition module, for obtaining the required Thread Count of the destination request;
    Judge module, for judging Thread Count needed for the destination request can distribute Thread Count described in whether being less than or equal to;
    Distribute module, for judging that the required Thread Count can distribute Thread Count described in being less than or equal in the judge module When, then distribute corresponding thread for the destination request.
  15. 15. device according to claim 14, it is characterised in that it is described distribution thread acquisition module, specifically for based on Equation below can distribute Thread Count described in obtaining;
    N=(M-Qt*Ct)/Qt;
    Wherein, Thread Count can be distributed described in N expressions;M represents the maximum query rate per second;Ct represents current thread number;Qt tables Show single thread query rate per second, Qt=1/RT, RT represent the response time.
  16. 16. device according to claim 14, it is characterised in that the response time acquisition module, specifically for obtaining The historical responses time in preset duration, the response time is obtained based on the historical responses time.
  17. 17. device according to claim 14, it is characterised in that the response time acquisition module, specifically for starting For measuring the dedicated thread of response time in real time, measured in real time by the dedicated thread, to obtain the response time.
  18. 18. device according to claim 16, it is characterised in that the response time acquisition module, specifically for rejecting The exception response time in the historical responses time, to obtain the remaining historical responses time, calculate the remaining history The arithmetic mean of instantaneous value of response time, and using the arithmetic mean of instantaneous value as the response time.
  19. 19. device according to claim 14, it is characterised in that thread acquisition module needed for described, including:
    TU task unit is disassembled, task amount is disassembled corresponding to the destination request for obtaining;
    Judging unit, for judging described to disassemble whether task amount exceeds default maximum task amount;
    Setting unit, for when the judged result of the judging unit exceeds the maximum task amount to disassemble task amount, then Goal task amount using the maximum task amount as the destination request;
    Computing unit, for the Thread Count according to needed for default individual task and the goal task amount, calculate the target The required Thread Count of request.
  20. 20. device according to claim 19, it is characterised in that the computing unit, be additionally operable in the judging unit Judged result for disassemble task amount without departing from the maximum task amount when, then the Thread Count according to needed for the individual task and It is described to disassemble task amount, calculate the required Thread Count of the destination request.
  21. 21. device according to claim 14, it is characterised in that also include:
    Processing time acquisition module, for judging that the required Thread Count can distribute described in being less than or equal in the judge module During Thread Count, the processing time handled needed for the destination request is obtained;
    Comparison module, for by the processing time compared with default time threshold;
    The distribute module, if being additionally operable to the processing time is less than the time threshold, distributed for the destination request Corresponding thread.
  22. 22. device according to claim 21, it is characterised in that also include:
    Queue module, for when the processing time being more than or equal to the time threshold, being then placed into the destination request Ranked in waiting list, wait thread distribution next time.
  23. 23. device according to claim 22, it is characterised in that also include:
    Priority setup module, it is default preferential when meeting for when the destination request waits in line the distribution of next thread When level sets condition, the priority of the destination request is arranged to highest;
    The distribute module, be additionally operable to when it is described distribute Thread Count be more than or equal to it is described needed for Thread Count when, be directly described Thread corresponding to destination request distribution.
  24. 24. device according to claim 21, it is characterised in that the processing time acquisition module, specifically for basis The response time calculates single thread query rate per second, obtains single thread query rate per second and distributes Thread Count with described Product;The ratio of data volume corresponding to the destination request and the product is obtained, using the ratio as during the processing Between.
  25. 25. device according to claim 14, it is characterised in that also include:
    Setup module, the maximum per second of cluster permission is relied on for what query rate acquisition module acquisition target cluster was relied on After query rate, the maximum that the maximum query rate per second itself allowed of the target cluster is arranged to the dependence cluster is every Second query rate.
  26. 26. device according to claim 25, it is characterised in that also include:
    Real-time monitoring modular, for during the destination request is performed, monitoring the current response time in real time;
    Response time correcting module, if being more than the response time in duration time interval for the current response time When, using the current response time monitored in the time interval, calculate a revised response time;
    Correction factor acquisition module, ratio is done for obtaining the response time and the revised response time, and by institute Ratio is stated as correction factor;
    Adjusting module, the thread needed for the individual task is adjusted for repairing coefficient described in utilization, and described in utilization Correction factor is adjusted to the maximum query rate per second of the target cluster.
CN201610342244.7A 2016-05-20 2016-05-20 Thread allocation method and device Active CN107402810B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610342244.7A CN107402810B (en) 2016-05-20 2016-05-20 Thread allocation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610342244.7A CN107402810B (en) 2016-05-20 2016-05-20 Thread allocation method and device

Publications (2)

Publication Number Publication Date
CN107402810A true CN107402810A (en) 2017-11-28
CN107402810B CN107402810B (en) 2020-07-14

Family

ID=60389500

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610342244.7A Active CN107402810B (en) 2016-05-20 2016-05-20 Thread allocation method and device

Country Status (1)

Country Link
CN (1) CN107402810B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108924213A (en) * 2018-06-27 2018-11-30 北京金山安全软件有限公司 QPS control method and device for server and electronic equipment
CN109284229A (en) * 2018-10-17 2019-01-29 武汉斗鱼网络科技有限公司 A kind of dynamic adjusting method and relevant device based on QPS
CN109840142A (en) * 2018-12-15 2019-06-04 平安科技(深圳)有限公司 Thread control method, device, electronic equipment and storage medium based on cloud monitoring
CN110058940A (en) * 2019-03-08 2019-07-26 苏宁易购集团股份有限公司 Data processing method and device under a kind of multi-thread environment
CN110069340A (en) * 2019-04-01 2019-07-30 北京百度网讯科技有限公司 Thread Count appraisal procedure and device
CN110278160A (en) * 2018-03-15 2019-09-24 阿里巴巴集团控股有限公司 Method of rate control, device and electronic equipment
CN110413209A (en) * 2018-04-28 2019-11-05 伊姆西Ip控股有限责任公司 The method and apparatus for managing storage system
CN110458468A (en) * 2019-08-16 2019-11-15 北京百度网讯科技有限公司 A task processing method, device, electronic device and storage medium
CN110609855A (en) * 2018-05-29 2019-12-24 北京三快在线科技有限公司 Query processing and query rate threshold determination method and distributed query system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043675A (en) * 2010-12-06 2011-05-04 北京华证普惠信息股份有限公司 Thread pool management method based on task quantity of task processing request
CN103729361A (en) * 2012-10-12 2014-04-16 百度在线网络技术(北京)有限公司 Method and device for testing performance of database
CN103905553A (en) * 2014-04-04 2014-07-02 江苏林洋电子股份有限公司 Cloud architecture of energy efficiency management system and operation method thereof
CN104461740A (en) * 2014-12-12 2015-03-25 国家电网公司 Cross-domain colony computing resource gathering and distributing method
CN105335231A (en) * 2014-08-15 2016-02-17 阿里巴巴集团控股有限公司 Dynamic distribution method and device for server threads
US20160119246A1 (en) * 2014-10-28 2016-04-28 Salesforce.Com, Inc. Facilitating dynamic hierarchical management of queue resources in an on-demand services environment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043675A (en) * 2010-12-06 2011-05-04 北京华证普惠信息股份有限公司 Thread pool management method based on task quantity of task processing request
CN103729361A (en) * 2012-10-12 2014-04-16 百度在线网络技术(北京)有限公司 Method and device for testing performance of database
CN103905553A (en) * 2014-04-04 2014-07-02 江苏林洋电子股份有限公司 Cloud architecture of energy efficiency management system and operation method thereof
CN105335231A (en) * 2014-08-15 2016-02-17 阿里巴巴集团控股有限公司 Dynamic distribution method and device for server threads
US20160119246A1 (en) * 2014-10-28 2016-04-28 Salesforce.Com, Inc. Facilitating dynamic hierarchical management of queue resources in an on-demand services environment
CN104461740A (en) * 2014-12-12 2015-03-25 国家电网公司 Cross-domain colony computing resource gathering and distributing method

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110278160A (en) * 2018-03-15 2019-09-24 阿里巴巴集团控股有限公司 Method of rate control, device and electronic equipment
CN110413209A (en) * 2018-04-28 2019-11-05 伊姆西Ip控股有限责任公司 The method and apparatus for managing storage system
CN110609855B (en) * 2018-05-29 2021-06-04 北京三快在线科技有限公司 Query processing and query rate threshold determination method and distributed query system
CN110609855A (en) * 2018-05-29 2019-12-24 北京三快在线科技有限公司 Query processing and query rate threshold determination method and distributed query system
CN108924213A (en) * 2018-06-27 2018-11-30 北京金山安全软件有限公司 QPS control method and device for server and electronic equipment
CN108924213B (en) * 2018-06-27 2021-06-18 北京金山安全软件有限公司 QPS control method and device for server and electronic equipment
CN109284229A (en) * 2018-10-17 2019-01-29 武汉斗鱼网络科技有限公司 A kind of dynamic adjusting method and relevant device based on QPS
CN109284229B (en) * 2018-10-17 2022-02-22 武汉斗鱼网络科技有限公司 Dynamic adjustment method based on QPS and related equipment
CN109840142A (en) * 2018-12-15 2019-06-04 平安科技(深圳)有限公司 Thread control method, device, electronic equipment and storage medium based on cloud monitoring
CN109840142B (en) * 2018-12-15 2024-03-15 平安科技(深圳)有限公司 Thread control method and device based on cloud monitoring, electronic equipment and storage medium
CN110058940A (en) * 2019-03-08 2019-07-26 苏宁易购集团股份有限公司 Data processing method and device under a kind of multi-thread environment
CN110058940B (en) * 2019-03-08 2022-11-22 苏宁易购集团股份有限公司 Data processing method and device in multi-thread environment
CN110069340A (en) * 2019-04-01 2019-07-30 北京百度网讯科技有限公司 Thread Count appraisal procedure and device
CN110069340B (en) * 2019-04-01 2022-09-16 北京百度网讯科技有限公司 Thread number evaluation method and device
CN110458468A (en) * 2019-08-16 2019-11-15 北京百度网讯科技有限公司 A task processing method, device, electronic device and storage medium

Also Published As

Publication number Publication date
CN107402810B (en) 2020-07-14

Similar Documents

Publication Publication Date Title
CN107402810A (en) Thread distribution method and device
CN110555785B (en) A monthly plan security and stability check method and system
CN109039833B (en) Method and device for monitoring bandwidth status
CN108197909B (en) Project progress supervision control system
CN104978335B (en) Data access control method and device
US9858106B2 (en) Virtual machine capacity planning
US10671440B2 (en) Resource usage prediction for cluster provisioning
CN103778071A (en) Cache space distribution method and device
CN105872061B (en) A kind of server set group managing means, apparatus and system
CN104484134B (en) The disk distribution method and device of distributed storage
CN108108490B (en) Hive table scan method, apparatus, computer equipment and storage medium
CN104477776B (en) The crane remote hierarchical monitoring system of based role
CN106202280A (en) A kind of information processing method and server
CN107943522A (en) A kind of project delay rate computation processing method and device
CN105955101A (en) Control method, scheduling processor and controller
CN107833051A (en) A kind of data statistical approach and system
CN109597800B (en) A log distribution method and device
CN112817719A (en) Method, device and equipment for adjusting parameters of thread pool and readable storage medium
CN111415261B (en) Control method, system and device for dynamically updating flow control threshold of bank system
CN104518913B (en) A kind of cloud service method for detecting abnormality based on artificial immunity
US20170144066A1 (en) Distribution system and method
CN109624108A (en) A kind of method and apparatus for simulating the silicon chip slicer production time
CN112583912A (en) VPN automatic connection method, device, equipment and storage medium
CN104378239A (en) Rapid reliability index statistical system and method based on cluster frame
CN112804300B (en) Flow access control method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20201014

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20201014

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: Alibaba Group Holding Ltd.

TR01 Transfer of patent right