Disclosure of Invention
The application aims to provide a task processing method which can finely control tasks under the condition of limited network resources and server resources, improve the utilization rate of the network resources and the server resources and reduce the cost. Another object of the present application is to provide a task processing device, apparatus, and computer-readable storage medium, each having the above technical effects.
In order to solve the technical problems, the application provides a task processing method, which comprises the following steps:
acquiring execution parameters of each task from a task list, wherein the execution parameters at least comprise server resource consumption and network resource consumption;
according to the execution parameters corresponding to the tasks, respectively calculating the execution sequence and the execution probability of each task;
determining a target task according to the execution sequence and the execution probability;
And concurrently executing the target tasks.
Optionally, the execution parameters further include task time consumption and task priority.
Optionally, the calculating the execution sequence of each task according to the execution parameters corresponding to the task includes:
According to the server resource consumption, the network resource consumption, the task time consumption, the task priority and a preset functional relation, respectively calculating to obtain the sequence value of each task;
and sequencing the tasks according to the sequence values to obtain the execution sequence of the tasks.
Optionally, the calculating the execution probability of each task according to the execution parameters corresponding to the task includes:
According to the server resource consumption corresponding to the task and a first preset condition constraint, calculating to obtain a first execution probability of executing the task by the current server;
And calculating a second execution probability of executing the task by the current server according to the network resource consumption corresponding to the task and a second preset condition constraint.
Optionally, the determining the target task according to the execution sequence and the execution probability:
obtaining a first number according to the first execution probability;
Obtaining a second number according to the second execution probability;
comparing the first number to the second number;
If the first number is larger than the second number, selecting the second number of tasks from the tasks according to the execution sequence as the target task;
And if the first number is smaller than or equal to the second number, selecting the tasks with the first number from the tasks according to the execution sequence as the target tasks.
Optionally, the method further comprises:
After the task is executed, counting task time consumption, server resource consumption and network resource consumption when the task is executed;
and recording the task time consumption, the server resource consumption and the network resource consumption when the task is executed into a historical task list.
Optionally, the method further comprises:
Calculating the average value of the server resource consumption of the task and the average value of the network resource consumption of the task in the historical task list by taking a preset duration as a unit;
and updating the average value of the server resource consumption and the average value of the network resource consumption into the task list.
In order to solve the technical problem, the present application further provides a task processing device, including:
The system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring execution parameters of each task from a task list, and the execution parameters at least comprise server resource consumption and network resource consumption;
The calculation module is used for respectively calculating the execution sequence and the execution probability of each task according to the execution parameters corresponding to the tasks;
The determining module is used for determining a target task according to the execution sequence and the execution probability;
And the execution module is used for concurrently executing the target task.
In order to solve the technical problem, the present application further provides a task processing device, including:
a memory for storing a computer program;
A processor for implementing the steps of the task processing method as claimed in any one of the preceding claims when executing the computer program.
To solve the above technical problem, the present application also provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, implements the steps of the task processing method as described in any one of the above.
The task processing method comprises the steps of obtaining execution parameters of each task from a task list, wherein the execution parameters at least comprise server resource consumption and network resource consumption, respectively calculating to obtain execution sequence and execution probability of each task according to the execution parameters corresponding to the tasks, determining a target task according to the execution sequence and the execution probability, and concurrently executing the target task.
Therefore, the task processing method provided by the application determines the task to be executed, namely the target task based on the server resource consumption and the network resource consumption of the task, and further executes each target task concurrently, so that the task can be finely managed and controlled under the condition of limited server resources and network resources, the utilization rate of the network resources and the server resources is improved, and the cost is reduced.
The task processing device, the equipment and the computer readable storage medium provided by the application have the technical effects.
Detailed Description
The core of the application is to provide a task processing method, which can finely control tasks under the condition of limited network resources and server resources, improve the utilization rate of the network resources and the server resources and reduce the cost. Another core of the present application is to provide a task processing device, apparatus, and computer-readable storage medium, which all have the above technical effects.
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Referring to fig. 1, fig. 1 is a flow chart of a task processing method according to an embodiment of the present application, and referring to fig. 1, the method mainly includes:
s101, acquiring execution parameters of each task from a task list, wherein the execution parameters at least comprise server resource consumption and network resource consumption;
Specifically, a task list is created, and the task list includes a task number field, a name field, a task time consumption field, a server resource consumption field, a network resource consumption field, and a task priority field. In addition, a historical task list is created, the historical task list including a task number field, a task time consuming field, a server resource consumption field, and a network resource consumption field. The task number, name, task time consumption, server resource consumption, network resource consumption, and task priority (the higher the level of task priority, the smaller the value of task priority) are entered into the task list. If the task is recorded for the first time and never runs, the estimated task time consumption, the estimated server resource consumption and the estimated network resource consumption of the task are recorded into a task list.
Based on creating a task list and inputting a task number, a name, task time consumption, server resource consumption and the like, at least obtaining the server resource consumption and the network resource consumption of each task from the task list so as to execute subsequent steps according to the server resource consumption and the network resource consumption of the task.
The server resources may include CPU resources, memory resources, hard disk resources, and the like. Network resources may include network bandwidth and traffic. Server resource consumption refers to how much server resources are consumed to perform a task, and network resource consumption refers to how much network resources are consumed to perform a task.
In a specific embodiment, the execution parameters further comprise task time consumption and task priority.
Specifically, in this embodiment, besides the server resource consumption and the network resource consumption of the task, the task time consumption and the task priority of the task are also obtained, and further, the subsequent steps are executed based on the server resource consumption, the network resource consumption, the task time consumption and the task priority of the task.
S102, respectively calculating the execution sequence and the execution probability of each task according to the execution parameters corresponding to the tasks;
on the basis of acquiring the execution parameters corresponding to each task, further, the execution sequence and the execution probability of each task are respectively calculated according to the acquired execution parameters.
In a specific embodiment, the manner of calculating the execution sequence of each task according to the execution parameters corresponding to the task may be:
According to the server resource consumption, the network resource consumption, the task time consumption, the task priority and a preset functional relation, respectively calculating to obtain the sequence value of each task;
and sequencing the tasks according to the sequence values to obtain the execution sequence of the tasks.
The preset functional relationship can be set differently, which is not limited by the present application. For example, the preset functional relationship may be that O j=αTj+βSj+γNj+δPj;Oj represents the order value, T j represents the task time consumption, S j represents the server resource consumption, N j represents the network resource consumption, P j represents the task priority, subscript j represents the task number, and α, β, γ, and δ all represent weighting coefficients.
Thus, for each task, the order value of the task is calculated according to the functional relation and the task time consumption, the server resource consumption, the network resource signal and the task priority corresponding to the task. Then, the tasks can be ordered according to the order of the order values from small to large, and the execution order of the tasks is obtained. The smaller the order value, the earlier the task ordering. The values of α, β, γ and δ may be 0 to 1, and α+β+γ+δ=1. For specific numerical values of the respective weighting coefficients, differential setting may be performed on the basis of satisfying α+β+γ+δ=1.
In addition, in a specific embodiment, the manner of calculating the execution probability of each task according to the execution parameters corresponding to the task may be:
According to the server resource consumption corresponding to the task and a first preset condition constraint, calculating to obtain a first execution probability of executing the task by the current server;
And calculating a second execution probability of executing the task by the current server according to the network resource consumption corresponding to the task and a second preset condition constraint.
Specifically, according to the server resource consumption corresponding to the task, the specific implementation manner of calculating the first execution probability of the task is as follows:
and initializing the residual server resources of the current server node i as the estimated total server resources of the current server node i by using R i=Si;Si. Solving for A first execution probability X j of the current server node i executing the task with the task number j is obtained. Equation (1) is a first preset condition constraint, and f (j) is a set of all server nodes that satisfy server resources required for a task with a task number j. If the above equation has no solution, the first execution probability X j of the task with the task number j by the current server node i is equal to 1.
Further, solve forAfter obtaining the first execution probability of the task with the task number j, updating the residual server resources of the current server node i in the following updating mode:
According to the network resource consumption corresponding to the task, the specific implementation mode of calculating the second execution probability of the task is as follows:
and initializing the residual network resources of the current server node as the estimated total network resources of the current server node by using M i=Ni Ni. Solving for A second execution probability Y j that the current server node i executes the task with the task number j is obtained. Equation (2) is a second preset condition constraint, and ψ (j) is a set of all server nodes satisfying network resources required for the task with the task number j. If the above equation has no solution, the second execution probability Y j of the task with the task number j by the current server node i is equal to 1.
Further, solve forAfter obtaining the second execution probability of the task with the task number j, updating the residual network resources of the current server node i in the following way:
s103, determining a target task according to the execution sequence and the execution probability;
Specifically, this step is intended to determine the target task. The target task refers to a task that the current server node needs to execute.
In a specific embodiment, the method for determining the target task according to the execution probability may be:
obtaining a first number according to the first execution probability;
Obtaining a second number according to the second execution probability;
comparing the first number to the second number;
If the first number is larger than the second number, selecting the second number of tasks from the tasks according to the execution sequence as the target task;
And if the first number is smaller than or equal to the second number, selecting the tasks with the first number from the tasks according to the execution sequence as the target tasks.
Specifically, for any one of the server nodes i, j= { c 1,c2,…,c|J| } is set as a set of tasks satisfying the above-described formula (1) and the above-described formula (2). c |J| represents a set of one kind of tasks satisfying the above formula (1) and the above formula (2).
If it isThen the calculation is satisfiedI, i.e. the first number. Meanwhile, according to the execution sequence of each task, the execution probability of the (1+1) th task is adjusted to beAt this time, X l+1>X′l+1 is satisfied, and the first execution probability of the (i+1) th task and the tasks arranged after the (i+1) th task is 0.
If it isThen the calculation is satisfiedThe maximum value of k is the second number. Meanwhile, according to the execution sequence of each task, the second execution probability of the (k+1) th task is adjusted to beWhen Y k+1>Y′k+1 is satisfied, the second execution probability of the (k+1) th task and the tasks arranged after the (k+1) th task is 0.
The first number is compared with the second number. If the first number is larger than the second number, selecting the second number of tasks from the tasks according to the execution sequence as the target task; and if the first number is smaller than or equal to the second number, selecting the first number of tasks from the tasks according to the execution sequence as the target task.
And S104, concurrently executing the target task.
Specifically, after determining the target task, that is, the task that needs to be executed by the current server node, the current server node concurrently executes each target task.
Further, on the basis of the above embodiment, as a specific implementation manner, the method further includes:
After the task is executed, counting task time consumption, server resource consumption and network resource consumption when the task is executed;
and recording the task time consumption, the server resource consumption and the network resource consumption when the task is executed into a historical task list.
Further, on the basis of the above embodiment, as a specific implementation manner, the method further includes:
Calculating the average value of the server resource consumption of the task and the average value of the network resource consumption of the task in the historical task list by taking a preset duration as a unit;
and updating the average value of the server resource consumption and the average value of the network resource consumption into the task list.
Specifically, the embodiment sets a function of automatically adjusting the execution parameters in the task list, and by automatically calculating the average value of the server resource consumption of the task and the average value of the network resource consumption of the task in the history task list and updating the average value of the server resource consumption and the average value of the network resource consumption into the task list, the execution parameters in the task list can be more accurate and reliable.
The specific value of the preset duration is not limited only, and the application can be adaptively set according to the actual application requirement.
For example, a preset time period is set for one day, whereby a mean value of the server resource consumption of the task and a mean value of the network resource consumption of the task in the history task list are calculated in units of one day, and the mean value of the server resource consumption and the mean value of the network resource consumption are updated into the task list.
In summary, the task processing method provided by the application comprises the steps of obtaining execution parameters of each task from a task list, wherein the execution parameters at least comprise server resource consumption and network resource consumption, respectively calculating to obtain the execution sequence and the execution probability of each task according to the execution parameters corresponding to the tasks, determining a target task according to the execution sequence and the execution probability, and concurrently executing the target task. Therefore, the task processing method provided by the application determines the task to be executed, namely the target task based on the server resource consumption and the network resource consumption of the task, and further executes each target task concurrently, so that the task can be finely managed and controlled under the condition of limited server resources and network resources, the utilization rate of the network resources and the server resources is improved, and the cost is reduced.
The application also provides a task processing device which can be referred to in the following in correspondence with the method described above. Referring to fig. 2, fig. 2 is a schematic diagram of a task processing device according to an embodiment of the present application, and in combination with fig. 2, the task processing device includes:
The acquisition module 10 is used for acquiring execution parameters of each task from the task list, wherein the execution parameters at least comprise server resource consumption and network resource consumption;
The calculation module 20 is configured to calculate an execution sequence and an execution probability of each task according to the execution parameters corresponding to the tasks;
a determining module 30, configured to determine a target task according to the execution order and the execution probability;
And the execution module 40 is used for concurrently executing the target task.
On the basis of the above embodiment, as a specific implementation manner, the execution parameters further include task time consumption and task priority.
On the basis of the above embodiment, as a specific implementation manner, the calculating module 20 includes:
The computing unit is used for respectively computing the sequence value of each task according to the server resource consumption, the network resource consumption, the task time consumption, the task priority and a preset function relation;
And the sequencing unit is used for sequencing the tasks according to the sequence values to obtain the execution sequence of the tasks.
On the basis of the above embodiment, as a specific implementation manner, the calculating module 20 includes:
The first execution probability calculation unit is used for calculating the first execution probability of executing the task by the current server according to the server resource consumption corresponding to the task and a first preset condition constraint;
And the second execution probability calculation unit is used for calculating the second execution probability of executing the task by the current server according to the network resource consumption corresponding to the task and a second preset condition constraint.
On the basis of the above embodiment, as a specific implementation manner, the determining module 30 includes:
A first number calculation unit, configured to obtain a first number according to the first execution probability;
A second number calculation unit, configured to obtain a second number according to the second execution probability;
A comparison unit for comparing the first number with the second number;
The first determining unit is used for selecting the second number of tasks from the tasks according to the execution sequence as the target tasks if the first number is larger than the second number;
And the second determining unit is used for selecting the first number of tasks from the tasks according to the execution sequence as the target tasks if the first number is smaller than or equal to the second number.
On the basis of the above embodiment, as a specific implementation manner, the method further includes:
the statistics module is used for counting task time consumption, server resource consumption and network resource consumption when the task is executed after the task is executed;
And the recording module is used for recording the task time consumption, the server resource consumption and the network resource consumption in the historical task list when the task is executed.
On the basis of the above embodiment, as a specific implementation manner, the method further includes:
The average value calculation module is used for calculating the average value of the server resource consumption of the task in the historical task list and the average value of the network resource consumption of the task by taking a preset duration as a unit;
And the updating module is used for updating the average value of the server resource consumption and the average value of the network resource consumption into the task list.
The task processing device provided by the application determines the task to be executed, namely the target task based on the server resource consumption and the network resource consumption of the task, and further executes each target task concurrently, so that the task can be finely managed and controlled under the condition of limited server resources and network resources, the utilization rate of the network resources and the server resources is improved, and the cost is reduced.
The application also provides a task processing device comprising a memory 1 and a processor 2, as shown with reference to figure 3.
A memory 1 for storing a computer program;
a processor 2 for executing a computer program to perform the steps of:
the method comprises the steps of obtaining execution parameters of each task from a task list, wherein the execution parameters at least comprise server resource consumption and network resource consumption, respectively calculating to obtain execution sequence and execution probability of each task according to the execution parameters corresponding to the tasks, determining a target task according to the execution sequence and the execution probability, and concurrently executing the target task.
For the description of the apparatus provided by the present application, refer to the above method embodiment, and the description of the present application is omitted herein.
The present application also provides a computer readable storage medium having a computer program stored thereon, which when executed by a processor, performs the steps of:
the method comprises the steps of obtaining execution parameters of each task from a task list, wherein the execution parameters at least comprise server resource consumption and network resource consumption, respectively calculating to obtain execution sequence and execution probability of each task according to the execution parameters corresponding to the tasks, determining a target task according to the execution sequence and the execution probability, and concurrently executing the target task.
The computer readable storage medium may include a U disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk or an optical disk, etc. various media that can store program codes.
For the description of the computer-readable storage medium provided by the present application, refer to the above method embodiments, and the disclosure is not repeated here.
In the description, each embodiment is described in a progressive manner, and each embodiment is mainly described by the differences from other embodiments, so that the same similar parts among the embodiments are mutually referred. For the apparatus, device and computer readable storage medium of the embodiment disclosure, since it corresponds to the method of the embodiment disclosure, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. 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 application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The task processing method, device, equipment and computer readable storage medium provided by the application are described above in detail. The principles and embodiments of the present application have been described herein with reference to specific examples, the description of which is intended only to facilitate an understanding of the method of the present application and its core ideas. It should be noted that it will be apparent to those skilled in the art that various changes and modifications can be made herein without departing from the principles of the application, which are also intended to fall within the scope of the appended claims.