Task Processing Method and Device
By acquiring subtasks in the subtask database and allocating them to multiple cache queues according to the task type, the problem of low task processing efficiency in the prior art is solved, and efficient task processing that can timely handle subtasks when the number of external service requests increases.
Patent Information
- Application Number
- CN202110687095.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-21
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2041-06-21
AI Technical Summary
In the process of task processing, the subtasks are stored in a temporary task queue regularly and quantitatively, resulting in the inability to process more subtasks in the subtask database in time, thus reducing the efficiency of task processing.
Store the subtasks to the target cache queue by obtaining subtasks in the subtask database and determining the target cache queue in multiple cache queues according to the task type of the subtask. Then, according to the priority and subtask type of the cache queue, the subtask is assigned to the corresponding task processing queue to ensure that the task processing queue can obtain and process the subtasks in a timely manner.
Distributing subtasks to multiple cache queues through the subtask database ensures that multiple cache queues can distribute a sufficient number of subtasks to multiple task processing queues, improving the efficiency of task processing, especially when the number of external service requests increases suddenly.
Smart Images

Figure CN113327053B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to automatic control technology, and more particularly to a task processing method and device. Background Art
[0002] In the process of banking business processing, subtasks are usually obtained from the subtask database and distributed to the task queue. Subsequently, external services call the subtasks from the task queue for task processing.
[0003] At present, in the existing technology, the task queue is divided into a temporary task queue and multiple assigned task queues. Usually, a certain number of subtasks are obtained from the subtask database at a regular interval and stored in the temporary task queue according to priority. The subtasks in the temporary task queue are then synchronously assigned to different assigned task queues according to task attributes. Subsequently, the subtasks are called from the assigned task queue through external services for subtask processing.
[0004] However, in the process of task processing in the prior art, due to the timing and quantity of storing subtasks in the subtask database into a temporary task queue, when the subtask database includes a large number of subtasks, the subtasks in the subtask database cannot be stored in the temporary task queue in time, which makes it impossible for external services to process the subtasks in time, thereby resulting in low efficiency of subtask processing. Summary of the invention
[0005] The embodiments of the present application provide a task processing method and device to improve the efficiency of subtask processing.
[0006] In a first aspect, an embodiment of the present application provides a task processing method, which is applied to a business processing system, wherein the business processing system includes a subtask database, multiple cache queues, and multiple task processing queues, including:
[0007] Acquire a subtask in the subtask database, wherein the subtask database includes a plurality of subtasks;
[0008] Determine a target cache queue among the multiple cache queues according to the task type of the task to which the subtask belongs, and store the subtask in the target cache queue;
[0009] Determine the priorities of the multiple cache queues, and assign the subtasks in the multiple cache queues to corresponding task processing queues according to the priorities of the multiple cache queues and the subtask types corresponding to the subtasks in the cache queues;
[0010] For any task processing queue, the subtasks in the task processing queue are processed through the service corresponding to the task processing queue.
[0011] In a possible design, allocating the subtasks in the multiple cache queues to corresponding task processing queues according to the priorities of the multiple cache queues and the subtask types corresponding to the subtasks in the cache queues includes:
[0012] In the order from the highest to the lowest priority, successively allocate the subtasks in the multiple cache queues to corresponding task processing queues according to the subtask types corresponding to the subtasks in the cache queues.
[0013] In a possible design, the step of, in the order from the highest to the lowest priority, successively allocating the subtasks in the multiple cache queues to corresponding task processing queues according to the subtask types corresponding to the subtasks in the cache queues includes:
[0014] Obtain the subtask types corresponding to the subtasks in the i-th cache queue, determine the task processing queues corresponding to the subtasks according to the subtask types corresponding to the subtasks, and allocate the subtasks to the corresponding task processing queues;
[0015] wherein i successively takes values of 1, 2,..., N, N is the number of the multiple cache queues, and the priority of the i-th cache queue is greater than the priority of the (i + 1)-th cache queue.
[0016] In a possible design, obtaining subtasks in the subtask database includes:
[0017] Obtain the processing waiting duration of each subtask in the subtask database;
[0018] Obtain the subtasks to be processed in the subtask database according to the processing waiting duration of each subtask in the subtask database.
[0019] In a possible design, the step of obtaining subtasks in the subtask database according to the processing waiting duration of each subtask in the subtask database includes:
[0020] Sort the subtasks in the subtask database in ascending order of the processing waiting duration;
[0021] Obtain subtasks in the subtask database in the sorted order.
[0022] In a possible design, before obtaining subtasks in the subtask database, it further includes:
[0023] Receive a task processing request sent by a client, where the task processing request is used to request processing of a task to be processed;
[0024] Determine at least one subtask corresponding to the task to be processed;
[0025] Store the at least one subtask in the subtask database.
[0026] In a second aspect, an embodiment of the present application provides a task processing device, including:
[0027] An acquisition module, configured to acquire subtasks in the subtask database, where the subtask database includes multiple subtasks;
[0028] A determination module, configured to determine a target cache queue from the multiple cache queues according to the task type of the task to which the subtask belongs, and store the subtask in the target cache queue;
[0029] An allocation module, configured to determine the priorities of the multiple cache queues, and allocate the subtasks in the multiple cache queues to corresponding task processing queues according to the priorities of the multiple cache queues and the subtask types corresponding to the subtasks in the cache queues;
[0030] A processing module, configured to, for any one task processing queue, process the subtasks in the task processing queue through the service corresponding to the task processing queue.
[0031] In a possible design, the allocation module is specifically configured to:
[0032] In the order of decreasing priority, successively allocate the subtasks in the multiple cache queues to corresponding task processing queues according to the subtask types corresponding to the subtasks in the cache queues.
[0033] In a possible design, the allocation module is specifically configured to:
[0034] Obtain the subtask types corresponding to the subtasks in the i-th cache queue, determine the task processing queues corresponding to the subtasks according to the subtask types corresponding to the subtasks, and allocate the subtasks to the corresponding task processing queues;
[0035] Wherein, i successively takes 1, 2,..., N, N is the number of the multiple cache queues, and the priority of the i-th cache queue is greater than the priority of the (i + 1)-th cache queue.
[0036] In a possible design, the acquisition module is specifically configured to:
[0037] Obtain the processing waiting duration of each subtask in the subtask database;
[0038] Obtain the subtasks to be processed in the subtask database according to the processing waiting duration of each subtask in the subtask database.
[0039] In a possible design, the obtaining module is specifically configured to:
[0040] Sort the subtasks in the subtask database in ascending order of the processing waiting duration;
[0041] Obtain the subtasks in the subtask database in the sorted order.
[0042] In a possible design, the apparatus further includes a storage module, and the storage module is specifically configured to:
[0043] Receive a task processing request sent by a client, where the task processing request is used to request processing of a task to be processed;
[0044] Determine at least one subtask corresponding to the task to be processed;
[0045] Store the at least one subtask into the subtask database.
[0046] In a third aspect, an embodiment of the present application provides a task processing device, including:
[0047] A memory for storing a program;
[0048] A processor for executing the program stored in the memory, and when the program is executed, the processor is configured to execute the method according to any one of the above first aspect and various possible designs of the first aspect.
[0049] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, including instructions, which when running on a computer, cause the computer to execute the method according to any one of the above first aspect and various possible designs of the first aspect.
[0050] In a fifth aspect, an embodiment of the present application provides a computer program product, where the program product includes: a computer program, the computer program is stored in a readable storage medium, and at least one processor of an electronic device can read the computer program from the readable storage medium, and the at least one processor executes the computer program to cause the electronic device to execute the method according to any one of the above first aspect and various possible designs of the first aspect.
[0051] An embodiment of the present application provides a task processing method and apparatus. The method includes: obtaining subtasks in a subtask database, where the subtask database includes multiple subtasks. Determining a target cache queue from multiple cache queues according to the task type of the task to which the subtask belongs, and storing the subtask in the target cache queue. Determining the priorities of the multiple cache queues, and distributing the subtasks in the multiple cache queues to corresponding task processing queues according to the priorities of the multiple cache queues and the subtask types corresponding to the subtasks in the cache queues. For any one of the task processing queues, processing the subtasks in the task processing queue through the service corresponding to the task processing queue. Distributing subtasks to multiple cache queues through the subtask database, and the multiple cache queues can distribute a sufficient number of subtasks to multiple task processing queues. Therefore, a sufficient number of subtasks can be provided when the external service request volume suddenly increases, which improves the task processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the accompanying drawings required for use in the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, other accompanying drawings can be obtained based on these drawings without creative efforts.
[0053] Figure 1 Schematic diagram of the task processing system provided by the embodiment of the present application;
[0054] Figure 2 Flow chart of the task processing method provided by the embodiment of the present application Figure 1 ;
[0055] Figure 3 Schematic diagram of the subtask database storing subtasks provided by the embodiment of the present application Figure 1 ;
[0056] Figure 4 Schematic diagram of the subtask database storing subtasks provided by the embodiment of the present application Figure 2 ;
[0057] Figure 5 Schematic diagram of the subtask database storing subtasks provided by the embodiment of the present application Figure 3 ;
[0058] Figure 6 Schematic diagram of multiple cache queues provided by the embodiment of the present application;
[0059] Figure 7 Flow chart of the task processing method provided by the embodiment of the present application Figure 2 ;
[0060] Figure 8 Schematic diagram for determining the priorities of multiple cache queues provided by an embodiment of the present application;
[0061] Figure 9 Schematic structural diagram of a task processing device provided by an embodiment of the present application;
[0062] Figure 10 Schematic hardware structure diagram of a task processing device provided by an embodiment of the present application. Detailed implementation manners
[0063] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in 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. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0064] To facilitate the understanding of the technical solution of the present application, first, relevant concepts involved in the present application will be introduced in combination with Figure 1 and described. Figure 1 Schematic diagram of a task processing system provided by an embodiment of the present application:
[0065] The task processing method provided by the present application is applied to a service processing system.
[0066] A service processing system is an information system used for processing services. As Figure 1 shown, the service processing system includes sub-modules such as a sub-task database, multiple cache queues, and multiple task processing queues.
[0067] Next, taking the case where a banking service processing system receives a service entry request as an example, the sub-modules included in the service processing system and the interrelationships between the sub-modules will be described:
[0068] When the banking business processing system receives business entry requests from multiple subordinate business centers, the system divides the tasks corresponding to each business request from each business center into multiple subtasks and stores them in the subtask database. Among them, each task has a corresponding task type, and the task type corresponding to each subtask is the task type to which the subtask belongs. At the same time, each subtask has multiple attributes, such as subtask type. Then, the subtask database distributes the subtasks to multiple cache queues. Subsequently, the multiple cache queues distribute the subtasks to multiple task processing queues so that the task processing queues can distribute the subtasks to complete the subtask processing. For example, after an external service initiates a task request, the task processing queue responds to the task request from the external service and distributes the subtasks to the external service. The external service receives the subtasks distributed by the task processing queue and processes the subtasks.
[0069] It should be emphasized that when the cache queue and the task processing queue distribute subtasks, they both follow the first-in, first-out rule, that is, the order in which the subtasks are dequeued from each queue is the same as the order in which the subtasks are enqueued. The subtasks that are enqueued first are dequeued first, and the subtasks that are enqueued later are dequeued later.
[0070] Based on the above introduction of the related concepts of this application, the related prior art of this application and the problems existing in the prior art will be described next:
[0071] Currently, in the prior art related to task processing, a certain number of subtasks are usually fetched from the subtask database at regular intervals and stored in the temporary task queue according to the priority, and then the subtasks in the temporary task queue are synchronously allocated to different assignment task queues according to the task attributes. Subsequently, the external service calls the subtasks from the assignment task queue to perform subtask processing.
[0072] However, in the process of task processing in the prior art, since the subtasks in the subtask database are stored in the temporary task queue at regular intervals and in a fixed quantity, when there are a large number of subtasks in the subtask database, the subtasks in the subtask database cannot be stored in the temporary task queue in time, resulting in the external service being unable to process the subtasks in time, and thus the efficiency of subtask processing is low.
[0073] Based on the above problems, the following technical concept is proposed in this application: when distributing subtasks from the subtask database, the subtasks are distributed to multiple cache queues simultaneously according to the task type. Among them, each cache queue stores only the subtasks of the same task type, and the subtasks of the same task type are stored only in the same cache queue. By distributing tasks from the subtask database to multiple cache queues simultaneously, it can be ensured that multiple cache queues can distribute a sufficient number of subtasks to multiple task processing queues, thereby ensuring that a sufficient number of subtasks can be provided in the case of a sudden increase in the external service request volume, and thus improving the efficiency of task processing.
[0074] Based on the technical concept introduced above, the technical solution shown in the present application will be described in detail below through specific embodiments. It should be noted that the following several embodiments can exist independently or be combined with each other. For the same or similar content, it will not be repeated in different embodiments.
[0075] Next, first, in combination with Figure 2 and specific embodiments, the task processing method provided by the present application will be introduced in detail. It is worth noting that the execution subject of each embodiment of the present application is a device with task processing functions such as a server. The specific implementation of this execution subject is not limited in this embodiment, as long as it can perform task processing. Figure 2 is the flow of the task processing method provided by the embodiments of the present application Figure 1 .
[0076] As Figure 2 shown, the method includes:
[0077] S201. Obtain subtasks from the subtask database, where the subtask database includes multiple subtasks.
[0078] In this embodiment, when the server receives service requests from multiple service centers, according to each service request, it determines the tasks corresponding to each service request, divides the tasks into multiple subtasks, and stores them in the subtask database.
[0079] Next, the tasks corresponding to each service request can be divided into multiple subtasks through at least the following two methods:
[0080] In a possible implementation manner, according to a preset quantity, the task corresponding to the service request is evenly divided into a preset quantity of subtasks with the same task quantity.
[0081] In another possible implementation manner, according to a preset task quantity and the total task quantity of the task corresponding to the service request, the task corresponding to the service request is divided into multiple subtasks with the preset task quantity and / or one subtask with the remaining task quantity. Wherein, the remaining task quantity is a value less than the preset task quantity.
[0082] It should be emphasized that each task corresponding to a service request has a corresponding task type to which it belongs, and the task type corresponding to each subtask is the task type corresponding to the task to which it belongs.
[0083] When storing the tasks corresponding to each service as subtasks in the subtask database, different priorities are set for each task type. Among them, the priority of the task type can be a static priority or a dynamic priority. Among them, the static priority means that once the priority of the task type is set, it will not change. The dynamic priority means that the priority of the task type can be adjusted as needed. At the same time, a tolerance duration is set for each subtask. Among them, the tolerance duration is a period of time, which means that the task must be processed within this duration. When starting to count from the creation of the subtask, if the subtask has not been processed when the counted duration is close to the tolerance duration, the priority of the subtask will be automatically increased to ensure that the subtask is completed within the tolerance duration.
[0084] Based on the above, where the tasks corresponding to each service request are divided into multiple subtasks, next, three possible implementation methods for storing subtasks in the subtask database will be introduced by way of example.
[0085] In one possible implementation method, each subtask is stored in the subtask database in the form of a queue. According to the order of receiving service requests, the multiple subtasks corresponding to each service request are sorted in ascending order of the tolerance duration, that is, the subtasks with shorter tolerance durations are stored first, and the subtasks with longer tolerance durations are stored later.
[0086] Next, Figure 3 through a specific example, this possible implementation method will be described. Figure 3 FIG. is a schematic diagram of storing subtasks in the subtask database provided by the embodiment of the present application. Figure 1 .
[0087] As Figure 3 shown, the subtask database stores subtasks in the form of a queue and controls the enqueueing and dequeueing of subtasks in accordance with the first-in, first-out rule of the queue. Sorted in ascending order of the tolerance duration, the subtasks corresponding to shorter tolerance times are first stored in the subtask database, and the subtasks corresponding to longer tolerance times are then stored in the subtask database, and so on, until all subtasks are stored in the subtask database.
[0088] In another possible implementation method, each subtask is stored in the subtask database in the form of a queue and stored according to the priority of the task type corresponding to the subtask, that is, the multiple subtasks corresponding to the task type with a higher priority are stored in the front, and the multiple subtasks corresponding to the task type with a lower priority are stored in the back.
[0089] Next, Figure 4 through a specific example, this possible implementation method will be described. Figure 4 FIG. is a schematic diagram of storing subtasks in the subtask database provided by the embodiment of the present application. Figure 2 .
[0090] As shown Figure 4 in the figure, the subtask database stores subtasks in the form of a queue and controls the enqueueing and dequeueing of subtasks according to the first-in, first-out rule of the queue. Sorting in descending order according to the priority of the task type, first store the subtasks corresponding to the higher priority in the subtask database, and then store the subtasks corresponding to the lower priority in the subtask database, and so on, to store all subtasks in the subtask database.
[0091] In another possible implementation, two queues are set in the subtask database, namely the real-time queue and the non-real-time queue. Among them, the real-time queue is used to store subtasks with a tolerance duration less than or equal to the preset duration, and the non-real-time queue is used to store subtasks with a tolerance duration greater than the preset duration. Among them, when storing subtasks in the real-time queue and the non-real-time queue, the enqueueing of subtasks is controlled in the order of the shortest to the longest tolerance duration.
[0092] Next, in combination with Figure 5 , through specific examples, this possible implementation method will be described. Figure 5 FIG. is a schematic diagram of storing subtasks in the subtask database provided by the embodiment of the present application. Figure 3 .
[0093] As shown Figure 5 in the figure, the subtask database includes a real-time queue and a non-real-time queue, and when storing subtasks in the real-time queue and the non-real-time queue, the subtasks are enqueued in the order of the shortest to the longest tolerance duration.
[0094] Based on the above introduction of three possible implementation methods for storing subtasks in the subtask database, next, three possible implementation methods for obtaining subtasks from the subtask database will be introduced.
[0095] In one possible implementation method, a preset number of subtasks are obtained from the subtask database in the order of subtask dequeueing.
[0096] In another possible implementation method, first obtain subtasks from the real-time queue, and when the subtasks in the real-time queue are taken out, then obtain from the non-real-time queue until the number of obtained subtasks reaches the preset number.
[0097] In another possible implementation method, obtain a first number of subtasks from the real-time queue and obtain a second number of subtasks from the non-real-time queue, where the first number and the second number are equal to the preset number.
[0098] Based on the above, on the basis of storing multiple subtasks in the subtask database, next, two possible implementation methods for obtaining subtasks from the subtask database will be described.
[0099] In a possible implementation, the sub-database obtains a certain number of sub-tasks dequeued regularly and quantitatively according to the first-in-first-out rule.
[0100] In another possible implementation, a preset number of sub-tasks is determined, and the preset number of sub-tasks is dequeued from the sub-task database according to the first-in-first-out rule. Among them, the preset number of sub-tasks is the number of required sub-tasks.
[0101] In this embodiment, only an exemplary introduction to the implementation of obtaining sub-tasks from the sub-task database is provided, and it does not limit the implementation of obtaining sub-tasks from the sub-task database. The implementation of obtaining sub-tasks from the sub-task database can be selected according to actual needs.
[0102] S202. According to the task type of the task to which the sub-task belongs, determine a target cache queue among multiple cache queues, and store the sub-task in the target cache queue.
[0103] It should be emphasized that only sub-tasks of the same task type are stored in each cache queue, and sub-tasks of the same task type are only stored in the same cache queue.
[0104] After obtaining multiple sub-tasks from the sub-task database based on the above S201, next, the obtained multiple sub-tasks are stored in multiple cache queues. It should be noted that before introducing in detail how to store the obtained multiple sub-tasks in multiple cache queues, first, two possible implementation methods of the multiple cache queues are introduced.
[0105] In a possible implementation, the multiple cache queues are all stored in the same database server.
[0106] In another possible implementation, the multiple cache queues are stored in multiple database servers. Here, the number of cache queues can be less than, greater than, or equal to the number of database servers. After performing a hash calculation based on the cache queue name, they are evenly distributed to each database server. When the number of cache queues is greater than the number of database servers, for example, there are 5 cache queues and 3 database servers. The 5 cache queues are cache queue 1, cache queue 2, cache queue 3, cache queue 4, and cache queue 5 respectively. And the 3 database servers are database server 1, database server 2, and database server 3 respectively. Among them, cache queue 1 and cache queue 2 are stored in database server 1, cache queue 3 and cache queue 4 are stored in database server 2, and cache queue 5 is stored in database server 3. When the number of cache queues is equal to the number of database servers, for example, there are 3 cache queues and 3 database servers. The 3 cache queues are cache queue 1, cache queue 2, and cache queue 3 respectively. And the 3 database servers are database server 1, database server 2, and database server 3 respectively. Among them, cache queue 1 is stored in database server 1, cache queue 2 is stored in database server 2, and cache queue 3 is stored in database server 3. When the number of cache queues is less than the number of database servers, for example, there are 3 cache queues and 5 database servers. The 3 cache queues are cache queue 1, cache queue 2, and cache queue 3 respectively. And the 5 database servers are database server 1, database server 2, database server 3, database server 4, and database server 5 respectively. Among them, cache queue 1 is stored in database server 1, cache queue 2 is stored in database server 2, cache queue 3 is stored in database server 5, and none of the database servers 3 and 4 store any of cache queues 1 - 3.
[0107] Among them, by using multiple database servers to store multiple cache queues, multiple subtasks can be dispersed and stored on multiple database servers. Therefore, the ability to store subtasks is borne by multiple database servers, and thus the ability to cache subtasks is not affected by the performance of a single database server. At the same time, storing multiple subtasks through multiple databases is conducive to improving the efficiency of subsequent distribution of subtasks by cache queues.
[0108] In this embodiment, only an exemplary introduction to the implementation manner of multiple cache queues is provided, rather than a limitation on the implementation manner of multiple cache queues. The implementation manner of multiple cache queues can be selected according to actual requirements.
[0109] In this embodiment, the subtasks obtained from the subtask database are stored in the cache queue. First, according to the task type of the task to which the subtask belongs, the target cache queue is determined among the multiple cache queues.
[0110] Next, in combination with Figure 6 , through specific examples, an exemplary description of the implementation method for determining the target cache queue will be given. Figure 6 FIG. is a schematic diagram of multiple cache queues provided in an embodiment of the present application.
[0111] Next, the process of determining the target cache queue for subtask K will be described. Assume that the task type of the task to which subtask K belongs is task type 3.
[0112] As Figure 6 shown, it includes n cache queues. Assume that the task type of the task to which the subtask stored in cache queue 1 belongs is task type 1, the task type of the task to which the subtask stored in cache queue 2 belongs is task type 2,..., and the task type of the task to which the subtask stored in cache queue n belongs is task type n. It is known that the service type to which subtask K belongs is service type 2. Therefore, the target cache queue for subtask K is determined to be cache queue 2.
[0113] Based on the above content, after determining the target cache queue corresponding to the subtask, the subtask is stored (added) to the target cache queue.
[0114] S203. Determine the priorities of multiple cache queues, and distribute the subtasks in the multiple cache queues to the corresponding task processing queues according to the priorities of the multiple cache queues and the subtask types corresponding to the subtasks in the cache queues.
[0115] After obtaining multiple subtasks and putting them into multiple cache queues based on step S202, next, multiple subtasks are taken from the multiple cache queues and distributed to multiple task processing queues.
[0116] In this embodiment, by determining the priorities of multiple cache queues, and according to the priorities of the multiple cache queues and the subtask types corresponding to the subtasks in the cache queues, the subtasks in the multiple cache queues are distributed to the corresponding task processing queues.
[0117] Next, first, two possible implementation methods for determining the priorities of multiple cache queues will be introduced:
[0118] In a possible implementation, according to the default business type priorities of the business processing system, the priorities of the cache queues corresponding to each business type are determined, where the priorities of the cache queues are consistent with the priorities of the business types corresponding to the cache queues. For example, there are a total of 5 cache queues. For ease of description, the business types corresponding to cache queue 1, cache queue 2, cache queue 3, cache queue 4, and cache queue 5 are denoted as business type 1, business type 2, business type 3, business type 4, and business type 5 respectively. Assume that the default business type priorities of the business processing system from high to low are: business type 3, business type 2, business type 5, business type 1, and business type 4. Therefore, it can be understood that the priorities of the cache queues can be determined from high to low as: cache queue 3, cache queue 2, cache queue 5, cache queue 1, and cache queue 4. Among them, setting priorities for multiple cache queues according to business types can ensure that sub-tasks with higher priorities can be processed in a timely manner.
[0119] In another possible implementation, the priorities of business types are adjusted according to business processing needs. Therefore, the priorities of the cache queues corresponding to each business type will be determined according to the adjusted business types. The priorities of the cache queues are consistent with the priorities of the business types corresponding to the cache queues after adjustment. Among them, adjusting the priorities of business types according to business processing needs and then adjusting the priorities of multiple cache queues makes the business processing more flexible and better able to meet business processing requirements.
[0120] In addition, it should be emphasized that each sub-task corresponds to a unique task sub-type. At the same time, only sub-tasks of the same sub-task type are stored in each task processing queue, and sub-tasks of the same sub-task type are only stored in the same task processing queue.
[0121] After determining the priorities of multiple cache queues based on the above content, next, according to the priorities of the multiple cache queues and the sub-task types corresponding to each sub-task in the cache queues, the sub-tasks in the multiple cache queues are assigned to the corresponding task processing queues. Taking the priorities of the cache queues determined in the above embodiment as an example, that is, the priorities of the cache queues from high to low are: cache queue 3, cache queue 2, cache queue 5, cache queue 1, and cache queue 4, the implementation method of assigning the sub-tasks in the multiple cache queues to the corresponding task processing queues is introduced, and it is assumed that the number of sub-tasks required by the multiple task queues is the third quantity.
[0122] In this embodiment, first, determine the cache queue with the highest priority among multiple cache queues, that is, cache queue 3. Next, dequeue the subtasks stored in cache queue 3 in the order of first in first out. Assume that the number of subtasks stored in cache queue 3 is the fourth quantity. If the fourth quantity is greater than or equal to the third quantity, control the dequeue of the third quantity of subtasks from cache queue 3 in the order of first in first out, and store each subtask in its corresponding task processing queue according to the subtask type of each subtask.
[0123] When the value of the fourth quantity is less than the value of the third quantity, allocate subtasks from cache queue 2 with the second highest priority compared to cache queue 3 to multiple task processing queues. It should be noted that since the number of subtasks required by multiple task queues is the third quantity, it is also necessary to allocate the fifth quantity of subtasks from other cache queues to multiple task processing queues, where the fifth quantity is the difference between the third quantity and the fourth quantity. Next, allocate subtasks from cache queue 2 with the second highest priority compared to cache queue 3 to multiple task processing queues. Assume that the number of subtasks included in cache queue 2 is the sixth quantity, and the sixth quantity is greater than the fifth quantity. Therefore, the first fifth quantity of subtasks in cache queue 2 are dequeued in sequence, and these fifth quantity of subtasks are allocated to the task processing queues corresponding to each subtask.
[0124] If the fourth quantity is less than the third quantity, store all the subtasks in cache queue 3 in the corresponding task processing queues according to the subtask type of the subtasks.
[0125] Next, take any subtask in cache queue 3 (e.g., subtask 3-1, that is, the first subtask in cache queue 3) as an example to illustrate the possible implementation methods of storing subtasks in the corresponding task processing queues. Assume that there are 5 task processing queues, and the corresponding subtask types of these 5 task processings are as follows: task processing queue 1 corresponds to task processing type 1, task processing queue 2 corresponds to task processing type 2, task processing queue 3 corresponds to task processing type 3, task processing queue 4 corresponds to task processing type 4, and task processing queue 5 corresponds to task processing type 5. And assume that the subtask type corresponding to subtask 3-1 is subtask type 3.
[0126] First, determine the subtask type of the subtask, that is, the subtask type corresponding to subtask 3-1 is subtask type 3. And determine that the task processing queue corresponding to subtask type 3 is task processing queue 3.
[0127] Therefore, allocate subtask 3-1 to task processing queue 3. Similarly, allocate all the subtasks in cache queue 3 to their corresponding task processing queues in the same way.
[0128] S204. For any task processing queue, use the service corresponding to the task processing queue to process the subtasks in the task processing queue.
[0129] After allocating multiple subtasks to each task processing queue as described above, next, use the service corresponding to the task processing queue to process the subtasks in the task processing queue.
[0130] The service corresponding to the task processing queue is a service institution that can process the subtasks in the task processing queue, such as a third-party service or an external service.
[0131] In a possible implementation, the third-party service sends a task processing request to the service processing system, where the task processing request includes service request information such as service type and subtask type. The service processing system sends the subtasks that meet the service request information from the task processing queue to the third-party service according to the service request information. After receiving the subtasks, the third-party service processes the subtasks and returns the service processing result to the service processing system.
[0132] The task processing method provided by the embodiments of the present application includes: obtaining subtasks from a subtask database, where the subtask database includes multiple subtasks. Determine a target cache queue from multiple cache queues according to the task type of the task to which the subtask belongs, and store the subtask in the target cache queue. Determine the priorities of multiple cache queues, and allocate the subtasks in the multiple cache queues to the corresponding task processing queues according to the priorities of the multiple cache queues and the subtask types corresponding to the subtasks in the cache queues. For any task processing queue, use the service corresponding to the task processing queue to process the subtasks in the task processing queue. Distribute subtasks from the subtask database to multiple cache queues, and the multiple cache queues can distribute a sufficient number of subtasks to multiple task processing queues. Therefore, a sufficient number of subtasks can be provided when the external service request volume suddenly increases, which improves the task processing efficiency.
[0133] Based on the above embodiments, the task processing method provided by the present application will be further introduced below in combination with a specific embodiment, in combination with Figure 7 be introduced, Figure 7 is the flow of the task processing method provided by the embodiments of the present application Figure 2 .
[0134] As Figure 7 shown, the method includes:
[0135] S701. Receive a task processing request sent by a client, where the task processing request is used to request the processing of a task to be processed.
[0136] The client, also known as the user end, refers to a program that provides local services corresponding to the server. It is generally installed on the client machine and needs to run in cooperation with the server end. The client can send business processing requests to the business processing system in the server.
[0137] The task processing request is used for the task to be processed. Among them, the task processing request includes the requested task information, such as task type, subtask type and other information.
[0138] The client sends a task processing request to the business processing system in the server. After receiving the task processing request, the business processing system in the server determines the task to be processed according to the task processing request.
[0139] S702. Determine at least one subtask corresponding to the task to be processed.
[0140] In this embodiment, determining at least one of the tasks to be processed means dividing the task to be processed into multiple subtasks.
[0141] Next, the task to be processed can be divided into multiple subtasks through at least the following two methods:
[0142] In a possible implementation, according to the preset quantity, the task to be processed is evenly divided into a preset number of subtasks with the same task quantity.
[0143] In another possible implementation, according to the preset task quantity and the task quantity of the task to be processed, the task to be processed is divided into multiple subtasks with the preset task quantity and / or one subtask with the remaining task quantity. Among them, the remaining task quantity is a value less than the preset task quantity.
[0144] In this embodiment, only an exemplary introduction to the implementation method of determining at least one subtask corresponding to the task to be processed is given, rather than a limitation on the implementation method of determining at least one subtask corresponding to the task to be processed. The implementation method of determining at least one subtask corresponding to the task to be processed can be selected according to actual needs.
[0145] S703. Store at least one subtask in the subtask database.
[0146] After determining at least one subtask corresponding to the task to be processed based on step S702, store at least one subtask in the subtask database.
[0147] Next, at least one subtask can be stored in the subtask database through at least the following two methods:
[0148] In a possible implementation, at least one subtask is stored in a subtask database in the form of a queue. When adding a subtask to the subtask database and retrieving a subtask from the subtask database, the rule of first-in, first-out of the queue must be followed, that is, the subtask that first enters the subtask database should be the first to be distributed when the subtask database distributes subtasks outward.
[0149] In another possible implementation, at least one subtask is stored in a subtask database in the form of a stack. When adding a subtask to the subtask database and retrieving a subtask from the subtask database, the rule of last-in, first-out of the stack must be followed, that is, the subtask that first enters the subtask database should be the last to be distributed when the subtask database distributes subtasks outward.
[0150] In this embodiment, only an exemplary introduction to the implementation of storing at least one subtask in the subtask database is provided, rather than a limitation on the implementation of storing at least one subtask in the subtask database. The implementation of storing at least one subtask in the subtask database can be selected according to actual needs.
[0151] S704. Obtain the processing waiting duration of each subtask in the subtask database.
[0152] The processing waiting duration is the processing tolerance duration corresponding to the subtask, that is, the subtask must be processed within the processing tolerance duration. It should be noted that when the processing waiting duration of the subtask is about to reach, the priority of the subtask is automatically increased so that the subtask can be quickly processed within the processing waiting duration.
[0153] Next, the processing waiting duration of each subtask in the subtask database can be obtained through at least the following two methods:
[0154] In a possible implementation, the corresponding processing waiting duration is set for each subtask according to the task volume of the subtask. Specifically, based on the basic unit of the task volume, the processing waiting duration corresponding to each unit of the task volume is the unit processing waiting duration. Therefore, the processing waiting duration corresponding to each subtask is the product of the task volume corresponding to each task and the unit processing waiting duration, that is, the subtask with a larger task volume has a longer corresponding processing waiting duration.
[0155] In another possible implementation, the waiting duration of the subtasks corresponding to the same business type is set to a fixed value, and the higher the priority of the business type, the smaller the processing waiting duration of the subtasks under this business type.
[0156] In this embodiment, only an exemplary introduction is given to the implementation manner of obtaining the processing waiting duration of each subtask in the subtask database, rather than a limitation on the implementation manner of obtaining the processing waiting duration of each subtask in the subtask database. The implementation manner of obtaining the processing waiting duration of each subtask in the subtask database can be selected according to actual requirements.
[0157] S705. Sort the subtasks in the subtask database in ascending order of the processing waiting duration.
[0158] In this embodiment, the subtasks in the task database are sorted according to the magnitudes of the processing waiting durations corresponding to the respective subtasks in the subtask data.
[0159] Next, the subtasks in the subtask database can be sorted in at least the following two ways:
[0160] In a possible implementation manner, the subtasks in the subtask database are sorted in ascending order of the processing waiting duration corresponding to each subtask. That is, the smaller the processing waiting duration corresponding to a subtask, the earlier it is ranked at the front of the subtask database, so as to ensure that the subtask with a smaller processing waiting duration can be distributed from the subtask database in the first place.
[0161] In another possible implementation manner, the subtasks are stored in the subtask database in the form of two queues, where the two queues are a real-time subtask queue and a non-real-time subtask queue respectively. Among them, the real-time subtask queue stores the subtasks with a processing waiting duration less than or equal to a preset duration, and the non-real-time subtask queue stores the subtasks with a processing waiting duration greater than the preset duration.
[0162] In this embodiment, only an exemplary introduction is given to the implementation manner of sorting the subtasks in the subtask database, rather than a limitation on the implementation manner of sorting the subtasks in the subtask database. The implementation manner of sorting the subtasks in the subtask database can be selected according to actual requirements.
[0163] S706. Obtain the subtasks in the subtask database in the sorted order.
[0164] After sorting the subtasks in the subtask database based on step S705, next, obtain the subtasks from the subtask database.
[0165] Next, the subtasks can be obtained from the subtask database in at least the following two ways:
[0166] In a possible implementation, a certain number of subtasks are obtained from the subtask queue corresponding to the subtask data at regular intervals. For example, every 30 seconds, 20 subtasks are obtained from the subtask queue corresponding to the subtask database.
[0167] In another possible implementation, a preset number of subtasks are obtained from the subtask database. Specifically, subtasks are first obtained from the real-time subtask queue corresponding to the subtask database. Assume that the number of subtasks in the current real-time subtask queue is the seventh number. If the seventh number is greater than or equal to the preset number, then the preset number of subtasks are obtained from the real-time subtask queue. If the seventh number is less than the preset number, then all the subtasks in the real-time subtask queue are first obtained, and then the eighth number of subtasks are obtained from the non-real-time part, where the value of the eighth number is the difference between the preset number and the seventh number.
[0168] In this embodiment, only an exemplary introduction to the implementation of obtaining subtasks from the subtask database is provided, and it does not limit the implementation of obtaining subtasks from the subtask database. The implementation of obtaining subtasks from the subtask database can be selected according to actual needs.
[0169] S707. Determine the target cache queue from multiple cache queues according to the task type of the task to which the subtask belongs, and store the subtask in the target cache queue.
[0170] After obtaining the preset number of subtasks based on step S706, next, the subtasks are stored (distributed) in multiple cache queues. Among them, each cache queue stores subtasks of different task types, that is, each cache queue corresponds to a different task type.
[0171] In this embodiment, first, the target cache queue is determined from multiple cache queues according to the task type of the task to which the subtask belongs.
[0172] In a possible implementation, according to the task type of the task to which the subtask belongs, the cache queue with the same task type as the task to which the subtask belongs is found in multiple cache queues, and this cache queue is determined as the target cache queue corresponding to the subtask, and the subtask is stored in this target cache queue.
[0173] In this embodiment, only an exemplary introduction to the implementation of determining the target cache queue is provided, and it does not limit the implementation of determining the target cache queue. The implementation of determining the target cache queue can be selected according to actual needs.
[0174] S708. Determine the priorities of multiple cache queues.
[0175] After storing multiple subtasks into multiple cache queues based on step S707, next, the subtasks in the multiple cache queues are distributed to multiple task processing queues. When distributing the subtasks from the multiple cache queues to the multiple task processing queues, it is necessary to first determine the priorities of the multiple cache queues. First, distribute the subtasks from the cache queue with the highest priority to the multiple task processing queues until all the multiple subtasks in the cache queue are allocated or the subtasks corresponding to the preset subtask type in the cache queue have been distributed. Then, start distributing the subtasks from the cache queue with the next highest priority compared to this cache queue to the multiple task processing queues.
[0176] Next, the priorities of the multiple cache queues can be determined through at least the following two methods:
[0177] In a possible implementation, according to the default business type priorities of the business processing system, determine the priorities of the cache queues corresponding to each business type. Among them, the priority of each cache queue is the same as the priority of the business type corresponding to each cache queue. Setting priorities for the multiple cache queues according to the business types can ensure that the sub - businesses with higher priorities can be processed in a timely manner.
[0178] In another possible implementation, the priorities of the business types are adjusted according to the business processing needs. Therefore, the priorities of the cache queues corresponding to each business type are determined according to the adjusted business types. The priority of each cache queue is the same as the priority of the business type corresponding to each cache queue after adjustment. Adjusting the priorities of the business types according to the business processing needs and then adjusting the priorities of the multiple cache queues makes the business processing more flexible and better able to meet the business processing requirements.
[0179] Next, in combination with Figure 8 , through specific examples, an exemplary description of the implementation method for determining the target cache queue is given. Figure 8 This is a schematic diagram for determining the priorities of multiple cache queues provided by an embodiment of this application.
[0180] As Figure 8As shown, there are a total of 5 cache queues, namely: Cache Queue 1, Cache Queue 2, Cache Queue 3, Cache Queue 4, and Cache Queue 5. The corresponding service types are Service Type 1, Service Type 2, Service Type 3, Service Type 4, and Service Type 5 respectively. Assume that the default service type priorities of the service processing system from high to low are: Service Type 3, Service Type 2, Service Type 5, Service Type 1, and Service Type 4. Therefore, it can be understood that the priorities of the cache queues can be determined from high to low as: Cache Queue 3, Cache Queue 2, Cache Queue 5, Cache Queue 1, and Cache Queue 4. If, according to user requirements, the priorities of the service types change. For example, the service type priorities after the change from high to low are: Service Type 4, Service Type 1, Service Type 2, Service Type 3, and Service Type 5. Therefore, the priorities of the cache queues from high to low are: Cache Queue 4, Cache Queue 1, Cache Queue 2, Cache Queue 3, and Cache Queue 5.
[0181] Among them, setting priorities for multiple cache queues according to service categories can ensure that sub-services with high priorities can be processed in a timely manner. At the same time, when the priorities of service types change, the priorities of the cache queues corresponding to each service type can be adjusted in a timely manner, so that during the process of distributing sub-tasks from multiple cache queues to multiple task processing queues, sub-tasks with high priorities can be distributed in a timely manner.
[0182] In this embodiment, only an exemplary introduction to the implementation method of determining the priorities of multiple cache queues is provided, rather than limiting the implementation method of determining the priorities of multiple cache queues. The implementation method of determining the priorities of multiple cache queues can be selected according to actual needs.
[0183] The method of determining the priorities of multiple cache queues is similar to the specific implementation method of determining the priorities of multiple cache queues in step S203, and will not be elaborated here.
[0184] S709. Obtain the sub-task types corresponding to each sub-task in the i-th cache queue. According to the sub-task types corresponding to each sub-task, determine the task processing queue corresponding to each sub-task, and allocate each sub-task to the corresponding task processing queue.
[0185] Among them, i takes 1, 2,..., N in sequence, N is the number of the multiple cache queues, and the priority of the i-th cache queue is greater than the priority of the (i + 1)-th cache queue.
[0186] It should be emphasized that each task processing queue corresponds to a different sub-task type, that is, all sub-tasks in each task processing queue correspond to the same sub-task type.
[0187] In this embodiment, when distributing subtasks from multiple cache queues to multiple task processing queues, it should be noted that the cache queues are determined in order from the highest priority to the lowest priority. After determining a cache queue, when distributing multiple subtasks in the cache queue to multiple task processing queues, the subtask types corresponding to each subtask in the i-th cache queue should be obtained first.
[0188] In a possible implementation, for any subtask, a task processing queue whose corresponding subtask queue in the multiple task processing queues has the same subtask type as the subtask is found, and the subtask is stored in the task processing queue.
[0189] In this embodiment, only an exemplary introduction to the implementation of determining the task processing queue corresponding to each subtask is provided, and it does not limit the implementation of determining the task processing queue corresponding to each subtask. The implementation of determining the task processing queue corresponding to each subtask can be selected according to actual requirements.
[0190] S710. For any task processing queue, the subtasks in the task processing queue are processed through the service corresponding to the task processing queue.
[0191] Among them, the specific implementation of step S710 is similar to that of step S204 and will not be elaborated here.
[0192] The task processing method provided by the embodiment of the present application includes: receiving a task processing request sent by a client, where the task processing request is used to request the processing of a to-be-processed task; determining at least one subtask corresponding to the to-be-processed task; storing the at least one subtask in a subtask database; obtaining the processing waiting duration of each subtask in the subtask database; sorting the subtasks in the subtask database in ascending order of the processing waiting duration; obtaining subtasks in the subtask database in the sorted order; determining a target cache queue from multiple cache queues according to the task type of the task to which the subtask belongs, and storing the subtask in the target cache queue; determining the priorities of the multiple cache queues; obtaining the subtask types corresponding to the subtasks in the i-th cache queue, determining the task processing queues corresponding to the subtasks according to the subtask types corresponding to the subtasks, and allocating the subtasks to the corresponding task processing queues, where i sequentially takes values of 1, 2,..., N, N is the number of multiple cache queues, and the priority of the i-th cache queue is higher than that of the (i + 1)-th cache queue; for any task processing queue, processing the subtasks in the task processing queue through the service corresponding to the task processing queue; setting priorities for the multiple cache queues according to the service types, which can ensure that the subtasks with higher priorities can be processed in a timely manner. At the same time, when the priority of the service type changes, the priorities of the cache queues corresponding to each service type can be adjusted in a timely manner, so that the subtasks with higher priorities can be distributed in a timely manner during the process of distributing subtasks from multiple cache queues to multiple task processing queues.
[0193] Figure 9 It is a schematic structural diagram of the task processing device provided by the embodiment of the present application. As Figure 9 shown, the device 900 includes: an obtaining module 901, a determining module 902, an allocating module 903, and a processing module 904.
[0194] The obtaining module 901 is configured to obtain subtasks in the subtask database, where the subtask database includes multiple subtasks;
[0195] The determining module 902 is configured to determine a target cache queue from the multiple cache queues according to the task type of the task to which the subtask belongs, and store the subtask in the target cache queue;
[0196] The allocating module 903 is configured to determine the priorities of the multiple cache queues, and allocate the subtasks in the multiple cache queues to the corresponding task processing queues according to the priorities of the multiple cache queues and the subtask types corresponding to the subtasks in the cache queues;
[0197] A processing module 904, configured to process sub-tasks in any one of the task processing queues through a service corresponding to the task processing queue.
[0198] In a possible design, the allocation module 903 is specifically configured to:
[0199] In the order from the highest to the lowest priority, successively according to the sub-task types corresponding to the sub-tasks in the buffer queue, allocate the sub-tasks in the multiple buffer queues to the corresponding task processing queues.
[0200] In a possible design, the allocation module 903 is specifically configured to:
[0201] Obtain the sub-task types corresponding to the sub-tasks in the i-th buffer queue, determine the task processing queues corresponding to the sub-tasks according to the sub-task types corresponding to the sub-tasks, and allocate the sub-tasks to the corresponding task processing queues;
[0202] Wherein, i successively takes 1, 2,..., N, N is the number of the multiple buffer queues, and the priority of the i-th buffer queue is greater than the priority of the (i + 1)-th buffer queue.
[0203] In a possible design, the obtaining module 901 is specifically configured to:
[0204] Obtain the processing waiting duration of each sub-task in the sub-task database;
[0205] According to the processing waiting duration of each sub-task in the sub-task database, obtain the sub-tasks to be processed in the sub-task database.
[0206] In a possible design, the obtaining module 901 is specifically configured to:
[0207] Sort the sub-tasks in the sub-task database in the order from the shortest to the longest processing waiting duration;
[0208] Obtain the sub-tasks in the sub-task database in the sorted order.
[0209] In a possible design, the device further includes a storage module 905, and the storage module 905 is specifically configured to:
[0210] Receive a task processing request sent by a client, where the task processing request is used to request processing of a task to be processed;
[0211] Determine at least one sub-task corresponding to the task to be processed;
[0212] Store the at least one sub-task into the sub-task database.
[0213] The device provided in this embodiment can be used to execute the technical solutions of the above method embodiment. The implementation principle and technical effects are similar, and will not be elaborated here in this embodiment.
[0214] Figure 10 It is a schematic hardware structure diagram of the task processing device provided in the embodiments of the present application. As Figure 10 shown, the task processing device 1000 in this embodiment includes: a processor 1001 and a memory 1002; where
[0215] The memory 1002 is used to store computer execution instructions;
[0216] The processor 1001 is used to execute the computer execution instructions stored in the memory to implement each step executed by the task processing method in the above embodiment. For specific details, please refer to the relevant descriptions in the foregoing method embodiment.
[0217] Optionally, the memory 1002 can be either independent or integrated with the processor 1001.
[0218] When the memory 1002 is independently provided, the task processing device further includes a bus 1003 for connecting the memory 1002 and the processor 1001.
[0219] The embodiments of the present application provide a computer-readable storage medium, in which computer execution instructions are stored. When the processor executes the computer execution instructions, the task processing method executed by the above task processing device is implemented.
[0220] The embodiments of the present application also provide a computer program product. The program product includes: a computer program. The computer program is stored in a readable storage medium. At least one processor of the electronic device can read the computer program from the readable storage medium, and at least one processor executes the computer program to enable the electronic device to execute the solution provided in any of the above embodiments.
[0221] In several embodiments provided by the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces, and the indirect coupling or communication connection of the device or module can be in an electrical, mechanical or other form.
[0222] The integrated modules implemented in the form of software functional modules can be stored in a computer-readable storage medium. The above software functional modules are stored in a storage medium and include several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to execute some steps of the methods described in various embodiments of the present application.
[0223] It should be understood that the above processor may be a central processing unit (English: Central Processing Unit, abbreviated as: CPU), and may also be other general-purpose processors, digital signal processors (English: Digital Signal Processor, abbreviated as: DSP), application specific integrated circuits (English: Application Specific Integrated Circuit, abbreviated as: ASIC), etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in combination with the invention can be directly embodied as being executed and completed by a hardware processor, or executed and completed by a combination of hardware and software modules in the processor.
[0224] The memory may include high-speed RAM memory and may also include non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk, or an optical disc, etc.
[0225] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, the buses in the drawings of the present application are not limited to only one bus or one type of bus.
[0226] The above storage medium may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disc. The storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0227] Those of ordinary skill in the art will understand that all or part of the steps of implementing the above method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments; and the aforementioned storage medium includes various media such as ROM, RAM, magnetic disks, or optical discs that can store program codes.
[0228] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A task processing method, characterized in that, applied to a service processing system, the service processing system includes a subtask database, multiple cache queues, and multiple task processing queues, and includes: Obtain subtasks in the subtask database, where the subtask database includes multiple subtasks; there are two queues in the subtask database: a real-time queue and a non-real-time queue; wherein, the real-time queue is used to store subtasks with a tolerance duration less than or equal to a preset duration, and the non-real-time queue is used to store subtasks with a tolerance duration greater than the preset duration; Determine a target cache queue from the multiple cache queues according to the task type of the task to which the subtask belongs, and store the subtask in the target cache queue; Determine the priorities of the multiple cache queues, and obtain the subtask types corresponding to each subtask in the i-th cache queue. According to the subtask types corresponding to each subtask, determine the task processing queues corresponding to each subtask, and allocate each subtask to the corresponding task processing queue; wherein, i sequentially takes 1, 2,..., N, N is the number of the multiple cache queues, and the priority of the i-th cache queue is greater than the priority of the (i + 1)-th cache queue; For any one task processing queue, process the subtasks in the task processing queue through the service corresponding to the task processing queue; The obtaining subtasks in the subtask database includes: Obtain the processing waiting duration of each subtask in the subtask database; when the processing waiting duration of the subtask is about to end, the priority of the subtask is automatically increased so that the subtask can be quickly processed within the processing waiting duration; wherein, the processing waiting duration is the processing tolerance duration corresponding to the subtask; Sort the subtasks in the subtask database in ascending order of the processing waiting duration; Obtain a preset number of subtasks in the subtask database in the sorted order.
2. The method according to claim 1, characterized in that, before obtaining subtasks in the subtask database, further includes: Receive a task processing request sent by a client, where the task processing request is used to request processing of a task to be processed; Determine at least one subtask corresponding to the task to be processed; Store the at least one subtask in the subtask database.
3. A task processing device, characterized in that, applied to a service processing system, the service processing system includes a subtask database, multiple cache queues, and multiple task processing queues, and includes: An obtaining module, configured to obtain subtasks in the subtask database, where the subtask database includes multiple subtasks; there are two queues in the subtask database: a real-time queue and a non-real-time queue; wherein, the real-time queue is used to store subtasks with a tolerance duration less than or equal to a preset duration, and the non-real-time queue is used to store subtasks with a tolerance duration greater than the preset duration; A determination module, configured to determine a target cache queue from the multiple cache queues according to the task type of the task to which the subtask belongs, and store the subtask into the target cache queue; An allocation module, configured to determine the priorities of the multiple cache queues, obtain the subtask types corresponding to the subtasks in the i-th cache queue, determine the task processing queues corresponding to the subtasks according to the subtask types corresponding to the subtasks, and allocate the subtasks to the corresponding task processing queues; where i sequentially takes 1, 2,..., N, N is the number of the multiple cache queues, and the priority of the i-th cache queue is greater than the priority of the (i + 1)-th cache queue; A processing module, configured to, for any one of the task processing queues, process the subtasks in the task processing queue through the service corresponding to the task processing queue; The obtaining module is specifically configured to obtain the processing waiting duration of each subtask in the subtask database; when the processing waiting duration of the subtask is about to end, the priority of the subtask is automatically increased so that the subtask can be quickly processed within the processing waiting duration; where the processing waiting duration is the processing tolerance duration corresponding to the subtask; sort the subtasks in the subtask database in ascending order of the processing waiting duration; and obtain a preset number of subtasks from the subtask database in the sorted order.
4. A task processing device Characterized in that It includes: A memory, configured to store a program; A processor, configured to execute the program stored in the memory, and when the program is executed, the processor is configured to execute the method according to any one of claims 1 to 2.
5. A computer-readable storage medium Characterized in that It includes instructions, which when running on a computer, cause the computer to execute the method according to any one of claims 1 to 2.
6. A computer program product, including a computer program Characterized in that The computer program, when executed by a processor, implements the method according to any one of claims 1 to 2.
Citation Information
Patent Citations
Method for recording event logs and database engine
CN103729442A
Task processing method and system
CN109814988A