CN104216765B - A kind of method and system of multi-thread concurrent processing business - Google Patents

A kind of method and system of multi-thread concurrent processing business Download PDF

Info

Publication number
CN104216765B
CN104216765B CN201410406151.7A CN201410406151A CN104216765B CN 104216765 B CN104216765 B CN 104216765B CN 201410406151 A CN201410406151 A CN 201410406151A CN 104216765 B CN104216765 B CN 104216765B
Authority
CN
China
Prior art keywords
thread
idle
business
auxiliary
worker
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.)
Expired - Fee Related
Application number
CN201410406151.7A
Other languages
Chinese (zh)
Other versions
CN104216765A (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.)
Neusoft Corp
Original Assignee
Neusoft Corp
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 Neusoft Corp filed Critical Neusoft Corp
Priority to CN201410406151.7A priority Critical patent/CN104216765B/en
Publication of CN104216765A publication Critical patent/CN104216765A/en
Application granted granted Critical
Publication of CN104216765B publication Critical patent/CN104216765B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The embodiment of the invention discloses a kind of method and system of multi-thread concurrent processing business, methods described includes:Receive any pending business;It is the idle thread of pending traffic assignments one, and the idle thread is defined as main thread when there is idle thread;The main thread is the pending business application idle thread;According to the disposal ability of current system, it is the pending traffic assignments idle thread, the idle thread is defined as worker thread;The main thread is respectively each worker thread distribution business module, and the business module is obtained by the pending business cutting;Each worker thread concurrently performs allocated business module.The present invention can control the maximum concurrency of thread according to the disposal ability of current system so that the processing procedure of the pending business will not both cause the waste of system resource, will not also cause system pressure excessive, the final treatment effeciency for improving business.

Description

