Task scheduling method and device based on load balancing, equipment and storage medium
By calculating the priority coefficient of the pending tasks and the server resource utilization rate, determining the target server of the task, the problem of unreasonable task scheduling in the existing technology is solved, and the task execution efficiency and effectiveness are improved.
Patent Information
- Application Number
- CN202411811951.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-25
AI Technical Summary
In the prior art, when the polling algorithm performs task scheduling in a distributed system, the current resource usage of each server and the urgency of the pending tasks are not taken into account, resulting in the task being unable to be scheduled to a suitable server for execution.
By determining the server resources required for each pending task and the expected processing time, the priority coefficient of the task is calculated, and the resource utilization rate of each server in the server cluster is calculated in real time, thereby determining the target server that performs each pending task.
It realizes a more reasonable scheduling of appropriate servers for pending tasks, improves the efficiency and effectiveness of task execution, and ensures that tasks are allocated reasonably according to urgency and resource availability.
Smart Images

Figure CN119883544A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of load balancing, and in particular to a method, device, equipment and storage medium for task scheduling based on load balancing. Background Art
[0002] In a distributed system, pending tasks need to be scheduled so that the server can execute them. Since the number of tasks that a single server can execute is limited, a load balancing algorithm (e.g., a round-robin algorithm) is used to schedule and execute tasks through a server cluster. However, the round-robin algorithm does not take into account the current resource usage of each server, nor the urgency of the pending tasks, resulting in the inability to schedule pending tasks to the appropriate server for execution.
[0003] Therefore, how to schedule the tasks to be processed to be executed by the appropriate server has become a technical problem that needs to be solved urgently by those skilled in the art. It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the invention
[0004] In view of the above, the present application provides a task scheduling method, device, equipment and storage medium based on load balancing, which aims to solve the above technical problems.
[0005] In a first aspect, the present application provides a task scheduling method based on load balancing, the method comprising:
[0006] Determine the server resources required to execute each pending task and the expected processing time corresponding to each pending task;
[0007] Calculate the priority coefficient of each of the tasks to be processed according to the server resources required by the tasks to be processed and the expected processing time;
[0008] Calculate the resource usage of each server in the server cluster in real time;
[0009] According to the priority coefficient and the resource usage rate of each server, a target server for executing each of the tasks to be processed is determined from the server cluster.
[0010] In a second aspect, the present application provides a task scheduling device based on load balancing, the device comprising:
[0011] Acquisition module: used to acquire video data of the area to be inspected and multiple types of sensor data;
[0012] Determination module: used to determine the server resources required to execute each pending task and the expected processing time corresponding to each pending task;
[0013] A first calculation module: used for calculating the priority coefficient of each task to be processed according to the server resources required by the task to be processed and the expected processing time;
[0014] The second calculation module: used to calculate the resource usage rate of each server in the server cluster in real time;
[0015] Scheduling module: used to determine the target server to execute each of the tasks to be processed from the server cluster according to the priority coefficient and the resource utilization rate of each server.
[0016] In a third aspect, the present application provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0017] Memory, used to store computer programs;
[0018] The processor is used to implement the load balancing-based task scheduling method described in any embodiment of the first aspect when executing the program stored in the memory.
[0019] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the load balancing-based task scheduling method as described in any embodiment of the first aspect is implemented.
[0020] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:
[0021] The present application determines the server resources required to execute each pending task and the expected processing time corresponding to each pending task, calculates the priority coefficient of each pending task according to the server resources required for the pending task and the expected processing time, calculates the resource utilization rate of each server in the server cluster in real time, and determines the target server for executing each pending task from the server cluster according to the priority coefficient and the resource utilization rate of each server. Since the resource utilization rate of the server represents the current idleness of the server and the priority coefficient of the pending task represents the urgency of the task execution, the target server for executing each pending task is determined from the server cluster according to the priority coefficient and the resource utilization rate of each server, so that the appropriate server can be more reasonably scheduled to execute the task. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0023] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0024] Figure 1 This is a flow chart of an embodiment of a task scheduling method based on load balancing of the present application;
[0025] Figure 2 This is a module diagram of an embodiment of a task scheduling device based on load balancing of the present application;
[0026] Figure 3 A schematic diagram of an electronic device embodiment of the present application;
[0027] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0029] The disclosure below provides many different embodiments or examples to realize the different structures of the present application. In order to simplify the disclosure of the present application, the parts and settings of specific examples are described below. Of course, they are only examples, and the purpose is not to limit the present application. In addition, the present application can repeat reference numbers and / or letters in different examples. This repetition is for the purpose of simplification and clarity, and does not itself indicate the relationship between the various embodiments and / or settings discussed.
[0030] The present application provides a task scheduling method based on load balancing. Figure 1 , which is a method flow diagram of an embodiment of a task scheduling method based on load balancing of the present application. The method can be executed by an electronic device, which is implemented by software and / or hardware. The task scheduling method based on load balancing includes:
[0031] Step S10: determining the server resources required to execute each task to be processed and the expected processing time corresponding to each task to be processed;
[0032] Step S20: Calculating the priority coefficient of each of the tasks to be processed according to the server resources required by the tasks to be processed and the expected processing time;
[0033] Step S30: Calculate the resource usage rate of each server in the server cluster in real time;
[0034] Step S40: determining a target server for executing each of the tasks to be processed from the server cluster according to the priority coefficient and the resource usage rate of each server.
[0035] In this embodiment, the tasks to be processed may refer to computing tasks, I / O tasks, real-time data processing tasks, etc., wherein computing tasks may include data analysis tasks, data conversion tasks, data cleaning tasks, image recognition tasks, video decoding tasks, etc. I / O tasks may include file upload / download tasks, database query tasks, network request processing tasks, etc. Real-time data processing tasks may include tasks for processing real-time data streams and processing tasks triggered by events, etc.
[0036] Since certain server resources (for example, CPU resources, memory resources, network resources, etc.) are required when the pending tasks are executed, in order to optimize the scheduling of tasks, the server resources required for the execution of each pending task can be estimated in advance, as well as the expected processing time corresponding to each pending task, that is, how long it takes from the start of the server executing the pending task to the end of the execution of the pending task.
[0037] The server resources required for each task and the expected processing time can be determined or estimated in advance through static analysis, machine learning model prediction, etc., and the server resources required for each task and the expected processing time obtained from the analysis can be stored in a data table. When the same or similar tasks to be processed need to be scheduled later, the server resources required for the task and the expected processing time can be determined or estimated by referring to the data table.
[0038] In actual applications, there are many types of tasks to be processed, and the completion time and resource requirements of each task are different. Therefore, the priority coefficient of each task to be processed can be calculated based on the server resources required for the task to be processed and the expected processing time, so as to more reasonably allocate corresponding server resources to the task to be processed and optimize the execution order of the tasks.
[0039] Specifically, the priority coefficient of each task to be processed is calculated according to the server resources required by the task to be processed and the expected processing time, including:
[0040] Obtaining the maximum waiting time of the task to be processed and the historical execution frequency of the task to be processed;
[0041] Based on the maximum waiting time and the expected processing time, determine the time between the current and the latest execution time of the task to be processed;
[0042] The priority coefficient of each of the tasks to be processed is calculated according to the server resources required by the tasks to be processed, the maximum waiting time, the historical execution frequency and the time from the current time to the latest execution time.
[0043] The maximum waiting time of a pending task reflects the timeliness of the pending task, and the historical execution frequency of the pending task reflects the execution frequency of the same task within a certain period of time. Tasks with high execution frequency usually also have to have a certain priority. Through the maximum waiting time of a pending task and the expected processing time of the pending task, the distance between the current and the latest execution time of the pending task can be determined. For example, if the maximum waiting time of a task is 1 second and the expected processing time of the task is 0.2 seconds, then the distance between the current and the latest execution time is 0.8 seconds. The distance between the current and the latest execution time reflects the urgency of the pending task. Therefore, the priority coefficient of each pending task can be calculated based on the server resources required for the pending task, the maximum waiting time, the historical execution frequency, and the distance between the current and the latest execution time, combined with the preset adjustment parameters.
[0044] The formula for calculating the priority coefficient of each task to be processed includes:
[0045]
[0046] Among them, Q represents the priority coefficient, N represents the distance from the current time to the latest execution time, M represents the maximum waiting time, F represents the historical execution frequency, C represents the server resources required for the task to be processed, a represents the first nonlinear adjustment parameter, and b represents the second nonlinear adjustment parameter.
[0047] The Q value reflects the priority order of task execution. The higher the priority coefficient of the task to be processed, the higher the order in which the task is executed by the server. The N value reflects the remaining time of the task from the maximum waiting time. The M value reflects the maximum waiting time that the task can accept. The range of the M value depends on the type of task and the characteristics of the task. In some scenarios, the higher the historical execution frequency of the task, that is, the higher the F value, usually reflects the higher importance of the task. Therefore, the historical execution frequency also needs to be considered as one of the factors for task priority. The C value is the server resources required for the task to be processed. The C value and other factors jointly affect the priority coefficient.
[0048] The a value can ensure that tasks with a shorter time to the latest execution time can be executed first. The value range of a value can be 0≤a≤2. When the a value is small, the server resources required by the task have a weaker nonlinear effect on the Q value. On the contrary, when the a value is large, the server resources required by the task have a stronger effect on the Q value.
[0049] The b value is used to balance the server resources required for the task and the historical execution frequency of the task, to prevent tasks that require more server resources from being ignored when they are used at a low frequency. The value range of the b value can be 0≤b≤8. The b value affects the adjustment effect of the a value, ensuring that the priority coefficient Q value can reasonably reflect the priority execution requirements of the tasks to be processed under different historical execution frequencies and required server resources.
[0050] Calculate the priority coefficient of each pending task and calculate the resource utilization rate of each server in the server cluster in real time. The resource utilization rate of the server can be characterized by indicators such as CPU utilization rate, memory utilization rate and network utilization rate.
[0051] In one embodiment, the real-time calculation of the resource usage of each server in the server cluster includes:
[0052] Collect the CPU usage, memory usage and network usage of each server in the server cluster in real time;
[0053] The CPU utilization, memory utilization, and network utilization of each server are weighted and summed to obtain the resource utilization of each server.
[0054] The CPU usage, memory usage, and network usage of the server can be queried and collected through the files in the Linux kernel. The resource usage of each server can be obtained by weighted summing according to the weights pre-assigned to the CPU usage, memory usage, and network usage. Among them, the weights assigned to the CPU usage, memory usage, and network usage can be 0.4, 0.3, and 0.3, respectively. It can be understood that the weights can be adjusted according to actual needs. The resource usage of the server can also include cache usage, broadband usage, IO usage, etc., which are not specifically limited here.
[0055] Since the resource utilization rate of the server represents the current idleness of the server, and the priority coefficient of the pending task represents the order of task execution, the server that executes each pending task (referred to as the target server) is determined from the server cluster based on the priority coefficient and the resource utilization rate of each server. For example, the server with the lowest resource utilization rate is used as the target server for the pending task with the highest priority coefficient, so as to more reasonably assign a more suitable server to execute the task.
[0056] In actual applications, there may be tasks with high CPU usage and low network usage (for example, computationally intensive tasks such as deep learning model training), or tasks with high memory usage and low CPU usage (for example, memory intensive tasks such as big data analysis), which results in the overall resource usage of the server not being high, but the usage of a single resource indicator being high. If a task with a higher priority coefficient is assigned to a server in this case, it may affect the execution timeliness of the task. Therefore, in order to avoid assigning tasks with higher priority coefficients to servers with higher usage of a single resource indicator, the single resource indicator of the server needs to be considered when determining the target server for each task. Specifically, determining the target server for executing each of the tasks to be processed from the server cluster based on the priority coefficient and the resource usage of each server includes:
[0057] Sort the tasks to be processed by priority coefficient from large to small to obtain a sorting result of the tasks to be processed;
[0058] Determine a candidate server from the server cluster, wherein the candidate server refers to a server whose CPU usage, memory usage, and network usage are all less than a preset threshold;
[0059] Sort the candidate servers according to their resource usage from small to large to obtain a ranking result of the candidate servers;
[0060] Based on the ranking results of the tasks to be processed and the ranking results of the candidate servers, a target server for executing each of the tasks to be processed is determined.
[0061] In the sorting results of pending tasks, the larger the priority coefficient of the task, the higher it is in the sorting results. Determine candidate servers from the server cluster, where the candidate servers refer to servers whose CPU usage, memory usage, and network usage are all less than the preset thresholds, and servers with higher usage of a single resource indicator can be screened out. Among them, the preset threshold can be 70%, and the preset threshold can be reasonably set according to actual needs, and is not specifically limited here. In the sorting results of candidate servers, the smaller the resource usage of the candidate server, the higher it is in the sorting results. After obtaining the sorting results of pending tasks and the sorting results of candidate servers, the task with the highest priority coefficient can be assigned to the server with the lowest resource usage.
[0062] Specifically, based on the ranking results of the tasks to be processed and the ranking results of the candidate servers, determining a target server for executing each of the tasks to be processed includes:
[0063] According to the order of the ranking results of the candidate servers, the target server for executing each of the tasks to be processed is determined in sequence from the order of the ranking results of the tasks to be processed.
[0064] For example, assuming that the ranking results of the tasks to be processed are tasks x1, x2, x3, x4, x5, x6, x7, x8, and the ranking results of the candidate servers are y1, y2, y3, y4, then the servers corresponding to tasks x1, x2, x3, x4 are determined to be y1, y2, y3, y4, respectively, and then the servers that have successively completed the tasks to be processed among y1, y2, y3, y4 are determined, and then x5, x6, x7, x8 are assigned to these servers in sequence. For example, the servers corresponding to tasks x1, x2, x3, x4 are y1, y2, y3, y4, respectively. If the target server y2 has completed task x2, the task x5 to be processed is assigned to the target server y2. For another example, when the target servers corresponding to tasks x1, x2, x3, x4 are determined to be y1, y2, y3, y4, the target servers corresponding to tasks x5, x6, x7, x8 are determined to be y1, y2, y3, y4, respectively.
[0065] In one embodiment, after selecting a target server for executing the task to be processed from the server cluster, the method further includes:
[0066] The data corresponding to the task to be processed is sent to the target server so that the target server executes the task to be processed.
[0067] After determining the target server for each task to be processed, the data corresponding to the task to be processed is sent to the target server, so that the target server can execute the tasks to be processed according to the received data.
[0068] Reference Figure 2 , which is a schematic diagram of functional modules of a task scheduling device 100 based on load balancing in the present application.
[0069] The task scheduling device 100 based on load balancing described in the present application can be installed in an electronic device. According to the functions to be implemented, the task scheduling device 100 based on load balancing can include a determination module 110, a first calculation module 120, a second calculation module 130 and a scheduling module 140. The module described in the present application can also be referred to as a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0070] In this embodiment, the functions of each module / unit are as follows:
[0071] Determination module 110: used to determine the server resources required to execute each task to be processed and the expected processing time corresponding to each task to be processed;
[0072] The first calculation module 120 is used to calculate the priority coefficient of each task to be processed according to the server resources required by the task to be processed and the expected processing time;
[0073] The second calculation module 130 is used to calculate the resource usage rate of each server in the server cluster in real time;
[0074] Scheduling module 140: used to determine a target server to execute each of the tasks to be processed from the server cluster according to the priority coefficient and the resource usage rate of each server.
[0075] In one embodiment, the calculating the priority coefficient of each of the tasks to be processed according to the server resources required by the tasks to be processed and the expected processing time includes:
[0076] Obtaining the maximum waiting time of the task to be processed and the historical execution frequency of the task to be processed;
[0077] Based on the maximum waiting time and the expected processing time, determine the time between the current and the latest execution time of the task to be processed;
[0078] The priority coefficient of each of the tasks to be processed is calculated according to the server resources required by the tasks to be processed, the maximum waiting time, the historical execution frequency and the time from the current time to the latest execution time.
[0079] In one embodiment, the formula for calculating the priority coefficient of each of the tasks to be processed includes:
[0080]
[0081] Among them, Q represents the priority coefficient, N represents the distance from the current time to the latest execution time, M represents the maximum waiting time, F represents the historical execution frequency, C represents the server resources required for the task to be processed, a represents the first nonlinear adjustment parameter, and b represents the second nonlinear adjustment parameter.
[0082] In one embodiment, the real-time calculation of the resource usage of each server in the server cluster includes:
[0083] Collect the CPU usage, memory usage and network usage of each server in the server cluster in real time;
[0084] The CPU utilization, memory utilization, and network utilization of each server are weighted and summed to obtain the resource utilization of each server.
[0085] In one embodiment, determining a target server for executing each of the tasks to be processed from the server cluster according to the priority coefficient and the resource usage rate of each server includes:
[0086] Sort the tasks to be processed by priority coefficient from large to small to obtain a sorting result of the tasks to be processed;
[0087] Determine a candidate server from the server cluster, wherein the candidate server refers to a server whose CPU usage, memory usage, and network usage are all less than a preset threshold;
[0088] Sort the candidate servers according to their resource usage from small to large to obtain a ranking result of the candidate servers;
[0089] Based on the ranking results of the tasks to be processed and the ranking results of the candidate servers, a target server for executing each of the tasks to be processed is determined.
[0090] In one embodiment, determining a target server for executing each of the tasks to be processed based on the ranking results of the tasks to be processed and the ranking results of the candidate servers includes:
[0091] According to the order of the ranking results of the candidate servers, the target server for executing each of the tasks to be processed is determined in sequence from the order of the ranking results of the tasks to be processed.
[0092] In one embodiment, the scheduling module 140 is further configured to:
[0093] The data corresponding to the task to be processed is sent to the target server so that the target server executes the task to be processed.
[0094] Reference Figure 3 , which is a schematic diagram of a preferred embodiment of the electronic device of the present application.
[0095] The electronic device includes a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other via the communication bus 114;
[0096] The memory 113 is used to store computer programs, for example, a task scheduling program based on load balancing;
[0097] In some embodiments, the processor 111 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips. The processor 111 is generally used to control the overall operation of the electronic device, such as performing control and processing related to data interaction or communication. In this embodiment, the processor 111 is used to run the program code stored in the memory 113 or process data, such as running the program code of a load-balancing-based task scheduler.
[0098] The communication interface 112 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), and the communication interface 112 may also be used to establish a communication connection between the electronic device and other electronic devices.
[0099] The memory 113 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 113 can be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. In other embodiments, the memory 113 can also be an external storage device of the electronic device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped with the electronic device. Of course, the memory 113 can also include both the internal storage unit of the electronic device and its external storage device. In this embodiment, the memory 11 is generally used to store the operating system and various computer programs installed in the electronic device, such as the program code of the task scheduler based on load balancing, etc. In addition, the memory 113 can also be used to temporarily store various types of data that have been output or are to be output.
[0100] In one embodiment of the present application, the processor 111 is used to implement the load balancing-based task scheduling method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 113, including:
[0101] Determine the server resources required to execute each pending task and the expected processing time corresponding to each pending task;
[0102] Calculate the priority coefficient of each of the tasks to be processed according to the server resources required by the tasks to be processed and the expected processing time;
[0103] Calculate the resource usage of each server in the server cluster in real time;
[0104] According to the priority coefficient and the resource usage rate of each server, a target server for executing each of the tasks to be processed is determined from the server cluster.
[0105] For a detailed description of the above steps, please refer to the above Figure 1 Description of a flowchart of an embodiment of a task scheduling method based on load balancing.
[0106] In addition, the embodiment of the present application also proposes a computer-readable storage medium, which may be non-volatile or volatile. The computer-readable storage medium includes a data storage area and a program storage area, and the program storage area stores a load balancing-based task scheduling program. When the load balancing-based task scheduling program is executed by a processor, the following operations are implemented:
[0107] Determine the server resources required to execute each pending task and the expected processing time corresponding to each pending task;
[0108] Calculate the priority coefficient of each of the tasks to be processed according to the server resources required by the tasks to be processed and the expected processing time;
[0109] Calculate the resource usage of each server in the server cluster in real time;
[0110] According to the priority coefficient and the resource usage rate of each server, a target server for executing each of the tasks to be processed is determined from the server cluster.
[0111] The specific implementation of the computer-readable storage medium of the present application is roughly the same as the specific implementation of the above-mentioned load balancing-based task scheduling method, and will not be repeated here.
[0112] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0113] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0114] It should be noted that the descriptions involving "first", "second", etc. in this application are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0115] It should be understood that the terms used herein are only for the purpose of describing specific example embodiments and are not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms "one", "an" and "said" as used herein may also be meant to include plural forms. The terms "include", "comprise", "contain", and "have" are inclusive, and therefore specify the existence of stated features, steps, operations, elements and / or parts, but do not exclude the existence or addition of one or more other features, steps, operations, elements, parts, and / or combinations thereof. The method steps, processes, and operations described herein are not interpreted as necessarily requiring them to be performed in the specific order described or illustrated, unless the execution order is clearly indicated. It should also be understood that additional or alternative steps may be used.
[0116] The above description is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest range consistent with the principles and novel features applied for herein.
Claims
1. A task scheduling method based on load balancing, characterized in that: The method comprises: Determine the server resources required to execute each pending task and the expected processing time corresponding to each pending task; Calculate the priority coefficient of each of the tasks to be processed according to the server resources required by the tasks to be processed and the expected processing time; Calculate the resource usage of each server in the server cluster in real time; According to the priority coefficient and the resource usage rate of each server, a target server for executing each of the tasks to be processed is determined from the server cluster.
2. The task scheduling method based on load balancing according to claim 1, characterized in that: The step of calculating the priority coefficient of each of the tasks to be processed according to the server resources required by the tasks to be processed and the expected processing time includes: Obtaining the maximum waiting time of the task to be processed and the historical execution frequency of the task to be processed; Based on the maximum waiting time and the expected processing time, determine the time between the current and the latest execution time of the task to be processed; The priority coefficient of each of the tasks to be processed is calculated according to the server resources required by the tasks to be processed, the maximum waiting time, the historical execution frequency and the time from the current time to the latest execution time.
3. The task scheduling method based on load balancing according to claim 2, characterized in that: The formula for calculating the priority coefficient of each of the tasks to be processed includes: Among them, Q represents the priority coefficient, N represents the duration from the current time to the latest execution time, M represents the maximum waiting time, F represents the historical execution frequency, C represents the server resources required for the task to be processed, a represents the first nonlinear adjustment parameter, and b represents the second nonlinear adjustment parameter.
4. The task scheduling method based on load balancing according to claim 1, characterized in that: The real-time calculation of the resource usage of each server in the server cluster includes: Collect the CPU usage, memory usage and network usage of each server in the server cluster in real time; The CPU utilization, memory utilization, and network utilization of each server are weighted and summed to obtain the resource utilization of each server.
5. The task scheduling method based on load balancing according to claim 1, characterized in that: Determining a target server for executing each of the tasks to be processed from the server cluster according to the priority coefficient and the resource usage rate of each server includes: Sort the tasks to be processed by priority coefficient from large to small to obtain a sorting result of the tasks to be processed; Determine a candidate server from the server cluster, wherein the candidate server refers to a server whose CPU usage, memory usage, and network usage are all less than a preset threshold; Sort the candidate servers according to their resource usage from small to large to obtain a ranking result of the candidate servers; Based on the ranking results of the tasks to be processed and the ranking results of the candidate servers, a target server for executing each of the tasks to be processed is determined.
6. The task scheduling method based on load balancing according to claim 5, characterized in that: The step of determining a target server for executing each of the tasks to be processed based on the sorting results of the tasks to be processed and the sorting results of the candidate servers includes: According to the order of the ranking results of the candidate servers, the target server for executing each of the tasks to be processed is determined in sequence from the order of the ranking results of the tasks to be processed.
7. The task scheduling method based on load balancing according to any one of claims 1 to 6, characterized in that: After selecting a target server for executing the task to be processed from the server cluster, the method further includes: The data corresponding to the task to be processed is sent to the target server so that the target server executes the task to be processed.
8. A task scheduling device based on load balancing, characterized in that: The device comprises: Determination module: used to determine the server resources required to execute each pending task and the expected processing time corresponding to each pending task; A first calculation module: used for calculating the priority coefficient of each task to be processed according to the server resources required by the task to be processed and the expected processing time; The second calculation module: used to calculate the resource usage rate of each server in the server cluster in real time; Scheduling module: used to determine the target server to execute each of the tasks to be processed from the server cluster according to the priority coefficient and the resource utilization rate of each server.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; The processor is used to implement the load balancing-based task scheduling method described in any one of claims 1 to 7 when executing the program stored in the memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the load balancing-based task scheduling method according to any one of claims 1 to 7 is implemented.