Task allocation optimization method and terminal

By prioritizing tasks based on their processing rate and assigning them scores, and then periodically allocating tasks by the master node, the problem of not being able to accurately understand the status of the processors in existing technologies is solved, thus achieving precise task allocation and system balance.

CN118689634BActive Publication Date: 2025-11-28福建天晴在线互动科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410711363.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2025-11-28
Estimated Expiration
2044-06-04

AI Technical Summary

Technical Problem

Existing task allocation strategies cannot accurately understand the actual situation of the processors, resulting in system imbalance.

Method used

Prioritize tasks based on their processing rate and assign points accordingly. The master node periodically retrieves the total points of each processor and prioritizes assigning points to the processor with the lowest points.

Benefits of technology

It achieves precise task allocation, ensures a balance of points among processors, and reaches a balanced state in the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118689634B_ABST
    Figure CN118689634B_ABST
Patent Text Reader

Abstract

The application provides a task allocation optimization method and a terminal, which comprises the following steps: according to the processing rate of different types of tasks from fast to slow, different types of tasks are divided into priorities from high to low, and according to the priorities from high to low, small to large integral numbers are sequentially assigned; each processor counts the corresponding priority integral number according to the type of the task to be processed and the type of the task being processed; the master node periodically acquires the integral total number of each processor in the local cache, and preferentially allocates the task to be allocated to the processor corresponding to the lowest integral total number. According to the application, the priorities of different types of tasks are divided, and different integral numbers are assigned, so that the master node can preferentially allocate new tasks to the processor with a lower integral total number according to the integral total number of the accumulated tasks in each processor, the accurate allocation of tasks is realized, and finally the integral number of the processor can reach a relatively balanced state, thereby ensuring the balance of the whole system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, in particular to a task allocation optimization method and terminal. BACKGROUND

[0002] Nowadays, various message middleware exist in the Internet system, and most of the message middleware or other task allocation and traffic forwarding software have task forwarding or allocation functions. At present, these forwarding or allocation functions are triggered by the master node or master module, and different strategies are usually adopted, such as round-robin balanced allocation, hash allocation or weight allocation.

[0003] However, the above allocation strategies are active strategies of the master node, and the actual situation of the handler cannot be understood. The existing allocation strategies can directly allocate according to the resource usage of the handler, but the resource usage is the resource usage of the entire server, and cannot accurately reflect the real situation of the handler. SUMMARY

[0004] The technical problem to be solved by the present application is to provide a task allocation optimization method and terminal, to realize accurate allocation of master node tasks and ensure the balance of the entire system.

[0005] In order to solve the above technical problems, the technical scheme adopted by the present application is:

[0006] A task allocation optimization method, comprising the steps of:

[0007] S1, according to the processing rate of different types of tasks from fast to slow, the types of different tasks are divided into high to low priority, and according to the priority from high to low, a small to large integral number is assigned in turn;

[0008] S2, each handler calculates the corresponding priority integral number according to the type of the task to be processed and the task being processed;

[0009] S3, the master node periodically acquires the total number of points of each handler, and preferentially allocates the task to be allocated to the handler corresponding to the lowest total number of points.

[0010] In order to solve the above technical problems, another technical scheme adopted by the present application is:

[0011] A task allocation optimization terminal, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:

[0012] S1, according to the processing rate of different types of tasks from fast to slow, the types of different tasks are divided into high to low priority, and the integral number is given from small to large according to the priority from high to low in turn;

[0013] S2, each processor according to the type of the task to be processed and the type of the task in processing, the corresponding priority integral number is counted;

[0014] S3, the master node periodically acquires the integral total number of each processor, and preferentially distributes the to-be-distributed task to the processor corresponding to the lowest integral total number.

[0015] The beneficial effects of the present application are that: provide a kind of optimization method and terminal of task distribution, the priority of different types of tasks is distinguished according to the processing rate of various types of tasks, different priority will have different integral number, each processor can obtain the integral number corresponding to the task according to the type of the task to be processed and the type of the task in processing, so that the master node can distribute new task according to the integral total number of each processor, i.e. when new task in master node will be distributed, according to the integral total number of the task accumulated in each processor, new task is preferentially distributed to the processor with lower integral total number, the accurate distribution of task is realized, and finally the integral number of the processor can reach a more balanced state, ensure the balance of the whole system. BRIEF DESCRIPTION OF DRAWINGS

