CN113608847A - Task processing method, device, equipment and storage medium - Google Patents

Task processing method, device, equipment and storage medium Download PDF

Info

Publication number
CN113608847A
CN113608847A CN202110853127.8A CN202110853127A CN113608847A CN 113608847 A CN113608847 A CN 113608847A CN 202110853127 A CN202110853127 A CN 202110853127A CN 113608847 A CN113608847 A CN 113608847A
Authority
CN
China
Prior art keywords
processed
task
tasks
available processing
ith
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.)
Pending
Application number
CN202110853127.8A
Other languages
Chinese (zh)
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.)
Shanghai Envision Innovation Intelligent Technology Co Ltd
Envision Digital International Pte Ltd
Original Assignee
Shanghai Envision Innovation Intelligent Technology Co Ltd
Envision Digital International Pte 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 Shanghai Envision Innovation Intelligent Technology Co Ltd, Envision Digital International Pte Ltd filed Critical Shanghai Envision Innovation Intelligent Technology Co Ltd
Priority to CN202110853127.8A priority Critical patent/CN113608847A/en
Publication of CN113608847A publication Critical patent/CN113608847A/en
Pending legal-status Critical Current

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
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques for rebalancing the load in a distributed system

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides a task processing method, a task processing device, a task processing equipment and a storage medium, and relates to the technical field of program design and task processing. The method comprises the following steps: acquiring a plurality of tasks to be processed and a plurality of available processing nodes, wherein the plurality of tasks to be processed are tasks needing to be processed and completed in a target time period; dividing a plurality of tasks to be processed into a plurality of task sets to be processed based on a Hash algorithm, wherein the number of the task sets to be processed is equal to that of available processing nodes; distributing a plurality of task sets to be processed to corresponding available processing nodes, wherein one task set to be processed corresponds to one available processing node in a target time period; and respectively processing the tasks to be processed in the corresponding task sets to be processed by adopting a plurality of available processing nodes. By adopting the technical scheme provided by the embodiment of the application, the load balance of the distributed system can be improved.

Description

