Adaptive load balancing task scheduling method and related devices
By using an adaptive load balancing task scheduling method, task routing and migration are dynamically adjusted based on task characteristics and queue length duration, solving the problem of insufficient resource adjustment in existing technologies and achieving uniform task distribution and efficient resource utilization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JINGZHOU NANHU MACHINERY CO LTD
- Filing Date
- 2026-03-16
- Publication Date
- 2026-06-30
AI Technical Summary
Existing technologies cannot adaptively adjust resources, causing the system to malfunction, especially in hardware-constrained and multi-threaded scenarios, leading to local overload and resource waste.
By routing tasks to corresponding task nodes based on task characteristics and dynamically adjusting the load in combination with task queue length and execution time, load balancing between and within task nodes is achieved. Hash algorithms and task migration mechanisms are used to dynamically adjust the task allocation strategy.
It achieves uniform distribution of task characteristics, reduces memory consumption and decision latency, improves system resource utilization and task processing efficiency, and solves the problems of uneven task distribution, differences in thread execution speed, and differences in node resources.
Smart Images

Figure CN122309064A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of task scheduling technology, and in particular to an adaptive load balancing task scheduling method and related apparatus. Background Technology
[0002] With the continuous development of computer technology and the increasing complexity of various application scenarios, the amount of data to be processed has increased, making load balancing a key technology to ensure the efficient and stable operation of the system.
[0003] In existing technologies, limitations imposed by the hardware environment and the strict requirement for domestically produced operating environments, such as the FT2000+ lacking a L3 cache and having four cores sharing an L2 cache, can impact performance and lead to differences in utilization if threads frequently access memory, the data volume exceeds the L2 cache capacity, or cores compete for memory access. Furthermore, in current pipelined architectures with multi-threaded scenarios, each node contains subscription, processing, and publishing threads. Processing is multi-threaded, and in scenarios with significant differences in processing time between pipeline nodes, vertical scaling is the only option, i.e., increasing the number of processing threads on high-load nodes. When a node is blocked, downstream nodes will inevitably be affected, easily leading to localized overload and resource waste.
[0004] This shows that existing technologies cannot adaptively adjust resources, causing the system to malfunction. Summary of the Invention
[0005] In view of this, it is necessary to provide an adaptive load balancing task scheduling method and related apparatus to solve the problem that the existing technology cannot adaptively adjust resources, resulting in the system failing to operate normally.
[0006] To address the aforementioned problems, in a first aspect, the present invention provides an adaptive load balancing task scheduling method, comprising:
[0007] Based on the task characteristics of the tasks to be executed, the tasks to be executed are routed to the task queues of the task threads in the corresponding task nodes, and the task threads in each task node execute the tasks to be executed in sequence according to the task queues of their respective task threads. The load of each task node is determined based on the task queue length of each task thread in each task node and the task execution time of each task to be executed, and tasks in high-load task nodes are moved to low-load task nodes. When it is detected that the task queue of a task thread in a task node is empty, the tasks to be executed in the task queues of other task threads in the task node are scheduled to be executed in the task thread whose task queue is empty.
[0008] In one possible implementation, the task to be executed is routed to the task queue of the corresponding task thread in the task node based on the task characteristics of the task to be executed, including: The parallel granularity of the task to be executed is determined based on the task characteristics of the task to be executed; The routing hash algorithm based on parallel granularity determines the tasks to be executed, and uses the hash algorithm to route the tasks to be executed to the task queue of the task thread in the corresponding task node.
[0009] In one possible implementation, the load of each task node is determined based on the task queue length of each task thread in each task node and the task execution duration of each task to be executed, and tasks in high-load task nodes are moved to low-load task nodes, including: The thread status of each task thread in each task node is obtained according to a preset period. The thread status includes the length of the task queue in the task thread and the average execution time of each task to be executed. The node load status of each task node is determined based on the thread state of each task thread. When the load difference between the high-load task node and the low-load task node exceeds the preset load difference threshold, the tasks to be executed in the high-load task node are scheduled to the low-load task node.
[0010] In one possible implementation, when it is detected that the task queue of a task thread in a task node is empty, the tasks to be executed in the task queues of other task threads in the task node are scheduled to be executed in the task thread whose task queue is empty, including: When the task queue of a task thread in a task node is detected to be empty, record the task waiting time. When the task waiting time exceeds the preset task waiting timeout, the tasks to be executed in the task queues of other task threads in the task node will be scheduled to be executed in the task thread whose task queue is empty in the task node.
[0011] In one possible implementation, tasks to be executed from the task queues of other task threads in the task node are scheduled to be executed in task threads whose task queues are empty in the task node, including: Determine the task queue length of other task threads in the task node; Schedule the pending tasks in the other task threads with the longest task queue to the task threads in the task node where the task queue is empty for execution.
[0012] In one possible implementation, if a new task is assigned to a task thread whose task queue is empty within the preset task waiting timeout period, the task waiting timeout period is reset.
[0013] In one possible implementation, task nodes communicate with each other through a model of publishing and subscribing to messages to content nodes, while task threads within a task node communicate with each other through local queues.
[0014] Secondly, the present invention also provides an adaptive load balancing task scheduling device, comprising: The task allocation module is used to route tasks to be executed to the task queues of the task threads in the corresponding task nodes based on the task characteristics of the tasks to be executed. The task threads in each task node execute the tasks to be executed sequentially according to the task queues of their respective task threads. The cross-node task scheduling module is used to determine the load of each task node based on the task queue length of each task thread in each task node and the task execution time of each task to be executed, and to move tasks in high-load task nodes to low-load task nodes. The intra-node task scheduling module is used to schedule tasks to be executed from the task queues of other task threads in the task node to the task thread with the empty task queue when the task queue of the task thread in the task node is detected to be empty.
[0015] Thirdly, the present invention also provides an electronic device, including a memory and a processor, wherein, Memory, used to store programs; A processor, coupled to memory, is used to execute programs stored in memory to implement steps in the adaptive load balancing task scheduling method described above.
[0016] Fourthly, the present invention also provides a computer-readable storage medium for storing a computer-readable program or instruction, which, when executed by a processor, enables the implementation of steps in the adaptive load balancing task scheduling method described above.
[0017] The beneficial effects of this invention are as follows: The adaptive load balancing task scheduling method provided by this invention routes tasks to be executed to the task queues of task threads in the corresponding task nodes based on the task characteristics of the tasks to be executed. The task threads in each task node execute the tasks to be executed sequentially according to their respective task queues. Routing tasks to be executed based on task characteristics can evenly distribute task characteristics across queues, ensuring initial load balancing and reducing memory consumption and decision latency. Furthermore, the load of each task node is determined based on the task queue length of each task thread and the execution time of each task to be executed, and tasks from high-load task nodes are moved to low-load task nodes, achieving... Load balancing between task nodes is achieved by scheduling pending tasks from other task threads in the same task node to the empty task thread when the task queue of a task thread in the task node is detected to be empty. This achieves load balancing among task threads within the node. Through a three-level coordination mechanism of task routing, task migration between nodes, and work scheduling between threads within the node, the problem of uneven task distribution, differences in the execution speed of processing threads, and differences in the resources of processing nodes in high-density computational tasks in a distributed environment, which exists in traditional architectures, is successfully solved. By monitoring performance indicators such as queue load and task processing time in real time, the task allocation strategy is dynamically adjusted to achieve fine-grained load balancing of tasks. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 A flowchart illustrating an adaptive load balancing task scheduling method provided in an embodiment of the present invention; Figure 2 A flowchart illustrating a task routing method provided in an embodiment of the present invention; Figure 3 A flowchart illustrating an inter-node task scheduling method provided in an embodiment of the present invention; Figure 4 A flowchart illustrating an intra-node task scheduling method provided in an embodiment of the present invention; Figure 5 A flowchart illustrating an implementation method of S402 provided in an embodiment of the present invention; Figure 6 A timing diagram of an adaptive load balancing task scheduling method provided in an embodiment of the present invention; Figure 7A schematic diagram of the structure of an adaptive load balancing task scheduling device provided in an embodiment of the present invention; Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0020] The preferred embodiments of the present invention will now be described in detail with reference to the accompanying drawings, which constitute a part of the present invention and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not intended to limit the scope of the present invention.
[0021] The terms "first," "second," etc., used in the embodiments of this invention are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a technical feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature.
[0022] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0023] A specific embodiment of the present invention, such as Figure 1 As shown, an adaptive load balancing task scheduling method is disclosed, including: S101, based on the task characteristics of the task to be executed, the task to be executed is routed to the task queue of the task thread in the corresponding task node, and the task thread in each task node executes the task to be executed in sequence according to the task queue of each task thread.
[0024] In this embodiment of the invention, the provided adaptive load balancing task scheduling method is applicable to data processing systems, such as radar data processing systems, and is used to adaptively load balance various data processing tasks of the radar system to achieve rational utilization of system resources and improve task processing efficiency.
[0025] In this embodiment of the invention, the task to be executed refers to the task that needs to be executed, including but not limited to tasks of various dimensions. When the system is assigned a new task to be executed, it is necessary to determine the task node and task thread corresponding to the task to be executed based on the task characteristics of the task to be executed. Specifically, the routing algorithm of the task to be executed can be determined based on the task characteristics of the task to be executed, and then the corresponding task node and task thread can be determined based on the routing algorithm. The determination of the routing algorithm will be described in detail later in this invention.
[0026] In this embodiment of the invention, after the subscription thread in the task node receives the data published by the upstream node, it routes the task data to the thread pool queue. The worker thread in the thread pool checks whether there is task data in the queue. If there is, it retrieves the task from the queue and executes it. After the task is executed, the result data is transmitted to the publishing queue. The publishing thread retrieves the data in the publishing queue and then transmits it to the downstream node.
[0027] S102, determine the load of each task node based on the task queue length of each task thread in each task node and the task execution time of each task to be executed, and move the tasks in the high-load task nodes to the low-load task nodes.
[0028] In this embodiment of the invention, due to uneven task distribution among nodes or different task execution times within each node, an unbalanced load may occur between nodes. To solve this problem, this embodiment of the invention achieves load balancing between nodes through cross-node task scheduling. Specifically, the load of each task node is determined based on the task queue length of each task thread in each task node and the task execution time of each task to be executed. Then, the task node with the highest load and the task node with the lowest load are determined, and the tasks to be executed in the task node with the highest load are scheduled to the task node with the lowest load. The process of determining the node load will be described in detail later in this invention.
[0029] S103, when it is detected that the task queue of the task thread in the task node is empty, the tasks to be executed in the task queues of other task threads in the task node are scheduled to be executed in the task thread whose task queue is empty.
[0030] In this embodiment of the invention, the aforementioned embodiment achieves load balancing between nodes through task scheduling between nodes. For each task thread within a single node, there may also be a situation of task imbalance. For example, when it is detected that the task queue of a task thread in a task node is empty, the tasks to be executed in the task queues of other task threads in the task node are scheduled to be executed in the task thread whose task queue is empty in the task node.
[0031] The adaptive load balancing task scheduling method provided by this invention routes tasks to be executed to the task queues of task threads in corresponding task nodes based on the task characteristics of the tasks to be executed. Task threads in each task node execute tasks sequentially according to their respective task queues. Routing tasks based on task characteristics ensures that these characteristics are evenly distributed across queues, guaranteeing initial load balancing and reducing memory consumption and decision latency. The load of each task node is determined based on the task queue length of each task thread and the execution duration of each task, and tasks from high-load task nodes are moved to low-load task nodes, achieving seamless coordination between task nodes. The system achieves load balancing by scheduling tasks from other task threads within the same node to the empty task thread when the task queue of a task thread in the node is detected to be empty. This achieves load balancing among task threads within the node. Through a three-level coordination mechanism of task routing, inter-node task migration, and inter-thread work scheduling within the node, the system successfully solves the problems of uneven task distribution, differences in thread execution speed, and differences in node resources in the processing of high-density computational tasks in a distributed environment, which exist in traditional architectures. By monitoring performance indicators such as queue load and task processing time in real time, the system dynamically adjusts the task allocation strategy to achieve fine-grained load balancing.
[0032] In some possible embodiments of the present invention, such as Figure 2 As shown, based on the task characteristics of the task to be executed, the task is routed to the task queue of the task thread in the corresponding task node, including: S201, determine the parallel granularity of the task to be executed based on the task characteristics of the task to be executed; S202 is a routing hash algorithm based on parallel granularity for determining tasks to be executed. It uses a hash algorithm to route tasks to be executed to the task queue of the task thread in the corresponding task node.
[0033] In this embodiment of the invention, after the subscribing thread receives data, it uses a task-characteristic-based routing algorithm to allocate tasks to queues in the thread pool. For pulse compression nodes, the received data consists of multiple residing data streams, and all input data are independent and can be processed in parallel. Here, the task characteristic is a path index, and data from different paths can be mapped to worker thread queues based on the path index hash, thereby achieving path-level load balancing. For cancellation nodes, multiple residing data streams need to be collected before processing, so the parallel granularity here is not single-path but multi-path. The task characteristic can be set as a residing index, and data from different residing paths can be mapped to worker thread queues based on the residing index hash, thereby achieving residing-level load balancing. This characteristic-based hash routing algorithm can evenly distribute task characteristics to various queues, ensuring initial load balancing and reducing memory consumption and decision latency. Tasks with the same characteristics will be routed to the same queue. During debugging and troubleshooting, the hash routing results can be reproduced, facilitating the tracing of task paths.
[0034] The embodiments of the present invention determine the task node and task thread corresponding to the task to be executed by task routing, thereby achieving initial load balancing.
[0035] In some possible embodiments of the present invention, such as Figure 3 As shown, the load of each task node is determined based on the task queue length of each task thread in each task node and the task execution time of each task to be executed, and tasks in high-load task nodes are moved to low-load task nodes, including: S301, according to a preset period, obtain the thread status of each task thread in each task node. The thread status includes the length of the task queue in the task thread and the average execution time of each task to be executed. S302, determine the node load status of each task node based on the thread status of each task thread, and when the load difference between the high-load task node and the low-load task node exceeds the preset load difference threshold, schedule the tasks to be executed in the high-load task node to the low-load task node.
[0036] In this embodiment of the invention, for load balancing among task nodes, the load status of each task node is determined by periodically obtaining the task queue length and task execution time of each task thread in each task node, and tasks from high-load nodes are migrated to low-load nodes. Specifically, each node registers with the global thread pool using its node component ID and thread pool as keys, achieving unified scheduling and management of the global thread pool. Node attributes in the global thread pool are periodically refreshed by the thread pool aggregation thread. In the global stealing thread, the optimal stealing pair is first found, identifying the nodes with the highest and lowest loads, and stealing is triggered only when the load difference between the two exceeds a stealing threshold. Then, the busiest queue of the node with the highest load and the idlest queue of the node with the lowest load are obtained, and tasks from the busy queue are stolen in batches and moved to the idle queue. The load rating decision is determined by the queue length and the average task execution time.
[0037] This invention achieves load balancing among nodes based on their load status, thus making full use of node resources.
[0038] In some possible embodiments of the present invention, such as Figure 4 As shown, when the task queue of a task thread in a task node is detected to be empty, the tasks to be executed in the task queues of other task threads in the task node are scheduled to be executed in the task thread whose task queue is empty, including: S401, when it is detected that the task queue of the task thread in the task node is empty, record the task waiting time; S402, when the task waiting time exceeds the preset task waiting timeout, the tasks to be executed in the task queues of other task threads in the task node will be scheduled to be executed in the task thread whose task queue is empty in the task node.
[0039] In this embodiment of the invention, after a worker thread starts running, it first reads data from the task queue in a blocking manner. If the task queue contains data, it retrieves and executes it; otherwise, it remains blocked. Subsequently, data is read from the task queue according to a timeout period. If no data is received within the timeout period, tasks from other threads are stolen. The timeout period is set as needed before retrieving a task, and the setting strategy is to determine the time based on a combination of factors such as the execution time of the previous task and the queue length within a protection interval. Considering performance, the frequency of setting the timeout period is equal to the number of threads in the current thread pool; that is, threads processing in parallel share a single timeout period.
[0040] This invention improves the execution efficiency of tasks on a single task node and increases the utilization rate of task threads by scheduling tasks of each task thread within a task node.
[0041] In some possible embodiments of the present invention, such as Figure 5As shown, scheduling tasks to be executed from the task queues of other task threads in a task node to task threads whose task queues are empty in the task node includes: S501, Determine the task queue length of other task threads in the task node; S502 schedules the pending tasks in the other task thread with the longest task queue to the task thread in the task node where the task queue is empty for execution.
[0042] In this embodiment of the invention, when scheduling tasks within a node, it is first determined whether the number of threads in the thread pool is at least two. Then, the longest queue (excluding the current queue) is selected from the thread pool, and the task is retrieved and executed. If no suitable queue is found, the task is retrieved from the next queue adjacent to the current queue. In this way, when a core is idle, it can share the tasks of threads on other cores within the acceptable waiting time. Moreover, the waiting time for each node is different, and the waiting time for the same node is also different each time, depending on factors such as the processing time of the previous time, thus completing a feedback closed loop from waiting to execution and back to waiting.
[0043] Furthermore, if a new task is assigned to a task thread that is empty within the preset task waiting timeout period, the task waiting timeout period is reset.
[0044] In this embodiment of the invention, for a task thread in a task node, when the task queue of this task thread is empty, it starts to wait and records the waiting time. Before the waiting time exceeds the waiting timeout period, if a new task to be executed is assigned to the task queue of this task thread, the waiting is canceled and the task waiting time is reset.
[0045] In some possible embodiments of the present invention, task nodes communicate with each other through a model of publishing and subscribing to messages to content nodes, and task threads within a task node communicate with each other through a local queue.
[0046] In this embodiment of the invention, inter-node communication is accomplished via SUB-PUB (a model for publishing and subscribing to messages to content nodes). For example, in the subscription thread, data from upstream nodes is subscribed to using the SUB mode, while the publishing thread sends data processed by the current node using the PUB mode. Intra-node communication is handled by local queues, including enqueuing data received and dequeuing tasks from worker threads using a processing queue, enqueuing data after processing in the publishing queue, and dequeuing processing results from the publishing thread. This preserves node scalability and flexibility, supports distributed deployment, and saves on intra-node communication overhead.
[0047] Furthermore, to better illustrate the adaptive load balancing task scheduling method provided by this invention, such as... Figure 6 The diagram shows the sequence of the adaptive load balancing task scheduling method. When an upstream node publishes a task, the component object's subscription thread receives and submits the task to the task queue of the thread pool. Here, the routing decision is based on a hash algorithm using task characteristics. Then, worker threads in the thread pool execute tasks based on the current task queue load. If the queue is empty, they steal tasks from peer threads; otherwise, they retrieve tasks and execute them locally. Regardless of whether tasks are stolen or executed locally, current thread attributes, including execution time, queue length, and the number of successful steals, are updated in real time. Simultaneously, the aggregation thread in the thread pool periodically aggregates the states of all threads in the thread pool as the current node state and synchronizes this to offline nodes in the global thread pool. Furthermore, the global thread pool periodically retrieves the current optimal cross-node migration pair (the highest-loaded node and the lowest-loaded node) and selects the busiest queue from the highest-loaded node, assigning tasks from that queue to the idlest queue of the lowest-loaded node. Finally, after completing their tasks, worker threads send the results to the publishing queue. The publishing thread then extracts the data from the publishing queue and publishes it to downstream nodes.
[0048] Furthermore, to verify the implementation effect of the adaptive load balancing task scheduling method provided in this embodiment of the invention, various load experiments were conducted on computationally intensive tasks under both traditional and new architectures. The experimental physical environment used an FT2000+ processor with an ARMv8 architecture. The chip is based on a data-affinity multi-core processor architecture, integrating 64 FTC662 processor cores, divided into 8 panels. Each panel contains two clusters (each cluster contains 4 processor cores), 4MB of L2 cache, and the 4 cores in the same cluster share 2MB of L2 cache. On average, each core has 512KB of available L2 cache, with no L3 cache. A certain project's signal processing workflow comprises six processes. Based on process division and pipeline rules, through analysis and comparison, the core process with the longest processing time, which determines the overall workflow time, was first identified. Then, through analysis and comparison of memory usage, load, and time consumption at each pipeline node under this core process, the two key nodes with the longest consumption and highest load—the pulse compression PC and the cancellation IC—were identified as the main influencing factors on the overall load and time consumption. Below is a comparison of the overall time consumption of the key nodes of this core process under different scenarios with different PRTs and different numbers of cores, using both new and traditional architectures. The new architecture environment uses one board, while the traditional architecture uses two boards. The table below shows a comparison of the overall time consumption of the two architectures in various scenarios:
[0049] Taking Scenario 1 as an example, the PRT of the front-end input data is 1000us, and the dwell time is 48000us. Under the new architecture, 4 cores are allocated to the thread pool of the pulse compression node PC, and 2 cores are allocated to its downstream cancellation node IC. All processes run on one board, and the average time for the entire process is 66121.77049us, with an average absolute deviation of 263.3227627. In the traditional architecture, 12 cores are allocated to the thread pool of the pulse compression node PC, and 4 cores are allocated to its downstream cancellation node IC. All processes run on two boards, and the average time for the entire process is 61415.36066us, with an average absolute deviation of 1735.833378. By observing the two sets of data, although the traditional architecture is faster, saving about 5ms, the average absolute deviation is larger. When more cores are allocated to the PC and IC, the physical operating environment is more flexible, and the traditional architecture has a greater speed advantage, but its stability is not as good as the new architecture. When the number of cores in the PC and IC are set to the same value (5 and 2 respectively), and the hardware environment remains the same (the traditional architecture has one more board than the new architecture), the overall process time for both is approximately 63ms. However, the new architecture exhibits a smaller average absolute deviation, meaning its output time is more stable than the traditional architecture. In conclusion, by halving the hardware resources, and ensuring that the number of cores at critical nodes remains the same without significantly increasing the time required, the new architecture offers a stability improvement of over 50%.
[0050] This invention successfully solves three fundamental problems of traditional architectures in distributed environments with high-density computational tasks through a three-level coordination mechanism: task routing, intra-node thread work scheduling, and inter-node task migration. These problems are uneven distribution of processing tasks, differences in the execution speed of processing threads, and differences in the resources of processing nodes.
[0051] To better implement the adaptive load balancing task scheduling method in this embodiment of the invention, based on the adaptive load balancing task scheduling method, correspondingly, as follows: Figure 7 As shown, this embodiment of the invention also provides an adaptive load balancing task scheduling device 700, which includes: The task allocation module 701 is used to route the tasks to be executed to the task queues of the task threads in the corresponding task nodes based on the task characteristics of the tasks to be executed. The task threads in each task node execute the tasks to be executed sequentially according to the task queues of their respective task threads. The cross-node task scheduling module 702 is used to determine the load of each task node based on the task queue length of each task thread in each task node and the task execution time of each task to be executed, and to move the tasks in the high-load task nodes to the low-load task nodes. The intra-node task scheduling module 703 is used to schedule tasks to be executed in the task queues of other task threads in the task node to the task thread whose task queue is empty when the task queue of the task thread in the task node is detected to be empty.
[0052] The adaptive load balancing task scheduling device 700 provided in the above embodiments can implement the technical solutions described in the above adaptive load balancing task scheduling method embodiments. The specific implementation principles of each module or unit can be found in the corresponding content in the above adaptive load balancing task scheduling method embodiments, and will not be repeated here.
[0053] like Figure 8 As shown, the present invention also provides an electronic device 800. The electronic device 800 includes a processor 801, a memory 802, and a display 803. Figure 8 Only some components of the electronic device 800 are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
[0054] In some embodiments, processor 801 may be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run program code stored in memory 802 or process data, such as the adaptive load balancing task scheduling method of the present invention.
[0055] In some embodiments, processor 801 may be a single server or a group of servers. The server group may be centralized or distributed. In some embodiments, processor 801 may be local or remote. In some embodiments, processor 801 may be implemented on a cloud platform. In some embodiments, the cloud platform may include private cloud, public cloud, hybrid cloud, community cloud, distributed cloud, internal cloud, multi-cloud, etc., or any combination thereof.
[0056] In some embodiments, memory 802 may be an internal storage unit of electronic device 800, such as a hard disk or memory of electronic device 800. In other embodiments, memory 802 may also be an external storage device of electronic device 800, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. equipped on electronic device 800.
[0057] Furthermore, the memory 802 may include both internal storage units of the electronic device 800 and external storage devices. The memory 802 is used to store application software and various types of data installed on the electronic device 800.
[0058] In some embodiments, display 803 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. Display 803 is used to display information from electronic device 800 and to display a visual user interface. Components 801-803 of electronic device 800 communicate with each other via a system bus.
[0059] In some embodiments, when the processor 801 executes the adaptive load balancing task scheduler in the memory 802, the following steps may be implemented: Based on the task characteristics of the tasks to be executed, the tasks to be executed are routed to the task queues of the task threads in the corresponding task nodes, and the task threads in each task node execute the tasks to be executed in sequence according to the task queues of their respective task threads. The load of each task node is determined based on the task queue length of each task thread in each task node and the task execution time of each task to be executed, and tasks in high-load task nodes are moved to low-load task nodes. When it is detected that the task queue of a task thread in a task node is empty, the tasks to be executed in the task queues of other task threads in the task node are scheduled to be executed in the task thread whose task queue is empty.
[0060] It should be understood that when the processor 801 executes the adaptive load balancing task scheduler in the memory 802, in addition to the functions mentioned above, it can also perform other functions, as detailed in the description of the corresponding method embodiments above.
[0061] Furthermore, this embodiment of the invention does not specifically limit the type of electronic device 800 mentioned. Electronic device 800 can be a mobile phone, tablet computer, personal digital assistant (PDA), wearable device, laptop computer, or other portable electronic device. Exemplary embodiments of portable electronic devices include, but are not limited to, portable electronic devices running iOS, Android, Microsoft, or other operating systems. The aforementioned portable electronic device can also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the invention, electronic device 800 may not be a portable electronic device, but rather a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0062] Accordingly, embodiments of the present invention also provide a computer-readable storage medium for storing computer-readable programs or instructions. When the programs or instructions are executed by a processor, they can implement the steps or functions of the adaptive load balancing task scheduling method provided in the above-described method embodiments.
[0063] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware, and the program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0064] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. An adaptive load balancing task scheduling method, characterized in that, include: Based on the task characteristics of the tasks to be executed, the tasks to be executed are routed to the task queues of the task threads in the corresponding task nodes, and the task threads in each task node execute the tasks to be executed in sequence according to the task queues of their respective task threads. The load of each task node is determined based on the task queue length of each task thread in each task node and the task execution time of each task to be executed, and tasks in high-load task nodes are moved to low-load task nodes. When it is detected that the task queue of a task thread in a task node is empty, the tasks to be executed in the task queues of other task threads in the task node are scheduled to be executed in the task thread whose task queue is empty.
2. The adaptive load balancing task scheduling method according to claim 1, characterized in that, The step of routing tasks to the task queue of the corresponding task thread in the task node based on the task characteristics of the task to be executed includes: The parallel granularity of the task to be executed is determined based on the task characteristics of the task to be executed; Based on the parallel granularity, the routing hash algorithm for the task to be executed is determined, and the hash algorithm is used to route the task to be executed to the task queue of the task thread in the corresponding task node.
3. The adaptive load balancing task scheduling method according to claim 1, characterized in that, The process of determining the load of each task node based on the task queue length of each task thread in each task node and the task execution time of each task to be executed, and moving tasks from high-load task nodes to low-load task nodes, includes: The thread status of each task thread in each task node is obtained according to a preset period. The thread status includes the length of the task queue in the task thread and the average execution time of each task to be executed. The node load status of each task node is determined based on the thread state of each task thread. When the load difference between the high-load task node and the low-load task node exceeds a preset load difference threshold, the tasks to be executed in the high-load task node are scheduled to the low-load task node.
4. The adaptive load balancing task scheduling method according to claim 1, characterized in that, The step of scheduling tasks to be executed from the task queues of other task threads in the task node to the task thread with the empty task queue when the task queue of a task thread in the task node is detected to be empty includes: When the task queue of a task thread in a task node is detected to be empty, record the task waiting time. When the task waiting time exceeds the preset task waiting timeout period, the tasks to be executed in the task queues of other task threads in the task node are scheduled to be executed in the task thread whose task queue is empty in the task node.
5. The adaptive load balancing task scheduling method according to claim 4, characterized in that, The step of scheduling tasks to be executed from the task queues of other task threads in the task node to task threads whose task queues are empty in the task node includes: Determine the task queue length of other task threads in the task node; The tasks to be executed in the other task threads with the longest task queue are scheduled to be executed in the task threads in the task node where the task queue is empty.
6. The adaptive load balancing task scheduling method according to claim 4, characterized in that, If a new task is assigned to a task thread that is empty within the preset task waiting timeout period, the task waiting timeout period is reset.
7. The adaptive load balancing task scheduling method according to claim 1, characterized in that, The task nodes communicate with each other through a model of publishing and subscribing to messages to content nodes, and the task threads within each task node communicate with each other through a local queue.
8. An adaptive load balancing task scheduling device, characterized in that, include: The task allocation module is used to route tasks to be executed to the task queues of the task threads in the corresponding task nodes based on the task characteristics of the tasks to be executed. The task threads in each task node execute the tasks to be executed sequentially according to the task queues of their respective task threads. The cross-node task scheduling module is used to determine the load of each task node based on the task queue length of each task thread in each task node and the task execution time of each task to be executed, and to move tasks in high-load task nodes to low-load task nodes. The intra-node task scheduling module is used to schedule tasks to be executed from the task queues of other task threads in the task node to the task thread whose task queue is empty when the task queue of the task thread in the task node is detected to be empty.
9. An electronic device, characterized in that, Including memory and processor, among which, The memory is used to store programs; The processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps of the adaptive load balancing task scheduling method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps of the adaptive load balancing task scheduling method according to any one of claims 1 to 7.