[0016] Figure 1 It is a flow chart of the optimization method of task distribution for the embodiment of the present application;

[0017] Figure 2 It is a structural schematic diagram of the optimization terminal of task distribution for the embodiment of the present application.

[0018] Label explanation:

[0019] 1, an optimization terminal of task distribution;2, memory;3, processor. DETAILED DESCRIPTION

[0020] To explain the technical content, the purpose and effect realized by the present application in detail, the following is explained by combining with embodiment and accompanying drawings.

[0021] Please refer to Figure 1 An optimization method of task distribution, comprising the steps of:

[0022] S1, according to the processing rate of different types of tasks from fast to slow, the types of different tasks are divided into high to low priority, and the integral number is given from small to large according to the priority from high to low in turn;

[0023] S2, each processor calculates corresponding priority score according to the type of the task to be processed and the type of the task being processed;

[0024] S3, the master node periodically acquires the total score of each processor, and preferentially allocates the task to be allocated to the processor corresponding to the lowest total score.

[0025] From the above description, the beneficial effects of the present application are that an optimization method for task allocation is provided, the priority of different types of tasks is distinguished according to the processing rate of various types of tasks, different priorities will have different scores, each processor can obtain the corresponding score of the task according to the type of the task to be processed and the type of the task being processed, so that the master node can allocate new tasks according to the total score of each processor, that is, when there is a new task to be allocated in the master node, the new task will be preferentially allocated to the processor with a lower total score according to the total score of the accumulated tasks in each processor, realizing accurate allocation of tasks, and finally the score of the processor can reach a relatively balanced state, ensuring the balance of the whole system.

[0026] Further, the step S1 further comprises:

[0027] S0, acquiring different types of processed tasks, and performing stress testing on different types of processed tasks to obtain the processing rate of different types of tasks.

[0028] From the above description, since the task being processed or the task to be processed allocated to the corresponding processor cannot obtain the processing rate, the processing rate of the processed task can be obtained by stress testing the processed task, and the different types of tasks are classified, and then the processing rate of different types of tasks is obtained as a standard for subsequent priority division and score assignment.

[0029] Further, the step S0 further comprises: periodically acquiring new processed tasks and repeating the above steps to update the processing rate of different types of tasks.

[0030] From the above description, in order to ensure accurate allocation of tasks, new processed tasks can be periodically acquired for stress testing to update the different processing rates corresponding to different types of tasks, dynamically adjust the priority and score corresponding to different types of tasks, and realize a more realistic balance.

[0031] Further, the task to be processed is a task stored in the task queue of the corresponding processor;

[0032] The task being processed is a task being executed by the thread of the corresponding processor;

[0033] The step S2 specifically includes:

[0034] S21, each of the processors synchronously acquires the type of the new task when acquiring the new task from the master node each time, and stores the corresponding integral number into the local cache according to the priority corresponding to the type;

[0035] S22, if the thread of the processor is full, the new task is stored into the task queue as the to-be-processed task, and the to-be-processed task is called from the task queue to be processed when the thread is idle, otherwise the new task is directly called as the processing task to be processed;

[0036] S23, when the processing task or the to-be-processed task in the processor is processed, the corresponding integral number in the local cache is synchronously deleted.

[0037] As can be seen from the above description, there are mainly two parts of tasks in each processor, one part is the task being executed by the thread, and the other part is the task stored in the task queue. When the processor acquires a new task each time without processing, the type of the task can be synchronously acquired first, and the integral number is acquired and stored into the local cache according to the priority corresponding to the type. In the subsequent execution process or in the process of being assigned to the task queue to be executed, the integral number does not need to be counted and cached again to prevent repeated addition of the integral number. At the same time, the corresponding integral number can be synchronously deleted when the task is executed, so as to ensure that the total integral number of each processor is accurate and reliable.

[0038] Further, the step S3 further includes:

[0039] If the difference between the total integral numbers of each of the processors is within a preset threshold range, the master node distributes the to-be-distributed data to each of the processors in a polling manner.