Task processing method, device, equipment and storage medium
Technical Field
The embodiment of the application relates to the technical field of program design and task processing, in particular to a task processing method, a device, equipment and a storage medium.
Background
The distributed system technology is a task processing technology which is frequently adopted in high-concurrency scenes and is applied to the current Internet enterprises.
In the related art, a preemptive task processing scheme is adopted, and after the preemption starting time is reached, each node immediately preempts and processes a task. However, in the above related art, because the clocks of the nodes have slight deviations, the time of the clocks in some nodes is faster than the time of the clocks in other nodes, so even if the time for starting preemption of the tasks is preset, it is practically impossible to realize that the nodes start to preempt the tasks at the same time, which inevitably results in excessive tasks preempted by some nodes, less or no preemption of other nodes, and further causes load imbalance of the distributed system.
Disclosure of Invention
The embodiment of the application provides a task processing method, a task processing device and a task processing storage medium, and load balance of a distributed system can be improved. The technical scheme is as follows:
according to an aspect of an embodiment of the present application, there is provided a task processing method, including:
acquiring a plurality of tasks to be processed and a plurality of available processing nodes, wherein the tasks to be processed are tasks needing to be processed and completed in a target period;
dividing the plurality of tasks to be processed into a plurality of task sets to be processed based on a hash algorithm, wherein the number of the task sets to be processed is equal to the number of the available processing nodes;
distributing the plurality of task sets to be processed to corresponding available processing nodes, wherein one task set to be processed corresponds to one available processing node in the target time period;
and respectively processing the tasks to be processed in the corresponding task sets to be processed by adopting the plurality of available processing nodes.
According to an aspect of an embodiment of the present application, there is provided a task processing apparatus, including:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a plurality of tasks to be processed and a plurality of available processing nodes, and the plurality of tasks to be processed are tasks which need to be processed and completed in a target period;
the task dividing module is used for dividing the plurality of tasks to be processed into a plurality of task sets to be processed based on a hash algorithm, wherein the number of the task sets to be processed is equal to that of the available processing nodes;
the task allocation module is used for allocating the plurality of task sets to be processed to corresponding available processing nodes, and one task set to be processed corresponds to one available processing node in the target time period;
and the task processing module is used for respectively processing the tasks to be processed in the corresponding task sets to be processed by adopting the plurality of available processing nodes.
According to an aspect of the embodiments of the present application, there is provided a computer device including a processor and a memory, the memory having stored therein a computer program, the computer program being loaded and executed by the processor to implement the above task processing method.
According to an aspect of embodiments of the present application, there is provided a computer-readable storage medium having stored therein a computer program, the computer program being loaded and executed by a processor to implement the above-mentioned task processing method.
According to an aspect of the embodiments of the present application, there is provided a computer program product which is loaded and executed by a processor to implement the above task processing method.
The technical scheme provided by the embodiment of the application can have the following beneficial effects:
the plurality of tasks to be processed are distributed to the plurality of available processing nodes based on the hash algorithm by acquiring the plurality of tasks to be processed and the plurality of available processing nodes, and the number of tasks required to be processed by the plurality of available processing nodes is relatively average due to relatively strong randomness of the hash algorithm, so that the balance of task processing of the distributed system is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
FIG. 1 is a flow diagram of a task processing method provided by an embodiment of the present application;
FIG. 2 is a flowchart of a task processing method according to another embodiment of the present application;
FIG. 3 is a flowchart of a task processing method according to another embodiment of the present application;
FIG. 4 is a block diagram of a task processing device provided in one embodiment of the present application;
FIG. 5 is a block diagram of a task processing device according to another embodiment of the present application;
fig. 6 is a block diagram of a terminal according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of methods consistent with aspects of the present application, as detailed in the appended claims.
According to the method provided by the embodiment of the application, the execution main body of each step can be a computer device, and the computer device refers to an electronic device with data calculation, processing and storage capabilities. The Computer device may be a terminal such as a PC (Personal Computer), a tablet, a smartphone, a wearable device, a smart robot, or the like; or may be a server. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud computing services.
The technical solution of the present application will be described below by means of several embodiments.
Referring to fig. 1, a flowchart of a task processing method according to an embodiment of the present application is shown. In the present embodiment, the method is mainly exemplified by being applied to the computer device described above. The method may include the steps of:
step 101, acquiring a plurality of tasks to be processed and a plurality of available processing nodes.
In some embodiments, the plurality of pending tasks are tasks that need to be processed to completion within the target period of time. That is, the plurality of tasks to be processed can be processed only within the target period, and need to be processed within the target period. The specific start-stop time of the target time period may be set by a relevant technician according to an actual situation, which is not limited in the embodiment of the present application. Optionally, the target period is a target period, the plurality of tasks to be processed are periodic tasks (e.g., CRON (Command Run On) tasks, i.e., a periodic code running task), and the completed tasks need to be processed in the target period. Alternatively, the duration of the target period is 30 seconds, 5 minutes, 15 minutes, 30 minutes, 1 hour, and the like, and the specific duration of the target period may be set by a person skilled in the relevant art according to practical situations, which is not specifically limited in this embodiment of the application. When the period of the periodic task is a continuous period in time, each period has a fixed task to be processed, and the task to be processed in each period (including a plurality of tasks to be processed in the target period) must be processed in the corresponding period and processed in the corresponding period, so that the task cannot be processed in advance or in a delayed manner, which has a high requirement on timeliness of task processing. Alternatively, a plurality of to-be-processed tasks are stored in a storage unit (e.g., a database) in advance, and the plurality of to-be-processed tasks may be acquired from the storage unit.
In some embodiments, a computer device has control of a distributed system (e.g., ZooKeeper, a distributed, open source distributed application coordination service) that includes multiple processing nodes. Optionally, the plurality of processing nodes are independent of each other. The available processing nodes are processing nodes capable of processing a plurality of tasks to be processed in a target time period, and the processing nodes incapable of processing the plurality of tasks to be processed are unavailable nodes. The processing node may be a computer device (e.g., a terminal such as a PC, a smartphone, a tablet computer, a wearable device, or a server), or may be a processor. Optionally, the configuration parameters of the plurality of available processing nodes are the same, so that the task processing capabilities of the available processing nodes are also the same, and therefore, when the to-be-processed task is allocated, the difference of the task processing capabilities of the available processing nodes does not need to be considered, the overall task processing time is saved, and further the task processing efficiency is improved.
It should be noted that the unavailable node may be a damaged node or an undamaged node; when the unavailable node is an undamaged processing node, the unavailable node may be a processing node for processing other tasks besides the plurality of tasks to be processed, which is not specifically limited in the embodiment of the present application.
102, dividing a plurality of tasks to be processed into a plurality of task sets to be processed based on a Hash algorithm.
Optionally, the number of the sets of tasks to be processed is equal to the number of available processing nodes.
In some embodiments, the identifiers corresponding to the multiple to-be-processed tasks are used as inputs, corresponding outputs are obtained based on a hash algorithm, and the multiple to-be-processed tasks are divided into multiple to-be-processed task sets based on the outputs. Optionally, one to-be-processed task corresponds to only one to-be-processed task set, so that the problem of repeated storage or repeated processing of to-be-processed tasks is avoided. Among them, the hash algorithm (also referred to as a hash algorithm) is an algorithm for converting an input of an arbitrary length into an output of a fixed length. In this embodiment, the fixed length output is an integer.
And 103, distributing the plurality of to-be-processed task sets to corresponding available processing nodes.
Optionally, in the target time period, one set of tasks to be processed corresponds to one available processing node. In some embodiments, the configuration parameters of the plurality of available processing nodes are the same, and the plurality of sets of tasks to be processed may be randomly allocated to the respective available processing nodes. In other embodiments, each set of tasks to be processed corresponds to a set identifier, one set identifier corresponds to one available processing node, and a plurality of sets of tasks to be processed are allocated to the available processing nodes corresponding to the set identifiers.
In this embodiment, since one to-be-processed task corresponds to one to-be-processed task set, one to-be-processed task corresponds to one available processing node. The repeated processing of the tasks to be processed by different available processing nodes is avoided, and therefore the waste of processing resources is avoided.
And 104, respectively processing the tasks to be processed in the corresponding task sets to be processed by adopting a plurality of available processing nodes.
In some embodiments, for an available processing node, all the pending tasks in the pending task set corresponding to the available processing node are processed within the target time period. Optionally, an identification character string (e.g., task _ id _202006301530) is generated for the to-be-processed task in the to-be-processed task set, and is written into a redis (a database) by a redis setnx (redis command reference) instruction, and a timeout time is set for a key (password) of the to-be-processed task, and the to-be-processed task is executed only if the execution of the redis command is successful. The timeout period may be 5 minutes, 15 minutes, 30 minutes, 1 hour, etc., and the specific duration of the timeout period is set by a person skilled in the relevant art according to practical situations, which is not specifically limited in this embodiment of the application.
To sum up, in the technical scheme provided in the embodiment of the present application, by obtaining a plurality of to-be-processed tasks and a plurality of available processing nodes, the plurality of to-be-processed tasks are allocated to the plurality of available processing nodes based on the hash algorithm, and because the randomness of the hash algorithm is strong, the number of tasks required to be processed by the plurality of available processing nodes is relatively average, so that the balance of task processing of the distributed system is improved.
Referring to fig. 2, a flowchart of a task processing method according to another embodiment of the present application is shown. In the present embodiment, the method is mainly exemplified by being applied to the computer device described above. The method comprises the following steps (201-209):
step 201, a plurality of tasks to be processed and a plurality of available processing nodes are obtained.
This step 201 is the same as or similar to the content of step 101 in the embodiment of fig. 1, and is not described herein again.
At step 202, a plurality of available processing nodes are numbered.
Optionally, the numbers of the plurality of available processing nodes are incremented from 0, and the difference between the numbers of two available processing nodes adjacent in number is 1. In some embodiments, the number of each of the plurality of available processing nodes is: 0. 1, 2, 3 … … are integers greater than or equal to 0. In other embodiments, the available processing nodes are respectively numbered as: a. b, c, d, e, and f … …, it should be noted that the available processing nodes may also be numbered in other manners, and this is not particularly limited in this embodiment of the present application.
Step 203, for the ith to-be-processed task of the multiple to-be-processed tasks, acquiring an integer corresponding to the ith to-be-processed task based on a hash algorithm, wherein i is a positive integer.
In some embodiments, this step 203 further comprises the sub-steps of:
1. acquiring an identifier corresponding to the ith task to be processed;
2. and processing the identifier corresponding to the ith task to be processed by adopting a hash algorithm to obtain an integer corresponding to the ith task to be processed.
In some embodiments, for the ith task to be processed, the identifier corresponding to the ith task to be processed is input into a hash algorithm, and a hash corresponding to the ith task to be processed output by the hash algorithm is obtained and is a random positive integer.
And 204, based on the number of the available processing nodes, performing remainder calculation on the integer corresponding to the ith task to be processed to obtain a remainder corresponding to the ith task to be processed.
In some embodiments, the integer corresponding to the ith to-be-processed task is divided by the number of available processing nodes to obtain a remainder corresponding to the ith to-be-processed task. Obviously, the remainder corresponding to the ith to-be-processed task is a positive integer greater than or equal to 0, and the remainder corresponding to the ith to-be-processed task is smaller than the number of available processing nodes.
And step 205, dividing the ith task to be processed into corresponding task sets to be processed according to the remainder corresponding to the ith task to be processed.
Optionally, a set of to-be-processed tasks corresponding to the ith to-be-processed task is determined according to a remainder corresponding to the ith to-be-processed task, that is, an available processing node corresponding to the ith to-be-processed task is determined.
In some embodiments, in response to that the remainder corresponding to the ith to-be-processed task matches the number of the jth available processing node, the ith to-be-processed task is divided into a to-be-processed task set corresponding to the jth available processing node, where j is a positive integer.
In one example, the Identifier of the to-be-processed task is a UUID (Universally Unique Identifier), and the UUIDs corresponding to the 3 to-be-processed tasks are as shown in table 1 below:
TABLE 1
Pending task UUID
Pending task 1 eeb7a6d6-ed09-5891-b4a1-c03ad3220302
Pending task 2 7cd8583b-1a02-5ae6-bd5b-b762d0b86f4a
Task to be processed 3 1877d37e-4c4c-5589-9f4c-d2c44f3e508b
Optionally, the number of available nodes is 3. Inputting UUIDs corresponding to the 3 to-be-processed tasks into a hash algorithm, outputting integers corresponding to the 3 to-be-processed tasks, and obtaining the remainder corresponding to the 3 to-be-processed tasks by adding the integers corresponding to the 3 to-be-processed tasks to 3. Referring to table 2 below, if the remainder corresponding to the task to be processed is 2, the corresponding available processing node is the available processing node numbered 2; if the remainder corresponding to the task to be processed is 1, the corresponding available processing node is the available processing node with the number of 1; if the remainder corresponding to the task to be processed is 0, the corresponding available processing node is the available processing node with the number of 0.
TABLE 2
Available processing node (number of available nodes)
Available processing node 1 (3,2) Available processing node numbered 2
Available processing node 2 (3,1) Available processing node numbered 1
Available processing node 3 (3,0) Available processing node numbered 0
And step 206, distributing the plurality of to-be-processed task sets to corresponding available processing nodes.
This step 206 is the same as or similar to the content of step 103 in the embodiment of fig. 1, and is not described here again.
And step 207, respectively processing the tasks to be processed in the corresponding task sets to be processed by adopting a plurality of available processing nodes.
This step 207 is the same as or similar to the content of step 104 in the embodiment of fig. 1, and is not repeated here.
And step 208, detecting whether the task to be processed still exists at the target moment in the target time period.
In some embodiments, the target time is a preset time within the target time period, that is, whether the task to be processed still exists is detected at a certain determined time within the target time period. In other embodiments, when all available processing nodes are in an idle state (an idle state may refer to a state where no task processing is performed), it is detected whether there are still pending tasks.
And step 209, if the task to be processed still exists, processing the task to be processed by adopting a preemptive processing mode.
In some embodiments, if there is an unallocated task to be processed or there is a task to be processed that is not processed due to an exception occurring in an available processing node, the task to be processed is processed and completed in a preemptive processing manner. Optionally, the preemptive processing means is: if a missing task to be processed is found, the available processing nodes in the idle state contend for the missing task to be processed and process the task.
In some possible implementations, if one or some of the available processing nodes are abnormal (i.e., down), or an available processing node is newly added, the number of available processing nodes may change. For example, if one available processing node is abnormal and cannot continue processing the task to be processed, the number of the available processing nodes is correspondingly reduced by one. Accordingly, the number of each available processing node may also vary as the number of available nodes varies.
To sum up, in the technical scheme provided by the embodiment of the application, based on the hash algorithm, the task to be processed is distributed in a surplus mode, so that the task distribution can be conveniently, quickly and accurately realized for any number of available nodes, the problem of uneven task distribution caused by the change of the number of the available nodes is avoided, and the load balance of the distributed system is further improved.
Next, a task processing method according to another embodiment of the present application is summarized and described with reference to fig. 3. As shown in FIG. 3, the method comprises the following steps (301-308):
301, generating identifiers corresponding to a plurality of tasks to be processed respectively, and registering a plurality of processing nodes in a distributed system;
step 302, triggering a distributed system to start processing a plurality of tasks to be processed;
303, acquiring a plurality of available processing nodes from a plurality of processing nodes of the distributed system;
step 304, determining numbers corresponding to a plurality of available processing nodes respectively;
step 305, obtaining a list of a plurality of tasks to be processed from a database;
step 306, for the ith to-be-processed task, performing remainder taking processing based on a hash algorithm, and judging whether a remainder corresponding to the ith to-be-processed task is matched with the jth available processing node, if so, executing step 307; if not, continuing to execute step 306 for the next task to be processed;
307, distributing the ith task to be processed to the jth available processing node, processing the ith task, and continuing to execute step 306;
and step 308, processing the missing task to be processed.
The following are embodiments of the apparatus of the present application that may be used to perform embodiments of the method of the present application. For details which are not disclosed in the embodiments of the apparatus of the present application, reference is made to the embodiments of the method of the present application.
Referring to fig. 4, a block diagram of a task processing device according to an embodiment of the present application is shown. The device has the functions of realizing the example of the task processing method, and the functions can be realized by hardware or by hardware executing corresponding software. The device may be the computer device described above, or may be provided on a computer device. The apparatus 400 may include: a first obtaining module 410, a task dividing module 420, a task allocating module 430, and a task processing module 440.
The first obtaining module 410 is configured to obtain a plurality of tasks to be processed, which are tasks that need to be processed within a target time period to be completed, and a plurality of available processing nodes.
The task dividing module 420 is configured to divide the multiple tasks to be processed into multiple task sets to be processed based on a hash algorithm, where the number of the task sets to be processed is equal to the number of the available processing nodes.
The task allocation module 430 is configured to allocate the multiple sets of tasks to be processed to corresponding available processing nodes, where in the target time period, one set of tasks to be processed corresponds to one available processing node.
The task processing module 440 is configured to use the multiple available processing nodes to process the to-be-processed tasks in the corresponding to-be-processed task sets respectively.
To sum up, in the technical scheme provided in the embodiment of the present application, by obtaining a plurality of to-be-processed tasks and a plurality of available processing nodes, the plurality of to-be-processed tasks are allocated to the plurality of available processing nodes based on the hash algorithm, and because the randomness of the hash algorithm is strong, the number of tasks required to be processed by the plurality of available processing nodes is relatively average, so that the balance of task processing of the distributed system is improved.
In an exemplary embodiment, the target period is a target period, and the plurality of tasks to be processed are periodic tasks, and tasks that need to be processed in the target period are completed in the target period.
In an exemplary embodiment, as shown in fig. 5, the task division module 420 includes: an integer obtaining submodule 421, a remainder calculating submodule 422, and a task dividing submodule 423.
The integer obtaining submodule 421 is configured to, for an ith to-be-processed task of the to-be-processed tasks, obtain an integer corresponding to the ith to-be-processed task based on the hash algorithm, where i is a positive integer.
The remainder calculation submodule 422 is configured to perform remainder calculation on the integer corresponding to the ith to-be-processed task based on the number of the available processing nodes, so as to obtain a remainder corresponding to the ith to-be-processed task.
The task dividing submodule 423 is configured to divide the ith task to be processed into a corresponding task set to be processed according to a remainder corresponding to the ith task to be processed.
In an exemplary embodiment, as shown in FIG. 5, said method, as shown in FIG. 5, is for:
acquiring an identifier corresponding to the ith task to be processed;
and processing the identifier corresponding to the ith task to be processed by adopting the hash algorithm to obtain an integer corresponding to the ith task to be processed.
In an exemplary embodiment, as shown in fig. 5, the apparatus 400 comprises: node numbering module 450.
The node numbering module 450 is configured to number the available processing nodes, where the numbers of the available processing nodes are incremented from 0, and a difference between the numbers of two adjacent processing nodes is 1.
In an exemplary embodiment, as shown in fig. 5, the task dividing sub-module 423 is configured to divide the ith to-be-processed task into a to-be-processed task set corresponding to a jth available processing node in response to a match between a remainder corresponding to the ith to-be-processed task and a number of the jth available processing node, where j is a positive integer.
In an exemplary embodiment, the configuration parameters of the plurality of available processing nodes are the same.
In an exemplary embodiment, as shown in fig. 5, the apparatus 400 comprises: task detection module 460.
The task detection module 460 is configured to detect whether the to-be-processed task still exists at a target time within the target time period.
The task processing module 440 is further configured to complete the processing of the to-be-processed task by using a preemptive processing manner if the to-be-processed task still exists.
It should be noted that, when the apparatus provided in the foregoing embodiment implements the functions thereof, only the division of the functional modules is illustrated, and in practical applications, the functions may be distributed by different functional modules according to needs, that is, the internal structure of the apparatus may be divided into different functional modules to implement all or part of the functions described above. In addition, the apparatus and method embodiments provided by the above embodiments belong to the same concept, and specific implementation processes thereof are described in the method embodiments for details, which are not described herein again.
Referring to fig. 6, a block diagram of a computer device according to an embodiment of the present application is shown. The computer device is used for implementing the task processing method provided in the above embodiment. Specifically, the method comprises the following steps:
the computer apparatus 600 includes a CPU (Central Processing Unit) 601, a system Memory 604 including a RAM (Random Access Memory) 602 and a ROM (Read-Only Memory) 603, and a system bus 605 connecting the system Memory 604 and the Central Processing Unit 601. The computer device 600 also includes a basic I/O (Input/Output) system 606 to facilitate information transfer between various elements within the computer, and a mass storage device 607 for storing an operating system 613, application programs 614, and other program modules 615.
The basic input/output system 606 includes a display 608 for displaying information and an input device 609 such as a mouse, keyboard, etc. for a user to input information. Wherein the display 608 and the input device 609 are connected to the central processing unit 601 through an input output controller 610 connected to the system bus 605. The basic input/output system 606 may also include an input/output controller 610 for receiving and processing input from a number of other devices, such as a keyboard, mouse, or electronic stylus. Similarly, input/output controller 610 may also provide output to a display screen, a printer, or other type of output device.
The mass storage device 607 is connected to the central processing unit 601 through a mass storage controller (not shown) connected to the system bus 605. The mass storage device 607 and its associated computer-readable media provide non-volatile storage for the computer device 600. That is, the mass storage device 607 may include a computer-readable medium (not shown) such as a hard disk or a CD-ROM (Compact disk Read-Only Memory) drive.
Without loss of generality, the computer-readable media may comprise computer storage media and communication media. Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes RAM, ROM, EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash Memory or other solid state Memory technology, CD-ROM, DVD (Digital Video Disc) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices. Of course, those skilled in the art will appreciate that the computer storage media is not limited to the foregoing. The system memory 604 and mass storage device 607 described above may be collectively referred to as memory.
According to various embodiments of the present application, the computer device 600 may also operate as a remote computer connected to a network via a network, such as the Internet. That is, the computer device 600 may be connected to the network 612 through the network interface unit 611 connected to the system bus 605, or may be connected to other types of networks or remote computer systems (not shown) using the network interface unit 611.
In an exemplary embodiment, there is also provided a computer-readable storage medium having stored therein a computer program which, when executed by a processor, implements the above-described task processing method.
In an exemplary embodiment, a computer program product for implementing the above task processing method when executed by a processor is also provided.
It should be understood that reference to "a plurality" herein means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The above description is only exemplary of the present application and should not be taken as limiting the present application, and any modifications, equivalents, improvements and the like that are made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (10)