A kind of method and system of multi-thread concurrent processing business
Technical field
The present invention relates to technical field of data processing, and in particular to a kind of method of multi-thread concurrent processing business and is System.
Background technology
Multi-thread concurrent processing business, i.e., split into some business modules by pending business in advance, and respectively by each industry Business block is distributed to different threads and handled simultaneously, is finally completed the processing procedure of whole business.With the side of single thread processing business Formula is compared, and multi-thread concurrent processing business can improve the efficiency of business processing, reduces the time of business processing.
At present, in the mode of traditional multi-thread concurrent processing business, it usually needs the line that artificial control is concurrently performed Number of passes amount.
Because there is certain subjective factor in the mode of manual control number of threads, so, the concurrently execution artificially determined The quantity of thread may not be to handle the ideal quantity required for the pending business, that is to say, that concurrently perform artificial determine The thread of quantity may cause the waste of system resource, or cause the generation for situations such as system pressure is excessive.In this feelings Under condition, the efficiency of multi-thread concurrent processing business is relatively low.
The content of the invention
, can be according to the processing of current system the invention provides a kind of method and system of multi-thread concurrent processing business The concurrent quantity of capability control thread, shortens the time of business processing, improves business processing and obtains efficiency.
The invention provides a kind of method of multi-thread concurrent processing business, methods described includes:
Receive any pending business;
It is the idle thread of pending traffic assignments one, and the idle thread is determined when there is idle thread For main thread;
The main thread is the pending business application idle thread;
It is the pending traffic assignments idle thread according to the disposal ability of current system, the idle thread is true It is set to worker thread;
The main thread is respectively each worker thread distribution business module, and the business module is by the pending business cutting Obtain;
Each worker thread concurrently performs allocated business module.
Preferably, the disposal ability according to current system, is the pending traffic assignments idle thread, including:
Judge whether currently allocated number of threads is not more than the CPU core number of system;
If currently allocated number of threads is not more than the CPU core number of system, network usage, system CPU are judged Utilization rate and or system IO utilization rates whether be less than predetermined threshold value;
If network usage, system CPU utilization rate and or system IO utilization rates be less than predetermined threshold value, treated to be described Processing business distributes idle thread.
Preferably, the main thread is respectively that each worker thread is distributed after business module, in addition to:
When there is unassigned business module, the main thread performs any unassigned business module;
Each described worker thread is concurrently performed after allocated business module, in addition to:
When any operative thread completes allocated business module, the worker thread continues executing with any unassigned Business module.
Preferably, methods described also includes:
When in the absence of unassigned business module, the worker thread in idle condition sends idle to the main thread Auxiliary request;
The main thread obtains an active line for meeting default auxiliary criteria after the idle auxiliary request is received Journey;
The main thread sends idle auxiliary to the worker thread in idle condition and responded, and the idle auxiliary is rung The worker thread for meeting default auxiliary criteria should be included;
The worker thread in idle condition is received after the idle auxiliary response, meets default auxiliary described in auxiliary The worker thread of standard is helped to complete to perform business module.
Preferably, the main thread obtains one and meets default auxiliary criteria after the idle auxiliary request is received Worker thread, including:
The main thread sends nonproductive poll request after the idle auxiliary request is received to each worker thread;
According to the implementation progress of allocated business, each worker thread judges whether itself meets default auxiliary criteria;
The main thread obtains a worker thread for meeting default auxiliary criteria.
Preferably, the worker thread in idle condition is received after the idle auxiliary response, aids in the mark The worker thread for having accessory ID completes to perform business module, including:
The worker thread in idle condition is received after the idle auxiliary response, meets default auxiliary described in acquisition Help the later half business for the business module that the worker thread of standard is carrying out;
The worker thread in idle condition performs the later half business of the business module.
Present invention also offers a kind of system of multi-thread concurrent processing business, the system includes:
Receiving unit, for receiving any pending business;
First allocation unit, for when there is idle thread, being the idle thread of pending traffic assignments one, and will The idle thread is defined as main thread;
Application unit, is the pending business application idle thread for the main thread;
Second allocation unit, is the pending traffic assignments idle thread for the disposal ability according to current system, The idle thread is defined as worker thread;
3rd allocation unit, for the main thread be respectively each worker thread distribution business module, the business module by The pending business cutting is obtained;
First execution unit, allocated business module is concurrently performed for each worker thread.
Preferably, second allocation unit includes:
Whether the first judgment sub-unit, the number of threads for judging currently to be allocated is not more than the CPU core number of system;
Second judgment sub-unit, for when the result of first judgment sub-unit is to be, judging network usage, being Unite CPU usage and or system IO utilization rates whether be less than predetermined threshold value;
First distribution subelement, for being the pending business when the result of second judgment sub-unit is to be Distribute idle thread;
Determination sub-module, for the idle thread to be defined as into worker thread.
Preferably, the system also includes the second execution unit and the 3rd execution unit,
Second execution unit, for when there is unassigned business module, the main thread perform it is any not by The business module of distribution;
3rd execution unit, for when any operative thread completes allocated business module, the worker thread Continue executing with any unassigned business module.
Preferably, the system also includes:
First transmitting element, for when in the absence of unassigned business module, the worker thread in idle condition to The main thread sends idle auxiliary request;
First acquisition unit, for the main thread after the idle auxiliary request is received, obtains one and meets default Auxiliary criteria worker thread;
Second transmitting element, sends idle auxiliary to the worker thread in idle condition for the main thread and rings Should, the idle auxiliary response includes the worker thread for meeting default auxiliary criteria;
Auxiliary unit, receives after the idle auxiliary response for the worker thread in idle condition, aids in institute State the worker thread completion execution business module for meeting default auxiliary criteria.
It is institute according to the disposal ability of current system when there is idle thread present invention firstly receives pending business Pending traffic assignments idle thread is stated, finally, each allocated idle thread concurrently performs the pending business cutting Each obtained business module.Compared with prior art, the present invention can control thread maximum according to the disposal ability of current system Concurrency so that the processing procedure of the pending business will not both cause the waste of system resource, will not also cause system pressure Power is excessive, the final treatment effeciency for improving business.
Brief description of the drawings
In order to illustrate more clearly of the technical scheme in the embodiment of the present application, make required in being described below to embodiment Accompanying drawing is briefly described, it should be apparent that, drawings in the following description are only some embodiments of the present application, for For those of ordinary skill in the art, without having to pay creative labor, it can also be obtained according to these accompanying drawings His accompanying drawing.
Fig. 1 is the method flow diagram for the multi-thread concurrent processing business that the embodiment of the present invention one is provided;
Fig. 2 is the method flow diagram for the multi-thread concurrent processing business that the embodiment of the present invention two is provided;
Fig. 3 is the system structure diagram for the multi-thread concurrent processing business that the embodiment of the present invention three is provided;
Fig. 4 is the second allocation unit structural representation that the embodiment of the present invention three is provided;
Fig. 5 is the system structure diagram for the multi-thread concurrent processing business that the embodiment of the present invention three is provided;
Fig. 6 is the service process performance contrast effect figure for three kinds of systems that the embodiment of the present invention three is provided.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present application, the technical scheme in the embodiment of the present application is carried out clear, complete Site preparation is described, it is clear that described embodiment is only some embodiments of the present application, rather than whole embodiments.It is based on Embodiment in the application, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made Embodiment, belongs to the scope of the application protection.
Embodiment one
With reference to Fig. 1, Fig. 1 is the method flow diagram of multi-thread concurrent processing business provided in an embodiment of the present invention, the side Method includes:
S101:Receive any pending business.
S102:It is the idle thread of pending traffic assignments one when there is idle thread, and by the idle thread It is defined as main thread.
In the present embodiment, when any one waiting task is triggered, system first determines whether current with the presence or absence of the free time Thread.When there is idle thread, system is determined whether for the pending traffic assignments according to the disposal ability of current system Idle thread.
S103:The main thread is the pending business application idle thread.
S104:It is the pending traffic assignments idle thread, by the idle line according to the disposal ability of current system Journey is defined as worker thread.
Specifically, when there is idle thread, system is described pending one idle thread of traffic assignments first, and will The idle thread is defined as main thread.Secondly, system is after it is determined that handle the main thread of the pending business, the main line Journey is responsible for the pending business application idle thread.When there is idle thread in system, once receive from main thread Idle thread application request, system, then according to the disposal ability of current system, is that the pending business continues to distribute empty Idle thread, and the idle thread of this sub-distribution is defined as worker thread, the worker thread is by the main line process control.
In practical operation, in order to reasonably control the quantity that thread is concurrent so that concurrent both do not resulted in of multithreading be The waste for resource of uniting, will not also cause system pressure excessive.The present embodiment for the pending traffic assignments idle thread it Before, first determine whether whether the number of threads being currently allocated is not more than the CPU core number of system.If the Thread Count being currently allocated Amount be not more than system CPU core number, then judge network usage, system CPU utilization rate and or system IO utilization rates whether be less than Predetermined threshold value.If network usage, system CPU utilization rate and or system IO utilization rates be less than predetermined threshold value, treated to be described Processing business distributes idle thread.
If currently allocated number of threads is more than the CPU core number of system, illustrate that the pressure of now system is excessive.In order to The pressure of increase system is not continued, in such cases, the present embodiment can not be the pending traffic assignments idle thread.Tool Body, the pending business can be added queue management device by system, when system can distribute idle thread for it, be continued Handle the pending business.Likewise, the present embodiment can also be respectively network usage, system CPU utilization rate and or be System IO utilization rates pre-set threshold value, when the above-mentioned performance of current system exceedes predetermined threshold value, illustrate the pressure of now system It is excessive, be not suitable for continuing as the pending traffic assignments idle thread.
In the present embodiment, by prolonged test, find under data analysis application scene, system can be supported most The CPU core number of big thread number of concurrent no more than current computer systems, once more than CPU core number, the energy of system processing business Power will be begun to decline.With the growth of thread number of concurrent, the ability of system processing business may also be subjected to network usage, be The limitation for the IO utilization rates and CPU usage etc. of uniting, if the utilization rate of this above-mentioned three indexs is too high, can equally turn into system The ability of processing business declines.
S105:The main thread is respectively each worker thread distribution business module, and the business module is by the pending industry Business cutting is obtained.
S106:Each worker thread concurrently performs allocated business module.
In the present embodiment, after the pending business is allocated idle thread, the idle thread can be performed concurrently Each business module obtained by the pending business cutting, is finally completed the pending business.
Specifically, the main thread in the allocated idle thread of the pending business is respectively the distribution of each worker thread Business module, the business module is obtained by the pending business cutting.Each worker thread is allocated after business module, is concurrently held The allocated business module of row.
In addition, when any one worker thread completes allocated business module, the worker thread can be continued executing with Any one unassigned business module, makes full use of the resource of system.
It is worth noting that, the main thread in the present embodiment can not only control management work thread, there can also be work Make all abilities of thread.Specifically, main thread complete for worker thread distribution business module after, still suffered from system not by During the business module of distribution, the main thread can start to perform any one unassigned business module, to make full use of sky Idle thread, improves traffic handing capacity.
In the present embodiment, when there is idle thread, system is pending business point according to current system processing power With idle thread, allocated idle thread concurrently performs each business module.Compared with prior art, the present embodiment is for business When distributing thread, it is contemplated that the disposal ability of current system, the maximum concurrency of thread is effectively controlled.So that the processing of business Process will not both cause the waste of system resource, will not also cause system pressure excessive, the final treatment effeciency for improving business.
Embodiment two
With reference to Fig. 2, Fig. 2 is the method flow diagram of multi-thread concurrent processing business provided in an embodiment of the present invention, the side Method includes:
S201:Receive any pending business.
S202:It is the idle thread of pending traffic assignments one when there is idle thread, and by the idle thread It is defined as main thread.
In the present embodiment, system is received after any one pending business, it is first determined whether there is idle thread.When depositing It is main thread of described one idle thread of pending traffic assignments as the pending business in idle thread.
When in the absence of idle thread, the pending business is added into queue management device.Specifically, the queue management Whether when device receives the pending business, it is high-priority service that the business is recognized first, if it is, determining the queue With the business of the pending business same priority in manager, then the pending business is jumped the queue to same priority business End.If the pending business is not high-priority service, the pending business is directly come to the most end of queue End.When system needs to perform the business in queue management device, the direct start to process foremost from queue.
S203:The main thread is the pending business application idle thread.
S204:It is the pending traffic assignments idle thread according to the disposal ability of current system.
S205:The idle thread is defined as worker thread.
In the present embodiment, it is determined that after the main thread of the pending business, the main thread is responsible for empty to system application Idle thread.System is institute according to the disposal ability of current system after the idle thread application for receiving the main thread is asked State pending traffic assignments idle thread, and using the idle thread of distribution as the pending business worker thread.
The present embodiment controls the maximum concurrency of thread according to the disposal ability of current system so that the processing procedure of business Both the waste of system resource will not be caused, will not also cause system pressure excessive, the final treatment effeciency for improving business.
S206:The main thread is respectively each worker thread distribution business module, and the business module is by the pending industry Business cutting is obtained.
S207:Each worker thread concurrently performs allocated business module.
In practical application, the main thread is also responsible for each worker thread distribution business module, so as to each worker thread Allocated business module can concurrently be performed.Wherein, the business module is obtained by the pending business cutting.
Specifically, the size of each business module can by the pending business data total amount and the CPU of current system The ratio calculation of check figure is obtained, while each business module includes at least 100,000 datas.
S208:When there is the worker thread in idle condition, unassigned business module is judged whether.
In the present embodiment, when there is the worker thread in idle condition, system is needed the work of the idle condition Dispensed as thread.Specifically, system first determines whether currently to whether there is the unassigned business of the pending business Block.
Wherein, the worker thread in idle condition in the present embodiment can be the work for completing allocated business module Thread or the worker thread for not distributed any business module by main thread.
S209:When there is unassigned business module, the worker thread in idle condition continues executing with any Unassigned business module.
If there is currently the unassigned business module of the pending business, the work in idle condition Thread can start to perform any one unassigned business module.
S210:When in the absence of unassigned business module, the worker thread in idle condition is to the main line Journey sends idle auxiliary request.
If there is currently no the unassigned business module of the pending business, the work in idle condition Make thread and send idle auxiliary request to the main thread, the idle auxiliary request is used for auxiliary to main thread request needs The worker thread helped.
S211:The main thread obtains one and meets default auxiliary criteria after the idle auxiliary request is received Worker thread.
In the present embodiment, after the main thread receives the idle auxiliary request, acquisition one, which meets, to be pre-set Auxiliary criteria worker thread.
Specifically, the main thread is after the idle auxiliary request is received, send auxiliary to each worker thread first Inquiry request is helped, wherein, the nonproductive poll asks to meet the worker thread of default auxiliary criteria for inquiring about.Secondly, root According to the implementation progress of allocated business, each worker thread judges whether itself meets default auxiliary criteria.The main thread Obtain a worker thread for meeting default auxiliary criteria.
In practical application, judge whether worker thread needs an essential condition of auxiliary to be exactly the worker thread processing The remaining processing time of allocated business, the present embodiment can be remained according to the data structure contained by each worker thread Remaining processing time and the calculating of remaining data volume.Finally, whether the worker thread is judged according to result of calculation is conditional Need auxiliary.
Held specifically, data structure contained by worker thread can include the data volume of current business, current business The time that traveling degree and current business have been consumed.It is remaining that worker thread calculates current business according to each property value of data structure Data volume, specific calculation the present embodiment is not limited.It is more than default threshold value in the remaining data volume of current business When, illustrate that the worker thread meets default auxiliary criteria.In addition, the present embodiment can also according to data structure each category Property value calculate current business remaining processing time, i.e., first according to the data volume of current business, the implementation progress of current business and The time for the Time Calculation processing wall scroll data consumption that current business has been consumed, secondly, wall scroll is handled according to the worker thread The time of data consumption and the remaining data volume of current business calculate current business remaining processing time.Specific calculation sheet Embodiment is not limited.When current business remaining processing time being more than default time threshold, illustrate the worker thread symbol Close default auxiliary criteria.The present inventor has found that single thread handles 10000 datas most by prolonged test For a long time not over 2s, so, default time threshold can also be 2s in the present embodiment.Wherein, 2s is by testing choosing The optimum value taken, is not intended to limit the protection domain of the application, but default time threshold it is excessive it is too small all can be to the property of system Can slightly it influence.
In practical application, default auxiliary criteria can be determined according to actual conditions.
S212:The main thread sends idle auxiliary to the worker thread in idle condition and responded, the free time Auxiliary response includes the worker thread for meeting default auxiliary criteria.
In the present embodiment, after the main thread, which obtains one, meets the worker thread of default auxiliary criteria, to described Worker thread in idle condition sends idle auxiliary response, to inform that it is auxiliary that the worker thread in idle condition needs The worker thread helped.Wherein, the idle auxiliary response includes the worker thread for meeting default auxiliary criteria.
S213:The worker thread in idle condition is received after the idle auxiliary response, meets pre- described in auxiliary If auxiliary criteria worker thread complete perform business module.
After the worker thread in idle condition receives the idle auxiliary response, the idle auxiliary is aided in ring The worker thread for meeting default auxiliary criteria in answering completes to perform business module.
Specifically, the worker thread in idle condition is received after the idle auxiliary response, obtain first described Meet the later half business for the business module that the worker thread of default auxiliary criteria is carrying out.Secondly, it is described in idle shape The worker thread of state performs the later half business of the business module, to aid in the worker thread for meeting default auxiliary criteria Complete the business module.
In the present embodiment, worker thread completes to perform after allocated business module, actively aids in other unfinished work Thread.Compared with prior art, the present embodiment makes full use of resource, shortens the time of business processing, improves business processing Efficiency.
, can be with when the main thread is known in the absence of the worker thread for meeting default auxiliary criteria in practical application The main thread is labeled as not receive idle thread state.That is, labeled as the main line for not receiving idle thread state Cheng Buzai needs idle thread, you can complete the pending business.
In this case, when there is the worker thread in idle condition, idle condition directly can be in by described Worker thread distribute to the main thread for being not labeled as not receiving idle thread state, it is not necessary to lose time to inquire and be not required to Apply for the main thread of idle thread, the time has been saved to a certain extent, improve the performance of system.
It is the pending business in the queue management device when main thread is marked as not receiving idle thread state The distribution worker thread for being in idle condition, now can be with the pending business in start to process queue management device.
In the present embodiment, the worker thread in idle condition is taken full advantage of, system resource is not wasted, to a certain extent Traffic handling time has been saved, the performance of system is improved.
Embodiment three
With reference to Fig. 3, Fig. 3 is the system structure diagram of multi-thread concurrent processing business provided in an embodiment of the present invention, institute The system of stating includes:
Receiving unit 301, for receiving any pending business.
First allocation unit 302, for when there is idle thread, being the idle thread of pending traffic assignments one, And the idle thread is defined as main thread.
Application unit 303, is the pending business application idle thread for the main thread.
Second allocation unit 304, is the pending traffic assignments idle line for the disposal ability according to current system Journey, worker thread is defined as by the idle thread.
3rd allocation unit 305, is respectively each worker thread distribution business module, the business module for the main thread Obtained by the pending business cutting.
First execution unit 306, allocated business module is concurrently performed for each worker thread.
With reference to Fig. 4, the structural representation for second allocation unit 304 that Fig. 4 provides for the present embodiment, specifically, institute Stating the second allocation unit 304 can include:
Whether the first judgment sub-unit 401, the number of threads for judging currently to be allocated is not more than the CPU core of system Number;
Second judgment sub-unit 403, for when the result of first judgment sub-unit is to be, judging Web vector graphic Rate, system CPU utilization rate and or system IO utilization rates whether be less than predetermined threshold value;
First distribution subelement 403, for being the pending industry when the result of second judgment sub-unit is to be Business distribution idle thread;
Determination sub-module 404, for the idle thread to be defined as into worker thread.
In addition, the system can also include the second execution unit and the 3rd execution unit,
Second execution unit, for when there is unassigned business module, the main thread perform it is any not by The business module of distribution;
3rd execution unit, for when any operative thread completes allocated business module, the worker thread Continue executing with any unassigned business module.
With reference to Fig. 5, Fig. 5 is the system structure diagram of multi-thread concurrent processing business provided in an embodiment of the present invention, institute Stating system not only includes the unit in Fig. 3, can also include:
First transmitting element 501, for when in the absence of unassigned business module, the worker thread in idle condition Idle auxiliary request is sent to the main thread;
First acquisition unit 502, for the main thread after the idle auxiliary request is received, obtains one and meets pre- If auxiliary criteria worker thread;
Second transmitting element 503, sends idle auxiliary for the main thread to the worker thread in idle condition Response is helped, the idle auxiliary response includes the worker thread for meeting default auxiliary criteria;
Auxiliary unit 504, is received after the idle auxiliary response, auxiliary for the worker thread in idle condition The worker thread for meeting default auxiliary criteria completes to perform business module.
The first acquisition unit 502 includes:
First transmission sub-unit 5021, for the main thread after the idle auxiliary request is received, to each work Make thread and send nonproductive poll request;
3rd judgment sub-unit 5022, for the implementation progress according to the business of being allocated, each worker thread judges itself Whether default auxiliary criteria is met;
First obtains subelement 5023, and a worker thread for meeting default auxiliary criteria is obtained for the main thread.
The auxiliary unit 504 includes:
Second obtains subelement 5041, and the idle auxiliary response is received for the worker thread in idle condition Afterwards, the later half business for the business module that the worker thread of default auxiliary criteria is carrying out is met described in obtaining;
3rd performs subelement 5042, and the latter of the business module is performed for the worker thread in idle condition Half business.
The system also includes:Indexing unit, meets default auxiliary criteria for knowing to be not present when the main thread Worker thread when, by the main thread labeled as not receiving idle thread state.
Second allocation unit, is not labeled as not receiving sky for the worker thread in idle condition to be distributed to The main thread of idle thread state.
The system also includes:Unit is added, for when in the absence of idle thread, the pending business to be added into team Column manager;
3rd allocation unit, for being the queue pipe when main thread is marked as not receiving idle thread state Manage the worker thread that idle condition is in described in the pending traffic assignments in device.
Under same hardware condition, system and the existing list of the multi-thread concurrent processing business that the present embodiment is provided Thread process system and multithreaded processing system have carried out the contrast test of performance, as a result as shown in fig. 6, Fig. 6 is three kinds of systems Service process performance contrast effect figure.Learnt according to the data of contrast test, when the quantity of business parallel processing is smaller, this The performance faster than multi-threaded system 0.4 for the system that embodiment is provided, 3.3 times faster than single-threaded system.With business parallel processing Quantity increase, the present embodiment performance change less, maintains the analysis ability of 130,000/second data or so, and many always Threaded systems and single-threaded system are begun to decline after experienced a performance high point, when business number increases to 64, this implementation 0.75 times faster than multi-threaded system, 0.4 times faster than single-threaded system of the performance of example.
To sum up, under same hardware condition, the embodiment of the present invention can more fully utilize computer resource, improve System process performance, shortens the processing time of single business, and the increase of the number of services with parallel processing, and system is kept Performance is stable.
For system embodiment, because it corresponds essentially to embodiment of the method, so related part is real referring to method Apply the part explanation of example.System embodiment described above is only schematical, wherein described be used as separating component The unit of explanation can be or may not be physically separate, and the part shown as unit can be or can also It is not physical location, you can with positioned at a place, or can also be distributed on multiple NEs.Can be according to reality Selection some or all of module therein is needed to realize the purpose of this embodiment scheme.Those of ordinary skill in the art are not In the case of paying creative work, you can to understand and implement.
It should be noted that herein, such as first and second or the like relational terms are used merely to a reality Body or operation make a distinction with another entity or operation, and not necessarily require or imply these entities or deposited between operating In any this actual relation or order.Moreover, term " comprising ", "comprising" or its any other variant are intended to Nonexcludability is included, so that process, method, article or equipment including a series of key elements not only will including those Element, but also other key elements including being not expressly set out, or also include being this process, method, article or equipment Intrinsic key element.In the absence of more restrictions, the key element limited by sentence "including a ...", it is not excluded that Also there is other identical element in process, method, article or equipment including the key element.
The method and system of the multi-thread concurrent processing business provided above the embodiment of the present invention has carried out detailed Jie Continue, specific case used herein is set forth to the principle and embodiment of the present invention, the explanation of above example is only It is the method and its core concept for being used to help understand the present invention;Simultaneously for those of ordinary skill in the art, according to this hair Bright thought, be will change in specific embodiments and applications, in summary, and this specification content should not be managed Solve as limitation of the present invention.