[0040] As can be seen from the above description, the difference between the total integral numbers of each processor is within a preset threshold range, that is, the task amount in each processor is close, so the tasks can be directly distributed to each processor by polling, thereby effectively improving the efficiency of task distribution.

[0041] Please refer to Figure 2 An optimization terminal for task distribution, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the following steps when executing the computer program:

[0042] S1, different types of tasks are divided into high to low priorities according to the processing rate of different types of tasks from fast to slow, and small to large integral numbers are sequentially assigned according to the priorities from high to low;

[0043] S2, each processor calculates corresponding priority score according to the type of the task to be processed and the type of the task being processed;

[0044] S3, the master node periodically acquires the total score of each processor, and preferentially allocates the task to be allocated to the processor corresponding to the lowest total score.

[0045] From the above description, the beneficial effects of the present application are that based on the same technical concept, in combination with the above-mentioned optimization method for task allocation, an optimization terminal for task allocation is provided, the priority of different types of tasks is distinguished according to the processing rate of various types of tasks, different priorities will have different scores, each processor can obtain the corresponding score of its own task according to the type of the task to be processed and the type of the task being processed, so that the master node can allocate new tasks according to the total score of each processor, that is, when there is a new task to be allocated in the master node, the new task will be preferentially allocated to the processor with a lower total score of the accumulated tasks in each processor, realizing accurate allocation of tasks, and finally the score of the processor can reach a relatively balanced state, ensuring the balance of the entire system.

[0046] Further, the step S1 further comprises the following steps:

[0047] S0, acquiring different types of processed tasks, and performing stress testing on different types of processed tasks to obtain the processing rate of different types of tasks.

[0048] From the above description, since the tasks being processed or already allocated to the corresponding processors for processing, the processing rate cannot be obtained, therefore, the processing rate of the processed tasks can be obtained by stress testing, and the different types of tasks are classified, and then the processing rate of different types of tasks is obtained as a standard for subsequent priority division and score assignment.

[0049] Further, the step S0 further comprises the following steps: periodically acquiring new processed tasks and repeating the above steps to update the processing rate of different types of tasks.

[0050] From the above description, in order to ensure accurate allocation of tasks, new processed tasks can be periodically acquired for stress testing to update the different processing rates corresponding to different types of tasks, dynamically adjust the priority and score corresponding to different types of tasks, and realize a more realistic balance.

[0051] Further, the task to be processed is a task stored in the task queue of the corresponding processor;

[0052] The processing task is specifically a task being executed by a thread of the corresponding processor;

[0053] The step S2 is specifically:

[0054] S21, each processor synchronously acquires the type of a new task each time the processor acquires the new task from the master node, and stores a corresponding integral number into a local cache according to a priority corresponding to the type;

[0055] S22, if the thread of the processor is full, the new task is stored into the task queue as the to-be-processed task, and the to-be-processed task is called from the task queue to be processed when the thread is idle, otherwise the new task is directly called as the processing task to be processed;

[0056] S23, when the processing task or the to-be-processed task in the processor is processed, the corresponding integral number in the local cache is synchronously deleted.

[0057] As can be known from the above description, there are mainly two parts of tasks in each processor, one part is a task being executed by a thread, and the other part is a task stored in a task queue. When a processor acquires a new task each time and the new task is not processed, the type of the new task can be synchronously acquired, and an integral number is acquired according to a priority corresponding to the type and stored into a local cache. In a subsequent execution process or a process of being assigned to a task queue to be executed, the integral number does not need to be counted and cached again to prevent the integral number from being added repeatedly. Meanwhile, when a task is executed, the corresponding integral number can be synchronously deleted, so that the total integral number of each processor is accurate and reliable.

[0058] Further, the step S3 further includes:

[0059] If the difference between the total integral numbers of the processors is within a preset threshold range, the master node assigns the to-be-assigned data to the processors in a polling manner.

[0060] The application provides a task assignment optimization method and a terminal, which are mainly applied to a scenario in which a master node or a master module assigns tasks in the Internet, and are specifically described below in combination with specific embodiments:

[0061] Please refer to Figure 1 , an embodiment of the application is:

[0062] A task assignment optimization method, as shown in Figure 1 , includes the following steps:

[0063] S1, different types of tasks are divided into high to low priorities according to processing rates of the different types of tasks from fast to slow, and small to large integral numbers are sequentially assigned according to the priorities from high to low.

[0064] In the embodiment, assuming that we divide different types of tasks into three priorities of fast, medium and slow according to processing rate, we can assign the task type with priority of fast with an integral number of 1, the task type with priority of medium with an integral number of 2, and the task type with priority of slow with an integral number of 3. That is, the higher the priority, the lower the integral number, representing the task processing block.

[0065] S2, each processor counts the corresponding priority integral number according to the type of the task to be processed and the type of the task being processed.

[0066] S3, the master node periodically acquires the integral total number of each processor in the local cache, and preferentially allocates the task to be allocated to the processor corresponding to the lowest integral total number.

[0067] That is, in the embodiment, different priorities of different types of tasks are divided according to the processing rate of various types of tasks, and different priorities will have different integral numbers. Each processor can obtain the integral number corresponding to the task according to the type of the task to be processed and the type of the task being processed, so that the master node can allocate new tasks according to the integral total number of each processor. That is, when there is a new task to be allocated in the master node, the new task will be preferentially allocated to the processor with a lower integral total number according to the integral total number of the accumulated tasks in each processor, realizing accurate allocation of tasks, and finally the integral number of the processor can reach a relatively balanced state, ensuring the balance of the entire system.

[0068] In addition, in the embodiment, since the processing rate of the task being processed or the task to be processed allocated to the corresponding processor cannot be obtained, the processing rate of the processed task can be obtained by means of stress test, and the different types of tasks are classified according to the type, and then the processing rate of different types of tasks is obtained, which is used as a standard for subsequent priority division and integral number assignment. That is, before step S1, the embodiment further includes:

[0069] S0, obtaining different types of processed tasks, and stress testing different types of processed tasks to obtain the processing rate of different types of tasks.

[0070] In order to ensure accurate allocation of tasks, new processed tasks can also be periodically obtained for stress testing to update the different processing rates of different types of tasks, dynamically adjust the priorities and integral numbers of different types of tasks, and realize a more realistic balance. That is, step S0 further includes:

[0071] Periodically obtaining new processed tasks and repeating the above steps to update the processing rate of different types of tasks.

[0072] Embodiment two of the present application is:

[0073] A task allocation optimization method, based on the above embodiment one, in this embodiment, the task to be processed is the task stored in the task queue of the corresponding processor, and the processing task is the task being executed by the thread of the corresponding processor. Then step S2 is specifically:

[0074] S21, each processor synchronously acquires the type of new task when acquiring new task from the master node each time, and stores the corresponding integral number in the local cache according to the priority corresponding to the type.

[0075] S22, if the thread of the processor is full, the new task is stored in the task queue as a task to be processed, and the task to be processed is called from the task queue to be processed when the thread is idle, otherwise the new task is directly called as a processing task to be processed.

[0076] S23, when the processing task or the task to be processed in the processor is completed, the corresponding integral number in the local cache is synchronously deleted.

[0077] That is, in this embodiment, there are mainly two parts of tasks in each processor, one part is the task being executed by the thread, and the other part is the task stored in the task queue. When the processor acquires a new task each time and has not been processed, the type of the task can be synchronously acquired first, and the integral number is acquired and stored in the local cache according to the priority corresponding to the type. In the subsequent execution process or in the process of being allocated to the task queue for execution, it is not necessary to count the integral number again for caching, so as to prevent the integral number from being added repeatedly. At the same time, the corresponding integral number can be synchronously deleted when the task is executed, so as to ensure that the total integral number of each processor is accurate and reliable.

[0078] In addition, in this embodiment, step S3 further includes:

[0079] If the difference between the total integral numbers of the processors is within the preset threshold range, the master node allocates the data to be allocated to the processors in a polling manner.

[0080] That is, the difference between the total integral numbers of the processors is within the preset threshold range, that is, the task amount in each processor is close, so that the tasks can be directly allocated to each processor by polling, thereby effectively improving the efficiency of task allocation.