1. A method for processing a task, the method comprising:
acquiring a plurality of tasks to be processed and a plurality of available processing nodes, wherein the tasks to be processed are tasks needing to be processed and completed in a target period;
dividing the plurality of tasks to be processed into a plurality of task sets to be processed based on a Hash algorithm, wherein the number of the task sets to be processed is equal to that of the available processing nodes;
distributing the plurality of task sets to be processed to corresponding available processing nodes, wherein one task set to be processed corresponds to one available processing node in the target time period;
and respectively processing the tasks to be processed in the corresponding task sets to be processed by adopting the plurality of available processing nodes.
2. The method of claim 1, wherein the target period is a target period, and the plurality of tasks to be processed are periodic tasks, and completed tasks are required to be processed in the target period.
3. The method according to claim 1, wherein the dividing the plurality of tasks to be processed into a plurality of sets of tasks to be processed based on a hash algorithm comprises:
for the ith task to be processed in the plurality of tasks to be processed, acquiring an integer corresponding to the ith task to be processed based on the hash algorithm, wherein i is a positive integer;
based on the number of the available processing nodes, performing remainder calculation on the integer corresponding to the ith task to be processed to obtain a remainder corresponding to the ith task to be processed;
and dividing the ith task to be processed into corresponding task sets to be processed according to the remainder corresponding to the ith task to be processed.
4. The method according to claim 3, wherein the obtaining, for an ith to-be-processed task of the to-be-processed tasks, an integer corresponding to the ith to-be-processed task based on a hash algorithm includes:
acquiring an identifier corresponding to the ith task to be processed;
and processing the identifier corresponding to the ith task to be processed by adopting the hash algorithm to obtain an integer corresponding to the ith task to be processed.
5. The method of claim 3, wherein after obtaining the plurality of available processing nodes, further comprising:
numbering the plurality of available processing nodes, wherein the numbering of the plurality of available processing nodes is increased from 0, and the difference value of the numbering of two adjacent available processing nodes is 1;
the dividing the ith task to be processed into corresponding task sets to be processed according to the remainder corresponding to the ith task to be processed includes:
and in response to the fact that the remainder corresponding to the ith task to be processed is matched with the number of the jth available processing node, dividing the ith task to be processed into a task set to be processed corresponding to the jth available processing node, wherein j is a positive integer.
6. The method according to any of claims 1 to 5, wherein the configuration parameters of the plurality of available processing nodes are the same.
7. The method according to any one of claims 1 to 5, wherein after the respectively processing tasks in the corresponding to-be-processed task sets by using the plurality of available processing nodes, the method further comprises:
detecting whether the task to be processed still exists at a target moment in the target time period;
and if the task to be processed still exists, finishing the processing of the task to be processed by adopting a preemptive processing mode.
8. A task processing apparatus, characterized in that the apparatus comprises:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a plurality of tasks to be processed and a plurality of available processing nodes, and the plurality of tasks to be processed are tasks which need to be processed and completed in a target period;
the task dividing module is used for dividing the plurality of tasks to be processed into a plurality of task sets to be processed based on a hash algorithm, wherein the number of the task sets to be processed is equal to that of the available processing nodes;
the task allocation module is used for allocating the plurality of task sets to be processed to corresponding available processing nodes, and one task set to be processed corresponds to one available processing node in the target time period;
and the task processing module is used for respectively processing the tasks to be processed in the corresponding task sets to be processed by adopting the plurality of available processing nodes.
9. A computer device, characterized in that the computer device comprises a processor and a memory, in which a computer program is stored, which computer program is loaded and executed by the processor to implement the task processing method according to any of the claims 1 to 7.
10. A computer-readable storage medium, in which a computer program is stored, which is loaded and executed by a processor to implement the task processing method according to any one of claims 1 to 7.
CN202110853127.8A 2021-07-27 2021-07-27 Task processing method, device, equipment and storage medium Pending CN113608847A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110853127.8A CN113608847A (en) 2021-07-27 2021-07-27 Task processing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110853127.8A CN113608847A (en) 2021-07-27 2021-07-27 Task processing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113608847A true CN113608847A (en) 2021-11-05

