CN107832126B - Thread adjusting method and terminal thereof - Google Patents

Thread adjusting method and terminal thereof Download PDF

Info

Publication number
CN107832126B
CN107832126B CN201710985525.9A CN201710985525A CN107832126B CN 107832126 B CN107832126 B CN 107832126B CN 201710985525 A CN201710985525 A CN 201710985525A CN 107832126 B CN107832126 B CN 107832126B
Authority
CN
China
Prior art keywords
processed
task
tasks
thread starting
upper limit
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.)
Active
Application number
CN201710985525.9A
Other languages
Chinese (zh)
Other versions
CN107832126A (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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201710985525.9A priority Critical patent/CN107832126B/en
Priority to PCT/CN2018/077682 priority patent/WO2019075980A1/en
Publication of CN107832126A publication Critical patent/CN107832126A/en
Application granted granted Critical
Publication of CN107832126B publication Critical patent/CN107832126B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/484Precedence

Abstract

The invention is suitable for the technical field of computers, and provides a thread adjusting method and a terminal thereof, wherein the thread adjusting method comprises the following steps: inquiring the number of tasks contained in a task library to be processed at preset time intervals; determining the current thread starting number according to the task number and a preset thread starting upper limit; extracting the tasks to be processed which are matched with the thread starting number from the task library to be processed based on the priority of each task to be processed; and starting threads corresponding to the thread starting number, and responding to the tasks to be processed through the threads. The invention solves the problems that the number of threads is fixed and unchanged, if the started threads can not meet the current traffic in the busy service period, the backlog of the tasks to be processed is caused, the service response efficiency is reduced, even a large number of tasks are invalid or overtime, and the service quality of a server and the use experience of a user are reduced in the conventional thread adjusting method.

Description

Thread adjusting method and terminal thereof
Technical Field
The invention belongs to the technical field of computers, and particularly relates to a thread adjusting method and a terminal thereof.
Background
With the continuous development of scientific technology, the types of services that a user can complete through a network are increasing, and therefore the business pressure of a server is also increasing, and in general, the server responds to a business initiated by a client in a concurrent processing manner, specifically, the server simultaneously processes a plurality of business requests by starting a plurality of threads. However, in the conventional thread adjusting method, the number of threads is fixed, and if the service is busy, the started thread may not meet the current traffic, so that the backlog of tasks to be processed is caused, the efficiency of service response is reduced, even a large number of tasks fail or are overtime, and the service quality of the server and the use experience of the user are reduced.
Disclosure of Invention
In view of this, embodiments of the present invention provide a thread adjusting method and a terminal thereof, so as to solve the problems that in an existing thread adjusting method, the number of threads is fixed and unchanged, and if a service is busy, a started thread may not meet a current traffic, so that a backlog of tasks to be processed is caused, so that efficiency of service response is reduced, even a large number of tasks are failed or overtime, and quality of service of a server and user experience are reduced.
A first aspect of an embodiment of the present invention provides a method for adjusting a thread, where the method for adjusting a thread includes:
inquiring the number of tasks contained in a task library to be processed at preset time intervals;
determining the current thread starting number according to the task number and a preset thread starting upper limit;
extracting the tasks to be processed which are matched with the thread starting number from the task library to be processed based on the priority of each task to be processed;
and starting threads corresponding to the thread starting number, and responding to the tasks to be processed through the threads.
A second aspect of the embodiments of the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the following steps when executing the computer program:
inquiring the number of tasks contained in a task library to be processed at preset time intervals;
determining the current thread starting number according to the task number and a preset thread starting upper limit;
extracting the tasks to be processed which are matched with the thread starting number from the task library to be processed based on the priority of each task to be processed;
and starting threads corresponding to the thread starting number, and responding to the tasks to be processed through the threads.
A third aspect of embodiments of the present invention provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of:
inquiring the number of tasks contained in a task library to be processed at preset time intervals;
determining the current thread starting number according to the task number and a preset thread starting upper limit;
extracting the tasks to be processed which are matched with the thread starting number from the task library to be processed based on the priority of each task to be processed;
and starting threads corresponding to the thread starting number, and responding to the tasks to be processed through the threads.
The thread adjusting method and the terminal thereof provided by the embodiment of the invention have the following beneficial effects:
the number of tasks contained in a task library to be processed is inquired at preset time intervals, and the number of the current thread starting is adjusted in real time according to the number of the tasks, so that the service response capacity of the terminal equipment is matched with the number of the current tasks to be processed; after the number of the threads started is determined, the terminal equipment extracts the tasks to be processed, the number of which is consistent with the number of the threads started, from the task library to be processed based on the priority of each task to be processed, and responds, so that the purpose of dynamically adjusting the number of the threads started of the terminal equipment is achieved. Compared with the existing service response technology, the number of the starting threads of the server is kept unchanged, when the number of the tasks to be processed is small, the threads are easy to start but idle, resources of the server are wasted, when the number of the tasks to be processed is large, the number of the current threads to start is not increased, and the situation of overstock of the tasks is easy to cause.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart illustrating an implementation of a thread adjustment method according to a first embodiment of the present invention;
fig. 2 is a flowchart illustrating a detailed implementation of the thread adjusting method S102 according to a second embodiment of the present invention;
fig. 3 is a flowchart illustrating a detailed implementation of a thread adjustment method according to a third embodiment of the present invention;
fig. 4 is a flowchart illustrating a detailed implementation of a thread adjusting method S102 according to a fourth embodiment of the present invention;
fig. 5 is a flowchart illustrating a detailed implementation of a thread adjusting method S103 according to a fifth embodiment of the present invention;
fig. 6 is a block diagram of a thread adjusting terminal according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The number of tasks contained in a task library to be processed is inquired at preset time intervals, and the number of the current thread starting is adjusted in real time according to the number of the tasks, so that the service response capacity of the terminal equipment is matched with the number of the current tasks to be processed; after the number of the threads is determined, the terminal equipment extracts the tasks to be processed, the number of which is consistent with the number of the threads started, from the task library to be processed based on the priority of each task to be processed, and responds, so that the purpose of dynamically adjusting the number of the threads started of the terminal equipment is achieved, and the problems that the number of the threads is fixed and unchanged, if the threads are busy, the started threads possibly cannot meet the current traffic, the backlog of the tasks to be processed is caused, the efficiency of service response is reduced, even a large number of tasks fail or overtime is caused, and the service quality of a server and the use experience of a user are reduced are solved.
In the embodiment of the present invention, the execution main body of the process is a terminal device installed with a thread adjustment program, the terminal device includes a mobile phone, a computer device, a tablet computer, and other terminals, and particularly, the terminal device is specifically a server, and is configured to receive and respond to a service request initiated by each user terminal, and then return a response result to the corresponding user terminal, thereby implementing an operation of service response. Fig. 1 shows a flowchart of an implementation of a method for adjusting a thread according to a first embodiment of the present invention, which is detailed as follows:
in S101, the number of tasks included in the task library to be processed is queried at preset time intervals.
In this embodiment, after receiving processing tasks sent by other user terminals, the terminal device stores the processing tasks in the to-be-processed task library, so that when a processing opportunity arrives, corresponding to-be-processed tasks are extracted according to the priority and the receiving order of each to-be-processed task to respond.
It should be noted that the to-be-processed task library may be in a local storage of the terminal device, and in this case, the terminal device may directly read the local storage, so as to obtain the relevant information of the to-be-processed task; the task library to be processed may also be an independent storage server, and is dedicated to receive and store the processing tasks sent by each user terminal. The terminal device needs to respond to the processing tasks sent by the plurality of user terminals at the same time, that is, a certain number of ports needs to be allocated to execute the operation of receiving the processing tasks, on the other hand, the terminal device needs to return the processing result to the user terminal after the corresponding task to be processed is completed in response, and at this time, the return operation needs to call a certain number of ports. Therefore, in order to improve the service response efficiency of the terminal device, an independent storage server may be provided, a corresponding number of ports may be provided, and processing tasks sent by other user terminals may be received.
In this embodiment, the terminal device queries the number of tasks included in the task library to be processed at a preset time interval, where the preset time interval is specifically a task extraction period of the terminal device. The terminal equipment has a preset task extraction period and a task response period, and when the terminal equipment reaches the task extraction period, corresponding number of tasks to be processed are extracted from the task library to be processed, and the task response period is entered. And in the task response period, the terminal equipment responds to the extracted tasks to be processed through a plurality of threads, the tasks to be processed are not extracted from the task library to be processed, and after the task response period is finished, if the starting time corresponding to the task extraction period is reached again, the operation of extracting the tasks to be processed is executed circularly. The step S101 provided in this embodiment is an operation performed when the terminal device enters the task extraction cycle. For example, the preset time interval is 2 minutes, the terminal device queries the number of tasks included in the task library to be processed every two minutes, and then responds to the tasks in the task library to be processed. Of course, the duration of the preset time interval may be set according to the actual requirement of the user, for example, 30 seconds, 10 minutes, and the like, and the preset time interval may also be adjusted according to whether the current time period belongs to a busy time period.
Optionally, in this embodiment, before S101, the method further includes: verifying the legality and the integrity of the task to be processed through a preset task to be processed verification algorithm, if the verification is successful, storing the task to be processed in a task library to be processed, and executing relevant operations of S101; otherwise, if the verification fails, the task request is discarded, and the illegal information of the task is returned to the corresponding user terminal. By the means, the terminal equipment can preprocess the tasks to be processed before processing, so that most illegal tasks are filtered, the service response pressure of the terminal equipment is reduced, and more storage spaces of the task library to be processed can be released for storing other effective tasks to be processed.
In S102, the current thread starting number is determined according to the number of tasks and a preset thread starting upper limit.
In this embodiment, after acquiring the number of tasks included in the task library to be processed, the terminal device acquires a preset thread starting upper limit, and determines the size of both the number of tasks and the thread starting upper limit, thereby determining whether an independent thread can be allocated for each task to be processed for responding. If the number of the tasks is less than or equal to the thread starting upper limit, the method indicates that a thread can be set for each task to be processed to respond to the task to be processed, and the current thread starting number is the number of the tasks; on the contrary, if the number of the tasks is greater than the preset thread starting upper limit, it indicates that the number of the tasks cannot exceed the number of the threads which can be started, that is, all the tasks to be processed cannot be responded in the task response period of this time, so the thread starting upper limit is set as the current thread starting number.
Optionally, in this embodiment, the terminal device may further set a corresponding thread starting upper limit for each task type. In this case, in S101, the terminal device not only obtains the number of tasks included in the to-be-executed task library, but also compares the number of tasks of each task type with the thread starting upper limit corresponding thereto according to the number of tasks corresponding to each task type, and obtains the number of thread promoters of each task type, thereby calculating the current thread starting number by the number of the thread promoters. In order to respond to the task with higher priority in each task response period, the terminal equipment reserves certain resources to respond to the task with lower priority, so that the task type with lower priority is prevented from being executed all the time in a delayed manner, a corresponding thread starting upper limit is set for each task type, and the response quantity of each task type is balanced.
For example, the terminal device is a net recommended value server, configured to respond to a net recommended value service request sent by each user terminal, where the net recommended value service request includes but is not limited to: services affecting the net recommendation value of the user to the interactive object, such as online service consultation, opinion feedback reply, failure declaration processing and the like, also include related service requests in the process of calculating the net recommendation value of the interactive object, such as a sample operation feedback opinion collection service request, a sample operation feedback opinion sending service request and the like. Because the net recommended value service request generally has strong real-time performance, when the net recommended value server detects that the to-be-processed task library contains the net recommended value service request, the net recommended value service request is processed preferentially. If the net recommended value server continuously obtains a large number of net recommended value service requests in a certain time period, and the server only responds to the net recommended value service requests in each task response cycle due to the high priority of the service requests, other service requests cannot respond. Therefore, the net recommended value server sets corresponding thread starting upper limits for different service request types, for example, for the net recommended value server as a whole, the thread starting upper limit is 100, the thread starting upper limit for the net recommended value service request is 80, and the thread starting upper limit for other types of service requests is 20. Therefore, the server reserves certain thread service to respond to other types of service requests while ensuring that the server preferentially responds to the net recommended value service request, so that service resources are reasonably distributed.
Preferably, with the above scheme, the number of the tasks of the first type is smaller than the thread starting upper limit corresponding thereto, and the number of the tasks of the second type is larger than the thread starting upper limit corresponding thereto, at this time, the remaining threads of the number of the tasks of the first type are available for responding to the tasks of the second type. For example, the number of the first type of task is 15, and the starting upper limit of the corresponding first thread is 30, so that the terminal device still has 15 threads to be idle for allocating to the first type of task, and can respond to other types of tasks. At this time, the terminal device determines that the number of the second type tasks is 25, and the corresponding second thread starting upper limit is 20, so that 5 threads can be extracted from the remaining 15 threads in the first type threads to respond to the second type tasks, and resources of each type can be reasonably called according to actual conditions.
In S103, based on the priority of each to-be-processed task, to-be-processed tasks matching the thread starting number are extracted from the to-be-processed task library.
In this embodiment, the terminal device first obtains the priority of each to-be-processed task, and extracts the N to-be-processed tasks with the highest priority from the to-be-processed task library according to the current number N of the start threads determined in S102, as the to-be-processed tasks executed by the current task response process.
In this embodiment, the priority of the to-be-processed task may be set by a task initiator, that is, by a user of the task request, and when the user generates the to-be-processed task, the priority of the to-be-processed task is set, so that when the terminal device receives the to-be-processed task, the corresponding response time may be determined based on the corresponding priority. Specifically, a user directly sets a priority parameter, for example, a corresponding parameter value is set in a priority byte of a task to be processed; the priority of the task to be processed can also be indirectly set in a mode of limiting the task feedback time, for example, for the task to be processed with higher priority, the corresponding preset feedback time is shorter; and the corresponding preset feedback time is longer corresponding to the task to be processed with lower priority.
In this embodiment, the priority of the task to be processed may also be set by the terminal device. Specifically, the terminal device queries a preset task type and priority corresponding relation list according to the task type of the task to be processed, so as to determine the priority of the task to be processed and generate the corresponding relation list of the task to be processed and the priority. When the terminal device executes the operation of S103, the terminal device directly reads the corresponding relationship list between the task to be processed and the priority, that is, the priority corresponding to each task to be processed can be determined. Preferably, the tasks to be processed in the corresponding relation list of the tasks to be processed and the priorities are sequentially sorted according to the size sequence of the priorities, and if the tasks to be processed have the same priority, the tasks to be processed are sorted according to the sequence of the task obtaining time, so that the terminal device directly intercepts the tasks to be processed corresponding to the thread starting number N, extraction is performed after priority information is not required to be obtained one by one, and task response efficiency is improved.
In S104, the threads corresponding to the number of the thread starts are started, and the to-be-processed task is responded through the threads.
In this embodiment, the terminal device starts the corresponding number of threads according to the number of started threads determined in S102, and responds to the to-be-processed task extracted in S103 through the started threads. Specifically, each thread responds to one to-be-processed task, so that the purpose of concurrently responding to a plurality of to-be-processed tasks is achieved.
In this embodiment, after a certain thread of the terminal device has completed a task to be processed, a requesting user identifier corresponding to the task is obtained, and a task processing result is fed back to the terminal corresponding to the requesting user identifier according to the requesting user identifier. The operation of processing result feedback can be sent to the thread responding to the task to be processed for execution, or after the thread executes the completed task, the processing result and the network address of the corresponding terminal are sent to the processing result sending module, and the processing result sending module sends the task result to the processing result sending module for unified sending operation of the task result.
Optionally, in this embodiment, the terminal device may summarize the processing results generated by all threads in the current response cycle, and then uniformly feed back the processing results to the corresponding user terminal. In this case, since some of the pending tasks may involve a smaller amount of data operations, the threads that process this type of pending task may complete the response operation earlier, and the processing result is sent uniformly, i.e., the threads are in an idle state. In this case, the terminal device may arrange the idle thread to support the slower thread, that is, execute the slower to-be-processed task by two threads simultaneously, so as to increase the response rate of the task and the utilization rate of the resource.
As can be seen from the above, in the thread adjusting method provided in the embodiment of the present invention, the number of tasks included in the task library to be processed is queried at preset time intervals, and the current thread starting number is adjusted in real time according to the number of tasks, so that the service response capability of the terminal device matches with the current number of tasks to be processed; after the number of the threads started is determined, the terminal equipment extracts the tasks to be processed, the number of which is consistent with the number of the threads started, from the task library to be processed based on the priority of each task to be processed, and responds, so that the purpose of dynamically adjusting the number of the threads started of the terminal equipment is achieved. Compared with the existing service response technology, the number of the starting threads of the server is kept unchanged, when the number of the tasks to be processed is small, the threads are easy to start but idle, resources of the server are wasted, when the number of the tasks to be processed is large, the number of the current threads to start is not increased, and the situation of overstock of the tasks is easy to cause.
Fig. 2 is a flowchart illustrating a specific implementation of the thread adjusting method S102 according to a second embodiment of the present invention. Referring to fig. 2, with respect to the embodiment shown in fig. 1, the method for adjusting a thread S102 provided in this embodiment further includes the following steps, which are detailed as follows:
further, the determining the current thread starting number according to the task number and a preset thread starting upper limit includes:
in S201, time information of the current time is acquired.
In this embodiment, the thread starting upper limit preset in the terminal device changes with time, that is, different time periods all correspond to one thread starting upper limit. For example, for an idle time period, the number of tasks to be processed which are averagely received by the terminal device is generally small, and at this time, the terminal device does not need to be in a full-load state to work but can gradually respond to the tasks to be processed, so that the upper limit of thread starting is small; on the contrary, in a busy period, the terminal equipment continuously receives a large number of tasks to be processed, and at the moment, the terminal equipment can be in a full-load state, so that the batch task failure caused by the accumulation of a large number of tasks to be processed is avoided.
In this embodiment, after determining the number of tasks included in the current task library to be processed, the terminal device determines the time information of the current time. Wherein, the time information can be absolute time information, such as 18:53, and uniquely determines the current time; the time information may also be relative time information, such as a time length of the terminal device running, a time length of the full-loading mode, and the like, which are used for indicating the running state of the terminal device. In this case, the terminal device defines the maximum operation time of each operation mode, and if the time information at the current time, that is, the operation time of the operation mode is greater than the maximum operation time, the operation mode of the terminal device is switched, and the current thread start upper limit is adjusted accordingly, so that the administrator can adjust the thread start upper limit of the terminal device in real time by configuring the relationship list between the operation mode and the thread start upper limit in response.
In S202, the thread starting upper limit corresponding to the time information is determined based on a corresponding relationship between a preset thread starting upper limit and the time information.
In this embodiment, the terminal device stores in advance the thread start upper limit corresponding to each different time information, and generates a correspondence between the thread start upper limit and the time information. The upper server determines thread starting upper limits corresponding to the devices in different time periods by acquiring the operating conditions of the terminal devices, and then generates a corresponding relation between the general thread starting upper limit suitable for the terminal devices and the time information. Therefore, each terminal device can directly acquire the corresponding relation from the upper server and store the corresponding relation in the local storage module.
In this embodiment, the user may generate the corresponding relationship between the thread start upper limit and the time information according to the actual use requirement, or may adjust the thread start upper limit based on the existing corresponding relationship. For convenience of management, the terminal device generates the corresponding relation between the thread starting upper limit and the time information in a mode set by default by the system, and can also enable a user to generate or adjust the corresponding relation.
After determining the current time information, the terminal device queries the corresponding relationship between the preset thread starting upper limit and the time information, determines the thread starting upper limit corresponding to the current time, and then executes the relevant operation of S203.
In S203, the current thread starting number is determined according to the task number and the thread starting upper limit corresponding to the time information.
In this embodiment, after determining the thread start upper limit corresponding to the current time information, the terminal device compares the number of tasks included in the to-be-executed task library with the thread start upper limit, and selects a smaller value of the two as the current thread start number.
In the embodiment of the invention, the numerical value of the thread starting upper limit is not fixed and can be adjusted according to different time information, so that the thread resource of the terminal equipment is effectively utilized, unnecessary resource waste is avoided, and the utilization efficiency of the resource and the flexibility of the terminal equipment are improved. In particular, the terminal device operates in a mode that may be fully loaded or overloaded for a long time during busy hours, and thus may operate under a less loaded state during non-busy hours in order to provide a certain buffer period for the terminal device. For example, in a certain task extraction cycle of idle time, the terminal device detects that the to-be-processed task library includes 100 to-be-processed tasks, the thread start upper limit corresponding to the time is 50, and the next extraction cycle database does not receive a new to-be-processed task, so the terminal device can execute the 100 to-be-processed tasks through two task response cycles, although the thread start upper limit of the terminal device in a busy period can reach 100, the time period is an idle time period, that is, the mathematical expectation value of the task quantity of the to-be-processed tasks in the time period is small, and a large number of to-be-processed tasks cannot be continuously acquired for a long time, so that the lower thread start upper limit can be maintained, and even if the to-be-processed tasks with increased bursts are encountered, the terminal device can gradually respond.
Fig. 3 is a flowchart illustrating a specific implementation of a thread adjustment method according to a third embodiment of the present invention. Referring to fig. 3, with respect to the embodiment shown in fig. 2, the method for adjusting a thread provided in this embodiment further includes the following steps, which are detailed as follows:
further, before S101, the method for adjusting the thread further includes:
in S301, a historical service response record is acquired; and the historical service response record comprises the information of the tasks to be processed and the running information of the hardware resources in each time period.
In this embodiment, after responding to the task to be executed each time, the terminal device generates a task response record to be processed corresponding to the task, where the task response record to be processed specifically includes: responding to information such as starting time, response finishing time, execution duration, hardware resource occupation condition, response waiting duration and the like. After the terminal device obtains the task response records corresponding to each task to be processed, the number of the tasks to be processed contained in different time periods and the consumption condition of the whole hardware resources of the terminal device in each time period can be determined, and then the historical service response records are generated.
In this embodiment, the hardware resource operation information includes, but is not limited to, one or a combination of at least two of the following: the running condition of the CPU, the occupation condition of the memory, the running temperature of the terminal equipment, the data read-write speed and the like. The hardware resource operation information is related to internal factors such as the current response task quantity and external factors such as the temperature, the voltage and the power of a machine room, so that the terminal equipment not only acquires the information of the tasks to be processed in each time period, but also acquires the hardware resource operation information and generates a corresponding historical service response record so as to determine the thread starting upper limit, and not only the internal factors but also the influence factors of the external environment on the terminal equipment are considered.
In S302, a correspondence relationship between the thread start upper limit and time information is generated based on the historical service response record.
In this embodiment, the terminal device determines the average number of tasks to be executed in each time period according to the number of tasks to be executed corresponding to different time periods or task extraction periods in the historical service response record, so as to obtain a change trend of the number of tasks to be executed over time. And the terminal equipment obtains a first factor for determining the corresponding relation between the thread starting upper limit and the time information based on the change trend of the number of the tasks to be executed.
In this embodiment, the terminal device determines the operation state of the terminal device in each time period according to hardware operation information corresponding to different time periods or task extraction periods in the historical service response record, where the operation state includes a load condition, an operation efficiency condition, and an abnormality occurrence rate, so as to obtain a change trend of the operation state over time. And the terminal equipment obtains a second factor for determining the corresponding relation between the thread starting upper limit and the time information based on the running state change trend.
In this embodiment, the terminal device generates a corresponding relationship between the thread start upper limit and the time information according to the first factor and the second factor. Optionally, the first factor is specifically an average number of executed tasks, and the second factor is hardware operating efficiency, so that the thread starting upper limit corresponding to any time period is as follows: average number of executed tasks x hardware operating efficiency. For example, in a time period from 8:00 to 8:10, the number of tasks to be executed received by the terminal device on average is 50, and the running speed of the hardware in the time period reaches the rated running speed, so that the running efficiency is 100%, and therefore, the upper limit of the thread start corresponding to the time period is: 50 × 100% ═ 50. Of course, the first factor may be the maximum number of tasks to be executed or the minimum number of tasks to be executed in the time period in the history record, or may be a mathematical expectation of the number of tasks to be executed, which is not limited herein. Then, the second factor may also determine a corresponding scaling factor according to the operating state, which is also not limited herein, specifically, the better the operating state of the terminal device is, that is, the lower the load is, the higher the operating efficiency is and/or the lower the occurrence rate of the abnormality is, the larger the corresponding scaling factor is, the terminal device may respond to more tasks to be executed in the time period, and thus the upper limit of thread starting is higher; conversely, the worse the operation state of the terminal device is, the smaller the corresponding proportionality coefficient is. Wherein the proportionality coefficient is a positive number greater than 0.
In the embodiment of the invention, the terminal equipment can also adjust the corresponding relation list of the thread starting upper limit and the time information according to the historical service response record.
Fig. 4 is a flowchart illustrating a detailed implementation of the thread adjusting method S102 according to a fourth embodiment of the present invention. Referring to fig. 4, with respect to the embodiments described in fig. 1 to fig. 3, in the method for adjusting threads provided in this embodiment, determining the current thread starting number according to the number of tasks and the preset thread starting upper limit further includes S401 to S405, which are detailed as follows:
in S401, it is determined whether the number of tasks is greater than the thread start upper limit.
In S402, if the number of tasks is greater than the thread start upper limit, it is determined whether a first ratio between the number of tasks and the thread start upper limit is greater than a preset up-trigger threshold.
In this embodiment, the upper limit of thread start of the terminal device may be adjusted according to the current actual number of tasks, so that the task processing capability of the terminal device matches the current task amount. Because the preset thread starting upper limit is obtained by prejudging according to the administrator or the system history record, and various emergency situations often occur in the actual process, the terminal device is provided with a process for adjusting the thread starting upper limit to flexibly adjust the thread starting upper limit.
In this embodiment, when the terminal device detects that the number of tasks included in the current task library to be processed is greater than the thread starting upper limit, that is, it indicates that the terminal device cannot complete responses to all tasks to be processed in the task response period of this time, and the actual task amount is greater than the task processing capability of the current terminal device. At this time, the terminal device calculates a first ratio between the number of tasks and the thread starting upper limit, and determines whether the first ratio is greater than a preset up-regulation trigger threshold.
In this embodiment, the trigger threshold is adjusted up to define whether the current task volume is in an abnormally increased situation and whether the current task processing capacity is sufficient to cope with the current task volume, without causing backlog and failure of a large batch of tasks. Therefore, if the first ratio is less than or equal to the up-regulation trigger threshold, it indicates that the current task processing capacity of the terminal device is matched with the current task amount, and the thread starting upper limit does not need to be adjusted, and the current thread starting upper limit is maintained unchanged; on the contrary, if the first ratio is greater than the up-regulation trigger threshold, it indicates that the current task amount is suddenly increased, and the current processing capability of the terminal device cannot ensure that all the tasks to be processed can normally respond, so the thread start upper limit is regulated, and the related operation of S403 is executed.
For example, in a certain time period, the thread starting upper limit of the terminal device is 100, and the up-regulation trigger threshold is 300%, that is, if the number of tasks to be executed at a certain time exceeds twice of the processing capacity of the terminal device, the thread starting upper limit needs to be adjusted. If the number of the tasks contained in the task library to be executed at the current moment is 150 and is greater than the thread starting upper limit 100, the terminal device calculates a first ratio of the number of the tasks to the thread starting upper limit as follows: 150/100, being less than the raise trigger threshold, the current thread start upper limit is kept unchanged.
In S403, if the first ratio is greater than a preset up-regulation trigger threshold, based on the first ratio, the thread start upper limit is increased, and the smaller value of the number of tasks and the increased thread start upper limit is selected as the current thread start number.
In this embodiment, after the terminal device detects that the first ratio is greater than the preset up-regulation trigger threshold, the terminal device correspondingly regulates the thread start upper limit of the terminal device. The terminal device presets a corresponding relation list of the first ratio and the adjustment amplitude, inquires an adjustment coefficient corresponding to the first ratio according to the first ratio obtained by current calculation, and then increases the thread starting upper limit through the adjustment coefficient.
For example, as described in the example of S402, the upper limit of thread starting of the terminal device is 100, the upward-adjustment trigger threshold is 300%, and the current number of tasks is 320, that is, the first ratio is 320% greater than the upward-adjustment trigger threshold, so that the upper limit of thread starting needs to be adjusted. The terminal device calculates that the adjustment coefficient corresponding to 320% is 200% based on the corresponding relation list of the first ratio and the adjustment amplitude, that is, the thread starting upper limit is doubled, that is, the thread starting upper limit after the increase is 200.
In this embodiment, after determining the thread starting upper limit, the terminal device selects a smaller value from the number of tasks and the adjusted thread starting upper limit as the current thread starting number. Since the adjustment coefficient may be larger than the first ratio, the actually calculated thread starting upper limit may be larger than the number of tasks.
In S404, if the number of tasks is smaller than the thread starting upper limit, it is determined whether a second ratio between the thread starting upper limit and the number of tasks is greater than a preset down-regulation trigger threshold.
In this embodiment, the terminal device may also appropriately adjust the current thread starting upper limit according to the current task number, and since the terminal device may use the current starting upper limit of each time period in the history record as a setting basis when setting the corresponding relationship between the time information and the thread starting upper limit, in order to make the corresponding relationship more accurate and reasonably allocate the thread resources of the terminal device, the terminal device may also appropriately reduce the thread starting upper limit according to the current task number, so that the reserved thread may perform other operations. For example, in a certain time period, the thread start upper limit of the terminal device is 100, and the down-regulation trigger threshold is 200%, that is, if the number of tasks to be executed at a certain time is less than twice of the current processing capacity of the terminal device, the thread start upper limit needs to be adjusted. If the number of the tasks contained in the task library to be executed at the current moment is 40 and is smaller than the thread starting upper limit 100, the terminal device calculates a second ratio of the thread starting upper limit to the number of the tasks as follows: 100/40% is greater than the down-regulation trigger threshold, the correlation operation of S405 is performed.
In this embodiment, when it is determined that the number of tasks is smaller than the upper thread starting limit, the terminal device calculates a second ratio between the upper thread starting limit and the number of tasks, and determines whether the second ratio is larger than a preset down-regulation trigger threshold. If the second ratio is greater than the down-regulation trigger threshold, it indicates that the task processing capacity of the terminal device is far greater than the currently required task amount, so that the thread starting upper limit is reduced, and the operation of S405 is executed; otherwise, if the second ratio is smaller than or equal to the down-regulation trigger threshold, the current thread starting upper limit is kept.
In S405, if the second ratio is greater than a preset down-regulation trigger threshold, the thread start upper limit is reduced based on the first ratio, and the smaller value of the number of tasks and the reduced thread start upper limit is selected as the current thread start number.
For example, as described in the example of S402, the upper limit of thread starting of the terminal device is 100, the down-regulation trigger threshold is 200%, and the current number of tasks is 40, that is, the second ratio is 250% greater than the down-regulation trigger threshold, so that the upper limit of thread starting needs to be down-regulated. The terminal device calculates that the adjustment coefficient corresponding to 250% is 200% based on the corresponding relation list of the first ratio and the adjustment amplitude, that is, the thread starting upper limit is reduced by one time, that is, the reduced thread starting upper limit is 50.
In this embodiment, after the terminal device detects that the second ratio is greater than the preset down-regulation trigger threshold, the terminal device correspondingly adjusts the thread start upper limit of the terminal device. The terminal device presets a corresponding relation list of the second ratio and the adjustment amplitude, inquires an adjustment coefficient corresponding to the second ratio according to the currently calculated second ratio, and then reduces the thread starting upper limit through the adjustment coefficient.
In the embodiment of the invention, whether the thread starting upper limit needs to be adjusted is determined by acquiring the ratio of the number of tasks to the thread starting upper limit, so that the task processing capacity of the terminal equipment is flexibly adjusted, and the accuracy of the thread starting upper limit is improved.
Fig. 5 is a flowchart illustrating a detailed implementation of the thread adjusting method S103 according to a fifth embodiment of the present invention. Referring to fig. 5, with respect to the embodiment shown in fig. 1, the method S103 for adjusting a thread according to this embodiment further includes the following steps, which are detailed as follows:
further, the extracting the tasks to be processed, which are matched with the thread starting number, from the task library to be processed based on the priority of each task to be processed includes:
in S501, whether each to-be-processed task is valid is respectively determined according to the maximum waiting time of each to-be-processed task and the task sending time.
In this embodiment, in order to ensure that all the responding to-be-processed tasks are valid to-be-processed tasks, the terminal device determines valid attributes of the to-be-processed tasks before extracting the to-be-processed tasks. If the task to be processed is determined to be valid, executing the relevant operation of S503; if the pending process is determined to be invalid, the related operation of S502 is performed.
Specifically, the terminal device first acquires current time information and a sending time of the task, calculates a waiting time relative to the current time, and if the waiting time is longer than a maximum waiting time, the task is invalid and is identified as an invalid task to be processed; otherwise, if the waiting time is less than or equal to the maximum waiting time, the task is effective and is identified as an effective task to be processed.
In S502, if the to-be-processed task is invalid, deleting the to-be-processed task from the to-be-processed task library, and returning service timeout information to the client corresponding to the to-be-processed task.
In this embodiment, if the terminal device detects that the task to be processed is an invalid task, the terminal device deletes the task to be processed from the task library to be processed, thereby ensuring that the tasks to be processed included in the task library to be processed are all valid tasks to be processed. Further, in order to inform a user of the service request that the task to be processed sent by the user is invalid, the terminal device pushes service timeout information to a client corresponding to the task to be processed, so that the client can initiate the task request again.
In S503, if the to-be-processed task is valid, the priority of the to-be-processed task is adjusted based on the remaining valid duration of the to-be-processed task.
In this embodiment, if the terminal device determines that the task to be processed is an effective task, the remaining effective time included in the task is extracted, so that the priority of the task to be processed is adjusted according to the remaining effective time. The terminal equipment avoids the invalidation of the tasks to be processed, and responds to the more urgent tasks to be processed firstly, so the terminal equipment improves the priority of the tasks to be processed with shorter residual time according to the effective residual time of each task to be processed, and maintains the priority of the tasks to be processed with longer effective residual time unchanged.
In the embodiment of the invention, the terminal equipment firstly screens the tasks to be processed before the extraction operation, thereby improving the effective rate of service response and improving the efficiency of service response.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Fig. 6 is a block diagram illustrating a configuration of a thread adjusting terminal according to an embodiment of the present invention, where the thread adjusting terminal includes units for executing steps in the corresponding embodiment of fig. 1. Please refer to fig. 1 and fig. 1 for the corresponding description of the embodiment. For convenience of explanation, only the portions related to the present embodiment are shown.
Referring to fig. 6, the thread adjusting terminal includes:
a task number determining unit 61, configured to query the number of tasks included in the task library to be processed at preset time intervals;
a current thread starting number determining unit 62, configured to determine a current thread starting number according to the number of tasks and a preset thread starting upper limit;
a to-be-processed task extracting unit 63, configured to extract, based on the priority of each to-be-processed task, to-be-processed tasks that are matched with the thread starting number from the to-be-processed task library;
and a to-be-processed task response unit 64, configured to start threads corresponding to the thread start number, and respond to the to-be-processed task through the threads.
Optionally, the unit 62 for determining the number of activated current threads includes:
the time information determining unit is used for acquiring the time information of the current moment;
the thread starting upper limit determining unit is used for determining the thread starting upper limit corresponding to the time information based on the corresponding relation between the preset thread starting upper limit and the time information;
and the current thread starting number setting unit is used for determining the current thread starting number according to the task number and the thread starting upper limit corresponding to the time information.
Optionally, the thread adjusting apparatus further includes:
a historical service response record obtaining unit, configured to obtain a historical service response record; the historical service response records comprise information of tasks to be processed in each time period and hardware resource operation information;
and the thread starting upper limit corresponding relation generating unit is used for generating the corresponding relation between the thread starting upper limit and the time information based on the historical service response record.
Optionally, the unit 62 for determining the number of started current threads further includes:
the up-regulation trigger judging unit is used for judging whether a first ratio between the number of the tasks and the thread starting upper limit is greater than a preset up-regulation trigger threshold value or not if the number of the tasks is greater than the thread starting upper limit;
a thread starting upper limit up-regulation unit, configured to increase the thread starting upper limit based on the first ratio if the first ratio is greater than a preset up-regulation trigger threshold, and select a smaller value of the number of tasks and the increased thread starting upper limit as the current thread starting number;
a down-regulation trigger judging unit, configured to, if the number of tasks is smaller than the thread starting upper limit, judge whether a second ratio between the thread starting upper limit and the number of tasks is greater than a preset down-regulation trigger threshold;
and the thread starting upper limit down-regulation unit is used for reducing the thread starting upper limit based on the first ratio if the second ratio is greater than a preset down-regulation trigger threshold, and selecting the smaller value of the number of the tasks and the reduced thread starting upper limit as the current thread starting number.
Optionally, the to-be-processed task extracting unit 63 includes:
the task failure judgment unit is used for respectively judging whether each task to be processed is effective according to the maximum waiting time and the task sending time of each task to be processed;
a to-be-processed task failure response unit, configured to delete the to-be-processed task from the to-be-processed task library and return service timeout information to a client corresponding to the to-be-processed task if the to-be-processed task is invalid;
and the priority determining unit of the tasks to be processed is used for adjusting the priority of the tasks to be processed based on the remaining effective duration of the tasks to be processed if the tasks to be processed are effective.
Therefore, the thread adjusting terminal provided by the embodiment of the invention can also query the number of tasks contained in the task library to be processed at preset time intervals, and adjust the current thread starting number in real time according to the number of the tasks, so that the service response capability of the terminal equipment is matched with the current number of the tasks to be processed; after the number of the threads started is determined, the terminal equipment extracts the tasks to be processed, the number of which is consistent with the number of the threads started, from the task library to be processed based on the priority of each task to be processed, and responds, so that the purpose of dynamically adjusting the number of the threads started of the terminal equipment is achieved. Compared with the existing service response technology, the number of the starting threads of the server is kept unchanged, when the number of the tasks to be processed is small, the threads are easy to start but idle, resources of the server are wasted, when the number of the tasks to be processed is large, the number of the current threads to start is not increased, and the situation of overstock of the tasks is easy to cause.
Fig. 7 is a schematic diagram of a terminal device according to another embodiment of the present invention. As shown in fig. 7, the terminal device 7 of this embodiment includes: a processor 70, a memory 71 and a computer program 72, such as a thread's adjustment program, stored in said memory 71 and operable on said processor 70. The processor 70, when executing the computer program 72, implements the steps in the above-mentioned embodiments of the thread adjusting method, such as S101 to S104 shown in fig. 1. Alternatively, the processor 70, when executing the computer program 72, implements the functions of the units in the above-described device embodiments, such as the functions of the modules 61 to 64 shown in fig. 6.
Illustratively, the computer program 72 may be divided into one or more units, which are stored in the memory 71 and executed by the processor 70 to accomplish the present invention. The one or more units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 72 in the terminal device 7. For example, the computer program 72 may be divided into a task number determining unit, a current thread starting number determining unit, a to-be-processed task extracting unit, and a to-be-processed task responding unit, where the specific functions of each unit are as follows:
the task number determining unit is used for inquiring the number of tasks contained in the task library to be processed at preset time intervals;
a current thread starting number determining unit, configured to determine a current thread starting number according to the number of tasks and a preset thread starting upper limit;
the to-be-processed task extraction unit is used for extracting the to-be-processed tasks matched with the thread starting number from the to-be-processed task library based on the priority of each to-be-processed task;
and the task response unit to be processed is used for starting the threads corresponding to the thread starting number and responding the tasks to be processed through the threads.
The terminal device 7 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is merely an example of a terminal device 7 and does not constitute a limitation of the terminal device 7 and may comprise more or less components than shown, or some components may be combined, or different components, for example the terminal device may further comprise input output devices, network access devices, buses, etc.
The Processor 70 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or a memory of the terminal device 7. The memory 71 may also be an external storage device of the terminal device 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal device 7. The memory 71 is used for storing the computer program and other programs and data required by the terminal device. The memory 71 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. . Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (8)

1. A method for adjusting a thread, comprising:
inquiring the number of tasks contained in a task library to be processed at preset time intervals;
determining the current thread starting number according to the task number and a preset thread starting upper limit;
extracting the tasks to be processed which are matched with the thread starting number from the task library to be processed based on the priority of each task to be processed;
starting threads corresponding to the thread starting number, and responding to the tasks to be processed through the threads;
determining the current thread starting number according to the task number and a preset thread starting upper limit, wherein the step comprises the following steps:
if the number of the tasks is larger than the thread starting upper limit, judging whether a first ratio between the number of the tasks and the thread starting upper limit is larger than a preset up-regulation trigger threshold value or not;
if the first ratio is larger than a preset up-regulation trigger threshold, based on the first ratio, increasing the thread starting upper limit, and selecting the smaller value of the number of tasks and the increased thread starting upper limit as the current thread starting number;
if the number of the tasks is smaller than the thread starting upper limit, judging whether a second ratio between the thread starting upper limit and the number of the tasks is larger than a preset down-regulation trigger threshold value or not;
if the second ratio is larger than a preset down-regulation trigger threshold, based on the second ratio, reducing the thread starting upper limit, and selecting the smaller value of the number of tasks and the reduced thread starting upper limit as the current thread starting number.
2. The adjusting method according to claim 1, wherein the determining the current thread starting number according to the task number and a preset thread starting upper limit includes:
acquiring time information of the current moment;
determining a thread starting upper limit corresponding to time information based on a corresponding relation between a preset thread starting upper limit and the time information;
and determining the current thread starting number according to the task number and the thread starting upper limit corresponding to the time information.
3. The adjustment method according to claim 2, characterized in that the adjustment method further comprises:
acquiring a historical service response record; the historical service response records comprise information of tasks to be processed in each time period and hardware resource operation information;
and generating the corresponding relation between the thread starting upper limit and the time information based on the historical service response record.
4. The adjusting method according to claim 1, wherein the extracting the tasks to be processed matching the thread starting number from the task library to be processed based on the priority of each task to be processed comprises:
respectively judging whether each task to be processed is effective or not according to the maximum waiting time of each task to be processed and the task sending time;
if the task to be processed is invalid, deleting the task to be processed from the task library to be processed, and returning service timeout information to the client corresponding to the task to be processed;
and if the task to be processed is effective, adjusting the priority of the task to be processed based on the remaining effective duration of the task to be processed.
5. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
inquiring the number of tasks contained in a task library to be processed at preset time intervals;
determining the current thread starting number according to the task number and a preset thread starting upper limit;
extracting the tasks to be processed which are matched with the thread starting number from the task library to be processed based on the priority of each task to be processed;
starting threads corresponding to the thread starting number, and responding to the tasks to be processed through the threads;
determining the current thread starting number according to the task number and a preset thread starting upper limit, and further comprising:
if the number of the tasks is larger than the thread starting upper limit, judging whether a first ratio between the number of the tasks and the thread starting upper limit is larger than a preset up-regulation trigger threshold value or not;
if the first ratio is larger than a preset up-regulation trigger threshold, based on the first ratio, increasing the thread starting upper limit, and selecting the smaller value of the number of tasks and the increased thread starting upper limit as the current thread starting number;
if the number of the tasks is smaller than the thread starting upper limit, judging whether a second ratio between the thread starting upper limit and the number of the tasks is larger than a preset down-regulation trigger threshold value or not;
if the second ratio is larger than a preset down-regulation trigger threshold, based on the second ratio, reducing the thread starting upper limit, and selecting the smaller value of the number of tasks and the reduced thread starting upper limit as the current thread starting number.
6. The terminal device according to claim 5, wherein the determining the current thread starting number according to the task number and a preset thread starting upper limit includes:
acquiring time information of the current moment;
determining a thread starting upper limit corresponding to time information based on a corresponding relation between a preset thread starting upper limit and the time information;
and determining the current thread starting number according to the task number and the thread starting upper limit corresponding to the time information.
7. The terminal device according to claim 6, wherein the processor when executing the computer program further performs the steps of:
acquiring a historical service response record; the historical service response records comprise information of tasks to be processed in each time period and hardware resource operation information;
and generating the corresponding relation between the thread starting upper limit and the time information based on the historical service response record.
8. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 4.
CN201710985525.9A 2017-10-20 2017-10-20 Thread adjusting method and terminal thereof Active CN107832126B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201710985525.9A CN107832126B (en) 2017-10-20 2017-10-20 Thread adjusting method and terminal thereof
PCT/CN2018/077682 WO2019075980A1 (en) 2017-10-20 2018-02-28 Thread adjustment method and terminal thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710985525.9A CN107832126B (en) 2017-10-20 2017-10-20 Thread adjusting method and terminal thereof

Publications (2)

Publication Number Publication Date
CN107832126A CN107832126A (en) 2018-03-23
CN107832126B true CN107832126B (en) 2020-06-12

Family

ID=61648667

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710985525.9A Active CN107832126B (en) 2017-10-20 2017-10-20 Thread adjusting method and terminal thereof

Country Status (2)

Country Link
CN (1) CN107832126B (en)
WO (1) WO2019075980A1 (en)

Families Citing this family (26)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110413419A (en) * 2018-04-28 2019-11-05 北京京东尚科信息技术有限公司 A kind of method and apparatus that rule executes
CN108710538B (en) * 2018-05-14 2023-06-02 中国平安人寿保险股份有限公司 Thread configuration method, computer readable storage medium and terminal equipment
CN109086132A (en) * 2018-06-26 2018-12-25 深圳市买买提信息科技有限公司 A kind of recognition of face task balance call method, device and terminal device
CN109254835A (en) * 2018-06-27 2019-01-22 阿里巴巴集团控股有限公司 Processing method, device, server and the readable storage medium storing program for executing of batch processing task
CN109063140A (en) * 2018-08-03 2018-12-21 福州麦辽自动化设备有限公司 A kind of data query method, transfer server and computer readable storage medium
CN109189336A (en) * 2018-08-17 2019-01-11 郑州云海信息技术有限公司 A kind of storage system thread method of adjustment, system and electronic equipment and storage medium
CN109271252B (en) * 2018-08-29 2021-07-16 华为技术有限公司 Method and device for adjusting thread number
CN109544015B (en) * 2018-11-26 2023-07-25 平安科技(深圳)有限公司 Task allocation method based on data processing and related equipment
CN111262894B (en) * 2018-11-30 2023-06-20 北京嘀嘀无限科技发展有限公司 Method and device for controlling online consultation user quantity
CN109815007A (en) * 2018-12-15 2019-05-28 平安科技(深圳)有限公司 Thread control method, device, electronic equipment and storage medium based on cloud monitoring
CN109710402A (en) * 2018-12-17 2019-05-03 平安普惠企业管理有限公司 Method, apparatus, computer equipment and the storage medium of process resource acquisition request
CN111324447B (en) * 2019-06-26 2023-03-28 杭州海康威视系统技术有限公司 Thread adjusting method and device, application server and storage medium
CN110287018B (en) * 2019-07-04 2021-08-13 中国工商银行股份有限公司 Batch task arranging method and device
CN111415725B (en) * 2020-03-05 2023-09-26 北京深睿博联科技有限责任公司 Scheduling method, system, terminal and storage medium applied to AI medical image diagnosis algorithm
CN111552567B (en) * 2020-04-27 2023-07-07 北京奇艺世纪科技有限公司 Thread management method and device, electronic equipment and storage medium
CN112991095A (en) * 2020-06-16 2021-06-18 洪江川 Artificial intelligence and big data information analysis method and cloud computing platform
CN112000446A (en) * 2020-07-13 2020-11-27 深圳市优必选科技股份有限公司 Data transmission method and robot
CN111782378B (en) * 2020-07-29 2024-04-16 平安银行股份有限公司 Adaptive processing performance adjustment method, server and readable storage medium
CN112069367A (en) * 2020-09-07 2020-12-11 上海金仕达软件科技有限公司 Task scheduling method and system
CN112153060A (en) * 2020-09-27 2020-12-29 苏州浪潮智能科技有限公司 Communication control method and system of SMB protocol server and related components
CN113222456B (en) * 2021-05-29 2023-05-05 长沙市到家悠享家政服务有限公司 Task processing method, system, electronic device and computer readable medium
CN113568737B (en) * 2021-06-30 2024-03-26 北京达佳互联信息技术有限公司 Hardware resource allocation method and device
CN113885956B (en) * 2021-09-29 2023-08-29 北京百度网讯科技有限公司 Service deployment method and device, electronic equipment and storage medium
CN113886185B (en) * 2021-10-16 2023-07-11 深圳市瑞云科技有限公司 Method for automatically judging busy state of platform
CN116755869B (en) * 2023-08-23 2023-10-27 北京浩然五洲软件技术有限公司 Financial business part processing method, system and medium
CN117453363A (en) * 2023-11-06 2024-01-26 北京明朝万达科技股份有限公司 Accessory processing method and device, electronic equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8136113B2 (en) * 2006-12-20 2012-03-13 International Business Machines Corporation Method and apparatus for adjusting sleep time of fixed high-priority threads
CN102779062A (en) * 2011-05-09 2012-11-14 阿里巴巴集团控股有限公司 Method and device for controlling number of threads accessing system resources
CN104572277B (en) * 2014-12-17 2018-04-27 大唐移动通信设备有限公司 A kind of thread flow control method and device
CN106952163B (en) * 2016-01-07 2021-04-13 平安科技(深圳)有限公司 Insurance data processing method and system

Also Published As

Publication number Publication date
WO2019075980A1 (en) 2019-04-25
CN107832126A (en) 2018-03-23

Similar Documents

Publication Publication Date Title
CN107832126B (en) Thread adjusting method and terminal thereof
CN108683720B (en) Container cluster service configuration method and device
CN110597858A (en) Task data processing method and device, computer equipment and storage medium
CN107819797B (en) Access request processing method and device
US11132229B2 (en) Method, storage medium storing instructions, and apparatus for implementing hardware resource allocation according to user-requested resource quantity
CN111858055B (en) Task processing method, server and storage medium
CN109151512A (en) The method and device of content is obtained in CDN network
CN110308985B (en) Cloud exclusive server resource management method, device, equipment and storage medium
CN103095824A (en) File uploading control method and system
CN107784085B (en) Data list exporting method and terminal thereof
US11102145B2 (en) Resource sharing method, computer device, and storage medium
CN108388409B (en) Print request processing method, apparatus, computer device and storage medium
CN108520401B (en) User list management method, device, platform and storage medium
CN110909978A (en) Resource processing method, device, server and computer readable storage medium
CN107193749B (en) Test method, device and equipment
CN111159131A (en) Performance optimization method, device, equipment and computer readable storage medium
CN112632363A (en) Method, device and equipment for processing batch query requests and readable storage medium
CN110347546B (en) Dynamic adjustment method, device, medium and electronic equipment for monitoring task
CN107689979B (en) method and equipment for processing download request
CN111586140A (en) Data interaction method and server
CN115039091A (en) Multi-key-value command processing method and device, electronic equipment and storage medium
CN111294377A (en) Network request sending method of dependency relationship, terminal device and storage medium
CN115454617A (en) Processor performance adjusting method and device, electronic equipment and storage medium
CN115904729A (en) Method, device, system, equipment and medium for connection allocation
CN213876703U (en) Resource pool management system

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