Claims (10)

1. a kind of method of multi-thread concurrent processing business, it is characterised in that methods described includes:
Receive any pending business;
Be the idle thread of pending traffic assignments one when there is idle thread, and by the idle thread determine based on Thread;
The main thread is the pending business application idle thread;
It is described according to the disposal ability of current system after the request of the idle thread application from the main thread is received Pending traffic assignments idle thread, is defined as worker thread, the worker thread is by the main thread by the idle thread Control;
The main thread is respectively each worker thread distribution business module, and the business module is obtained by the pending business cutting Arrive;
Each worker thread concurrently performs allocated business module.
2. according to the method described in claim 1, it is characterised in that the disposal ability according to current system, it is described treat Processing business distributes idle thread, including:
Judge whether currently allocated number of threads is not more than the CPU core number of system;
If currently allocated number of threads is not more than the CPU core number of system, judge that network usage, system CPU are used Rate and or system IO utilization rates whether be less than predetermined threshold value;
If network usage, system CPU utilization rate and or system IO utilization rates be less than predetermined threshold value, to be described pending Traffic assignments idle thread.
3. according to the method described in claim 1, it is characterised in that the main thread is respectively each worker thread distribution business After block, in addition to:
When there is unassigned business module, the main thread performs any unassigned business module;
Each described worker thread is concurrently performed after allocated business module, in addition to:
When any operative thread completes allocated business module, the worker thread continues executing with any unassigned business Block.
4. according to the method described in claim 1, it is characterised in that methods described also includes:
When in the absence of unassigned business module, the worker thread in idle condition sends idle auxiliary to the main thread Request;
The main thread obtains a worker thread for meeting default auxiliary criteria after the idle auxiliary request is received;
The main thread sends idle auxiliary to the worker thread in idle condition and responded, the idle auxiliary response bag Include the worker thread for meeting default auxiliary criteria;
The worker thread in idle condition is received after the idle auxiliary response, and default auxiliary mark is met described in auxiliary Accurate worker thread completes to perform business module.
5. method according to claim 4, it is characterised in that the main thread is receiving the idle auxiliary request Afterwards, a worker thread for meeting default auxiliary criteria is obtained, including:
The main thread sends nonproductive poll request after the idle auxiliary request is received to each worker thread;
According to the implementation progress of allocated business, each worker thread judges whether itself meets default auxiliary criteria;
The main thread obtains a worker thread for meeting default auxiliary criteria.
6. method according to claim 4, it is characterised in that the worker thread in idle condition receives the sky After spare time auxiliary response, the worker thread that default auxiliary criteria is met described in auxiliary completes to perform business module, including:
The worker thread in idle condition is received after the idle auxiliary response, and default auxiliary mark is met described in acquisition The later half business for the business module that accurate worker thread is carrying out;
The worker thread in idle condition performs the later half business of the business module.
7. a kind of system of multi-thread concurrent processing business, it is characterised in that the system includes:
Receiving unit, for receiving any pending business;
First allocation unit, for when there is idle thread, being the idle thread of pending traffic assignments one, and will be described Idle thread is defined as main thread;
Application unit, is the pending business application idle thread for the main thread;
Second allocation unit, for after the request of the idle thread application from the main thread is received, according to current system Disposal ability, be the pending traffic assignments idle thread, the idle thread be defined as worker thread, the work Thread is by the main line process control;
3rd allocation unit, is respectively each worker thread distribution business module for the main thread, the business module is by described Pending business cutting is obtained;
First execution unit, allocated business module is concurrently performed for each worker thread.
8. system according to claim 7, it is characterised in that second allocation unit includes:
Whether the first judgment sub-unit, the number of threads for judging currently to be allocated is not more than the CPU core number of system;
Second judgment sub-unit, for when the result of first judgment sub-unit is to be, judging network usage, system CPU usage and or system IO utilization rates whether be less than predetermined threshold value;
First distribution subelement, for being the pending traffic assignments when the result of second judgment sub-unit is to be Idle thread;
Determination sub-module, for the idle thread to be defined as into worker thread.
9. system according to claim 7, it is characterised in that the system also includes the second execution unit and the 3rd and performed Unit,
Second execution unit, for when there is unassigned business module, the main thread to perform any unassigned Business module;
3rd execution unit, for when any operative thread completes allocated business module, the worker thread to continue Perform any unassigned business module.
10. system according to claim 7, it is characterised in that the system also includes:
First transmitting element, for when in the absence of unassigned business module, the worker thread in idle condition is to described Main thread sends idle auxiliary request;
First acquisition unit, for the main thread after the idle auxiliary request is received, obtains one and meets default auxiliary Help the worker thread of standard;
Second transmitting element, sends idle auxiliary to the worker thread in idle condition for the main thread and responds, The idle auxiliary response includes the worker thread for meeting default auxiliary criteria;
Auxiliary unit, receives after the idle auxiliary response for the worker thread in idle condition, aids in the symbol The worker thread for closing default auxiliary criteria completes to perform business module.
CN201410406151.7A 2014-08-15 2014-08-15 A kind of method and system of multi-thread concurrent processing business Expired - Fee Related CN104216765B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410406151.7A CN104216765B (en) 2014-08-15 2014-08-15 A kind of method and system of multi-thread concurrent processing business

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410406151.7A CN104216765B (en) 2014-08-15 2014-08-15 A kind of method and system of multi-thread concurrent processing business