Family

ID=78305669

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110853127.8A Pending CN113608847A (en) 2021-07-27 2021-07-27 Task processing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113608847A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114969444A (en) * 2022-05-24 2022-08-30 北京百度网讯科技有限公司 Data processing method and device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109144690A (en) * 2018-07-06 2019-01-04 麒麟合盛网络技术股份有限公司 task processing method and device
CN110633135A (en) * 2019-08-15 2019-12-31 中国平安财产保险股份有限公司 Asynchronous task allocation method and device, computer equipment and storage medium
CN111190710A (en) * 2019-11-25 2020-05-22 泰康保险集团股份有限公司 Task allocation method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109144690A (en) * 2018-07-06 2019-01-04 麒麟合盛网络技术股份有限公司 task processing method and device
CN110633135A (en) * 2019-08-15 2019-12-31 中国平安财产保险股份有限公司 Asynchronous task allocation method and device, computer equipment and storage medium
CN111190710A (en) * 2019-11-25 2020-05-22 泰康保险集团股份有限公司 Task allocation method and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114969444A (en) * 2022-05-24 2022-08-30 北京百度网讯科技有限公司 Data processing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
Shah et al. The MDS queue: Analysing the latency performance of erasure codes
CN108595157B (en) Block chain data processing method, device, equipment and storage medium
CN108462760B (en) Electronic device, automatic cluster access domain name generation method and storage medium
CN112035258A (en) Data processing method, device, electronic equipment and medium
US9838332B1 (en) Dynamically meeting slas without provisioning static capacity
CN111988419A (en) File uploading method, file downloading method, file uploading device, file downloading device, computer equipment and storage medium
CN112231108A (en) Task processing method and device, computer readable storage medium and server
CN111949406A (en) Numbering resource allocation processing method and device, computer and storage medium
CN113608847A (en) Task processing method, device, equipment and storage medium
CN111277626B (en) Server upgrading method and device, electronic equipment and medium
EP4006725A1 (en) Virtual machine migration processing and strategy generation method, apparatus and device, and storage medium
CN112181599A (en) Model training method, device and storage medium
CN111988429A (en) Algorithm scheduling method and system
CN110968406B (en) Method, device, storage medium and processor for processing task
CN113051245A (en) Method, device and system for migrating data
CN115629853A (en) Task scheduling method and device
CN112685157B (en) Task processing method, device, computer equipment and storage medium
CN112398892B (en) Service distribution method, device and equipment
CN109614242B (en) Computing capacity sharing method, device, equipment and medium
CN110391929B (en) Fault-tolerant control method and device and fault-tolerant component
CN110633142B (en) Block chain consensus method, management node, electronic device, and storage medium
CN104572036B (en) Event processing method and device
GB2504812A (en) Load balancing in a SAP (RTM) system for processors allocated to data intervals based on system load
CN112446754A (en) Method and device for processing orders
CN111708812A (en) Distributed data processing method

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