[0081] Please refer to Figure 2 Embodiment three of the present application is:

[0082] An optimization terminal 1 of task allocation, comprising a memory 2, a processor 3, and a computer program stored in the memory 2 and executable on the processor 3, the processor 3 completes the steps in the task allocation optimization method of the above-mentioned embodiment one or embodiment two when executing the computer program.

[0083] In summary, the task allocation optimization method and terminal provided by the application can realize accurate task allocation, and the integral number of the final processor can reach a relatively balanced state, thereby ensuring the balance of the whole system.

[0084] The above-mentioned is only the embodiment of the application, and does not limit the patent range of the application, and any equivalent transformation, direct or indirect application in the related technical field by using the content of the application specification and drawings is also included in the patent protection range of the application.

Claims

1. An optimization method for task allocation, characterized in that, Including the following steps: S1. Based on the processing speed of different types of tasks from fast to slow, classify different task types into priorities from high to low, and assign points from low to high according to priority. S2. Each processor calculates its priority score based on the type of tasks to be processed and the types of tasks being processed. S3. The master node periodically obtains the total score of each processor and prioritizes assigning the tasks to be assigned to the processor with the lowest total score. The procedure preceding step S1 also includes: S0. Obtain different types of processed tasks and perform load testing on the different types of processed tasks to obtain the processing rate of different types of tasks; The tasks to be processed are the tasks stored in the task queue of the corresponding processor. The task in the process is specifically the task being executed by the thread of the corresponding processor. Step S2 specifically involves: S21. Each time a processor obtains a new task from the master node, it synchronously obtains the type of the new task and stores the corresponding points in the local cache according to the priority of the type. S22. If the processor's thread is full, the new task is stored in the task queue as the task to be processed. When the thread is idle, the task to be processed is called from the task queue. Otherwise, the new task is directly called as the task to be processed. S23. When the processing task or the pending task in the processor is completed, the corresponding points in the local cache are deleted synchronously.

2. The task allocation optimization method according to claim 1, characterized in that, Step S0 also includes: Periodically retrieve new processed tasks and repeat the above steps to update the processing rate for different types of tasks.

3. The task allocation optimization method according to claim 1, characterized in that, Step S3 further includes: If the difference between the total scores of each processor is within a preset threshold range, the master node will assign the task to be assigned to each processor in a round-robin manner.

4. An optimized terminal for task allocation, characterized in that, Includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, performs the following steps: S1. Based on the processing speed of different types of tasks from fast to slow, classify different task types into priorities from high to low, and assign points from low to high according to priority. S2. Each processor calculates its priority score based on the type of tasks to be processed and the types of tasks being processed. S3. The master node periodically obtains the total score of each processor and prioritizes assigning the tasks to be assigned to the processor with the lowest total score. The procedure preceding step S1 also includes: S0. Obtain different types of processed tasks and perform load testing on the different types of processed tasks to obtain the processing rate of different types of tasks; The tasks to be processed are the tasks stored in the task queue of the corresponding processor. The task in the process is specifically the task being executed by the thread of the corresponding processor. Step S2 specifically involves: S21. Each time a processor obtains a new task from the master node, it synchronously obtains the type of the new task and stores the corresponding points in the local cache according to the priority of the type. S22. If the processor's thread is full, the new task is stored in the task queue as the task to be processed. When the thread is idle, the task to be processed is called from the task queue. Otherwise, the new task is directly called as the task to be processed. S23. When the processing task or the pending task in the processor is completed, the corresponding points in the local cache are deleted synchronously.

5. The task allocation optimization terminal according to claim 4, characterized in that, Step S0 also includes: Periodically retrieve new processed tasks and repeat the above steps to update the processing rate for different types of tasks.

6. The task allocation optimization terminal according to claim 4, characterized in that, Step S3 further includes: If the difference between the total scores of each processor is within a preset threshold range, the master node will assign the task to be assigned to each processor in a round-robin manner.

Citation Information

Patent Citations

  • Task allocation method and system for multiple processing nodes

    CN111176833A

  • Task allocation method and device, storage medium and computer equipment

    CN115794328A