Publications (2)

Publication Number Publication Date
CN104216765A CN104216765A (en) 2014-12-17
CN104216765B true CN104216765B (en) 2017-11-03

Family

ID=52098290

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410406151.7A Expired - Fee Related CN104216765B (en) 2014-08-15 2014-08-15 A kind of method and system of multi-thread concurrent processing business

Country Status (1)

Country Link
CN (1) CN104216765B (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170031724A1 (en) * 2015-07-31 2017-02-02 Futurewei Technologies, Inc. Apparatus, method, and computer program for utilizing secondary threads to assist primary threads in performing application tasks
CN105391968B (en) * 2015-11-03 2019-05-24 浙江大华技术股份有限公司 A kind of video session distribution method and device
CN105915610A (en) * 2016-04-19 2016-08-31 乐视控股(北京)有限公司 Asynchronous communication method and device
CN107589959A (en) * 2016-07-08 2018-01-16 湖南易分销电子商务有限公司 One kind is used for the multi-thread process automation task treatment technology of mall system
CN107247626A (en) * 2017-06-14 2017-10-13 山东开创云软件有限公司 A kind of method dispatched suitable for high concurrent business module
CN110750339B (en) * 2018-07-23 2022-04-26 杭州海康威视系统技术有限公司 Thread scheduling method and device and electronic equipment
CN109032767B (en) * 2018-07-26 2021-04-02 苏州科达科技股份有限公司 Asynchronous multi-process business processing system, method, device and storage medium
CN109815007A (en) * 2018-12-15 2019-05-28 平安科技(深圳)有限公司 Thread control method, device, electronic equipment and storage medium based on cloud monitoring
CN109710416B (en) * 2019-01-11 2021-03-02 银清科技有限公司 Resource scheduling method and device
CN112735115A (en) * 2020-12-28 2021-04-30 新天科技股份有限公司 Multithreading business processing method and device, server and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101308467A (en) * 2008-07-16 2008-11-19 杭州华三通信技术有限公司 Task processing method and device
CN102591721A (en) * 2011-12-30 2012-07-18 北京新媒传信科技有限公司 Method and system for distributing thread execution task
CN103164267A (en) * 2013-03-29 2013-06-19 汉柏科技有限公司 Lock-free message queue implementation method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101403982B (en) * 2008-11-03 2011-07-20 华为技术有限公司 Task distribution method, system for multi-core processor

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101308467A (en) * 2008-07-16 2008-11-19 杭州华三通信技术有限公司 Task processing method and device
CN102591721A (en) * 2011-12-30 2012-07-18 北京新媒传信科技有限公司 Method and system for distributing thread execution task
CN103164267A (en) * 2013-03-29 2013-06-19 汉柏科技有限公司 Lock-free message queue implementation method

Also Published As

Publication number Publication date
CN104216765A (en) 2014-12-17

Similar Documents

Publication Publication Date Title
CN104216765B (en) A kind of method and system of multi-thread concurrent processing business
CN102902587B (en) Distributed task dispatching mthods, systems and devices
CN104699542B (en) Task processing method and system
CN103309738B (en) User job dispatching method and device
CN102033536B (en) Scheduling, organization and cooperation system and method for multi-robot system
CN106095590B (en) A kind of method for allocating tasks and device based on thread pool
CN105007337A (en) Cluster system load balancing method and system thereof
CN105677000B (en) The system and method for dynamic voltage frequency adjustment
EP2053786A3 (en) Targeted resource allocation
CN105975049B (en) A kind of accidental task low energy consumption dispatching method of tasks synchronization
CN106445070B (en) Energy consumption optimization scheduling method for hard real-time system resource-limited sporadic tasks
CN103366022B (en) Information handling system and disposal route thereof
CN104426694B (en) A kind of method and apparatus of adjustment resources of virtual machine
CN104793990A (en) Multi-timing-sequence task scheduling method and system
CN107844376A (en) Resource allocation method, computing system, medium and the server of computing system
CN104348928B (en) A kind of method, management equipment, request equipment and the system of distribution address resource
CN103336684B (en) The AC of a kind of concurrent processing AP message and processing method thereof
CN112130966A (en) Task scheduling method and system
CN107205248A (en) A kind of resource allocation methods and system
CN103455375A (en) Load-monitoring-based hybrid scheduling method under Hadoop cloud platform
CN105786447A (en) Method and apparatus for processing data by server and server
CN104750546B (en) A kind of method and system for adjusting connection pool
CN104301241B (en) A kind of SOA dynamic load distributing methods and system
CN104461722A (en) Job scheduling method used for cloud computing system
CN103533052B (en) In a kind of intelligent perception system, task accesses and the On-Line Control Method of distribution

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20171103

Termination date: 20210815