A task scheduling method based on Spark task identification
By defining identifiers for Spark tasks and optimizing task scheduling based on execution time and dependencies, the problem of low resource utilization caused by inaccurate Spark task analysis is solved, and task execution efficiency and resource utilization are improved.
Patent Information
- Application Number
- CN202410866189.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-07-01
AI Technical Summary
The analysis of Spark tasks in the existing technology is not accurate enough, resulting in unreasonable task scheduling methods, low resource utilization, and low task execution efficiency.
By defining a unique identifier for each Spark task, determining the priority based on task execution completion time and dependencies, combining the cluster resource idleness and the memory required by the task, adjusting the task execution order and scheduling parameters, and optimizing task scheduling in the Spark cluster. and execution.
It improves the analysis accuracy of Spark tasks, avoids delays and low resource utilization caused by insufficient resources or untimely execution of dependencies, and improves task execution efficiency and resource utilization.
Smart Images

Figure CN118394490B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a task scheduling method based on Spark task identification. Background Art
[0002] In recent years, with the rapid development of technologies such as social networks and the Internet of Things, there are large demands for data analysis in many fields such as banking, healthcare, business forecasting, and scientific exploration. Big data processing has become crucial. The Spark framework has been widely used in big data processing, but Spark tasks have an unbalanced load problem of idle nodes during task execution, resulting in a long overall task time span, low task execution efficiency, and insufficient utilization of cluster computing resources.
[0003] Chinese patent application publication number: CN112948066A discloses a Spark task scheduling method based on heterogeneous resources. The method includes: the Master node analyzes the computing power of each CPU core level according to the collected on-chip system information on each computing node in the Spark cluster; the Master node matches the computing power of the CPU core level according to the amount of computation of the task to be executed, assigns the task to the Slave computing node and indicates the assigned CPU core identifier to the Slave node; the Slave computing node binds the task to the corresponding CPU core for execution according to the CPU core identifier assigned by the Master node. The method of the invention can improve the efficiency of task execution, and especially can reduce the execution time of key tasks.
[0004] It can be seen that the existing technology has the problem of inaccurate analysis of Spark tasks, which leads to unreasonable task scheduling methods and low resource utilization. Summary of the invention
[0005] To this end, the present invention provides a task scheduling method based on Spark task identification to overcome the problem in the prior art that the analysis of Spark tasks is not accurate enough, resulting in an unreasonable task scheduling method and low resource utilization.
[0006] To achieve the above object, the present invention provides a task scheduling method based on Spark task identification, comprising:
[0007] Define a unique identifier for each Spark task and store the identified Spark task in the task queue to be executed;
[0008] Determine the priority of a single task based on the time it takes to complete the execution of the single task in the task queue and the number of other tasks that have dependencies on the single task;
[0009] The execution order of each task is determined according to the free resource memory of the cluster resources when executing task scheduling and the priority of the highest priority task in the task queue to be executed;
[0010] Send the scheduled tasks to the available Spark cluster for execution. After the tasks are completed, use Spark's task status monitoring function to detect the completion status of the tasks and store the completion status information of the tasks in the database.
[0011] The adjustment amount of the task scheduling parameters is determined according to the duration during which the idle resource ratio of the cluster resources is less than the preset ratio and the degree of task completion qualification during the execution of the Spark task, wherein the task scheduling parameters include the maximum execution time of the tasks in the task queue to be scheduled and the memory required for the execution of the highest priority task.
[0012] Furthermore, when determining the priority of a single task, include:
[0013] Determine the priority of the task according to the comparison result of the time when the single task is executed and completed and the preset time;
[0014] The priority of the task is determined based on a comparison result of the time when a single task is executed and completed with a preset time and a comparison result of the number of other tasks that have a dependency relationship with the task and a preset number of tasks.
[0015] Furthermore, the preset number of tasks is determined according to the difference between an average value of the number of tasks in the to-be-scheduled task queue that have a dependency relationship with each task and one.
[0016] Further, determining the execution order of each task includes:
[0017] The execution order of each task is determined based on the comparison result between the free resource memory of the cluster resources and the memory required for the execution of the highest priority task in the task queue to be executed when executing task scheduling;
[0018] The execution order of each task is determined according to the comparison result between the idle resource memory of the cluster resources and the memory required for the execution of the highest priority task in the task queue to be executed when executing task scheduling, and the priority of the highest priority task;
[0019] Among them, the priority of the first priority task is higher than the second priority task, and the priority of the second priority task is higher than the third priority task.
[0020] Furthermore, the memory required for executing the highest priority task is determined based on a historical average value of the memory occupied by the execution of the highest priority task.
[0021] Furthermore, when the scheduled task is sent to an available Spark cluster for execution, the task status, running time and progress are stored in a database.
[0022] Furthermore, when determining the adjustment amount of the task scheduling parameter, it includes:
[0023] Determine the adjustment amount of the task scheduling parameters according to the comparison result of the duration during which the idle resource ratio of the cluster resources is less than the preset ratio and the preset duration when the Spark task is executed;
[0024] The adjustment amount of the task scheduling parameters is determined according to the comparison result of the duration when the idle resource ratio of the cluster resources is less than the preset ratio and the preset duration during the Spark task execution and the comparison result of the task completion qualification degree and the preset task completion qualification degree.
[0025] Furthermore, the preset duration is determined according to an average waiting duration during task scheduling when the idle resource memory of cluster resources is greater than the memory required for execution of the highest priority task and then the highest priority task is scheduled.
[0026] Furthermore, the adjustment amount of the maximum execution time of the tasks in the to-be-scheduled task queue is negatively correlated with the idle time of the idle resources, and the adjustment amount of the memory required for the execution of the highest priority task is positively correlated with the idle time of the idle resources.
[0027] Furthermore, the degree of completion of the task is calculated by the following formula:
[0028] ;
[0029] Among them, G represents the degree of task completion qualification, R0 represents the preset number of task retries, R represents the number of task retries, A represents the number of tasks executed during task scheduling, Yi represents the execution time of the i-th task, and Yi0 represents the preset execution time of the i-th task.
[0030] Compared with the prior art, the beneficial effect of the present invention lies in that the present invention preliminarily determines the priority of the task according to the comparison result of the execution completion time of a single task with the preset time. When the execution completion time is greater than or equal to the preset time, it indicates that the task is about to reach the deadline, so the priority of the task is set to the first priority. When the execution completion time is less than the preset completion time, the priority of the task is further determined. The above method avoids the phenomenon that urgent tasks cannot be executed in time due to the inability to execute tasks in time, improves the accuracy of Spark task analysis and thus improves resource utilization.
[0031] Furthermore, the present invention further determines the priority of the task by comparing the number of other tasks that have a dependency relationship with the task with the preset number of tasks. When the number of other tasks is greater than or equal to the preset number of tasks, the priority of the task is determined to be the second priority. When the number of other tasks is less than the preset number of tasks, the priority of the task is determined to be the third priority. The above method can avoid the failure to execute tasks that depend on the task due to the failure to execute tasks with dependencies in time, thereby reducing the task execution efficiency, improving the accuracy of Spark task analysis and thus improving resource utilization.
[0032] Furthermore, the present invention determines the execution order of tasks according to the comparison result between the idle resource memory and the memory required for the execution of the task to be scheduled. When the idle resource memory is greater than the memory required for the execution of the task to be scheduled, it indicates that the idle resource memory can support the execution of the highest priority task. When the idle resource memory is less than or equal to the memory required for the execution of the task to be scheduled, it indicates that the idle resource memory is insufficient to support the execution of the highest priority task. At this time, the task is determined to be urgent according to the priority of the highest priority task being the first priority, and the idle resource memory of the cluster resources is determined to be greater than the memory required for the execution of the highest priority task before scheduling the highest priority task. The task is determined to be not urgent according to the priority of the highest priority task being not the first priority, and the memory required for the execution of the scheduled task is determined to be less than the highest priority task in the idle resource memory of the cluster resources. The above method can avoid the phenomenon that the urgent task of the first priority cannot be executed in time due to insufficient idle resources to support the execution of the highest priority task, thereby improving the accuracy of Spark task analysis and thus improving resource utilization.
[0033] Furthermore, the present invention determines to adjust the task scheduling parameters according to the comparison result of the duration when the proportion of idle resources of cluster resources is less than the preset proportion and the preset duration when the Spark task is executed. When the duration is greater than or equal to the preset duration, it indicates that the task execution efficiency is low and the task scheduling parameters need to be adjusted. When the duration is less than the preset duration, it is necessary to further analyze the execution qualification of the task to determine whether to adjust the task scheduling parameters. The above method improves the accuracy of Spark task analysis and thus improves resource utilization. The present invention determines the qualification of the task execution process by the number of task retries and the task execution duration, avoiding the phenomenon of misjudgment of the task execution process due to the failure of task execution and the duration of task execution being less than the preset duration. The above method improves the accuracy of Spark task analysis and thus improves the task execution efficiency.
[0034] Furthermore, the present invention determines the adjustment method by comparing the idle time of idle resources with the preset idle time. When the idle time is greater than or equal to the preset idle time, it means that the idle time is too long, resulting in low resource utilization. It is determined to reduce the maximum execution time of tasks in the task queue to be scheduled by the first adjustment coefficient, and then increase the judgment parameter of the first priority task to reduce the waiting time until the idle resource memory of the cluster resource is greater than the memory required for the execution of the highest priority task and then schedule the waiting time of the highest priority task. When the idle time is less than the preset idle time, it means that the highest priority task has a long execution time due to insufficient memory during execution, resulting in low efficiency of the task execution process. It is determined to adjust the memory required for the execution of the highest priority task by the second adjustment coefficient. The above method improves the accuracy of Spark task analysis and thus improves the efficiency of task execution. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 The following is a workflow diagram of a task scheduling method based on Spark task identification according to an embodiment of the present invention;
[0036] Figure 2 A workflow diagram for determining the execution order of each task in a task scheduling method based on Spark task identification according to an embodiment of the present invention;
[0037] Figure 3 The present invention provides a workflow diagram for determining the adjustment of task scheduling parameters according to a task scheduling method based on Spark task identification in an embodiment of the present invention. DETAILED DESCRIPTION
[0038] In order to make the objects and advantages of the present invention more clearly understood, the present invention is further described below in conjunction with embodiments; it should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0039] The preferred embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0040] In addition, it should be noted that in the description of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0041] See also Figure 1-Figure 3 As shown, Figure 1 The following is a workflow diagram of a task scheduling method based on Spark task identification according to an embodiment of the present invention; Figure 2 A workflow diagram for determining the execution order of each task in a task scheduling method based on Spark task identification according to an embodiment of the present invention; Figure 3 The present invention provides a workflow diagram for determining the adjustment of task scheduling parameters according to a task scheduling method based on Spark task identification in an embodiment of the present invention.
[0042] The task scheduling method based on Spark task identification in an embodiment of the present invention includes:
[0043] Step S1, defining a unique identifier for each Spark task, and storing the identified Spark task in a queue of tasks to be executed;
[0044] Step S2, determining the priority of a single task according to the time when the single task is completed in the to-be-executed task queue and the number of other tasks that have a dependency relationship with the single task;
[0045] Step S3, determining the execution order of each task according to the idle resource memory of the cluster resources when executing task scheduling and the priority of the highest priority task in the task queue to be executed;
[0046] Step S4, sending the scheduled task to an available Spark cluster for execution, using Spark's task status monitoring function to detect the task's completion status after the task is completed, and storing the task's completion status information in a database;
[0047] Step S5, determining the adjustment amount of the task scheduling parameters according to the duration that the idle resource ratio of the cluster resources is less than the preset ratio during the execution of the Spark task and the degree of task completion qualification, wherein the task scheduling parameters include the maximum execution time of the tasks in the task queue to be scheduled and the memory required for the execution of the highest priority task.
[0048] In the embodiment of the present invention, defining a unique identifier for each Spark task includes using a UUID library to generate a globally unique identifier. The dependency relationship means that a task needs to rely on the completion status or output results of other tasks to start or continue execution. For example, the premise for starting the execution of Task I is that Task II is completed, then it is determined that there is a dependency relationship between Task I and Task II.
[0049] Specifically, in step S2, when determining the priority of a single task, the priority of the task is determined according to the comparison result of the time T when the single task is executed and the preset time T0, including:
[0050] Determine the priority of the task as the first priority according to a first comparison result between the time when the single task is executed and the preset time T0;
[0051] Determine the priority of the task as the second priority according to a second comparison result of the time T for completing the execution of the single task and the preset time T0 and a first comparison result of the number N of other tasks having a dependency relationship with the task and the preset number N0 of tasks;
[0052] The priority of the task is determined to be the third priority based on a second comparison result of the time T for completing the execution of the single task and the preset time T0 and a second comparison result of the number N of other tasks having a dependency relationship with the task and the preset number N0 of tasks.
[0053] In a specific embodiment, it is set that:
[0054] T≥T0 is the first comparison result between the time when a single task is completed and the preset time;
[0055] T<T0 is the second comparison result between the time when a single task is completed and the preset time;
[0056] N≥N0 is a first comparison result of the number of other tasks that have a dependency relationship with the task and the preset number of tasks;
[0057] N<N0 is a second comparison result of the number of other tasks that have a dependency relationship with the task and the preset number of tasks;
[0058] In a specific embodiment, when T≥T0, determining the priority of the task as the first priority;
[0059] When T<T0, a second determination is made to determine the priority of the task.
[0060] The time for completing the execution of a single task in an embodiment of the present invention is a completion time moment obtained by taking the time of the scheduled task as the start time and the historical maximum execution time of the single task as the execution process duration. The historical maximum execution time of the single task is the maximum execution time of the task under the influence of different network delays, data volume distribution and other link factors. For example, the time of the scheduled task is 16:08:34:556 milliseconds on March 5, 2021, expressed in numbers as 20210305160834556, and the historical maximum execution time of the task is 12 seconds 125 milliseconds. Then the time for completing the execution of the task is 20210305160846681. The preset time is the completion time with the deadline of the task as the completion time, and the maximum execution time of the task in the task queue to be scheduled as the execution process duration. The start time moment, for example, the deadline of the task is 20210402100842664, and the maximum execution time of the task in the task queue to be scheduled is 35 seconds 210 milliseconds, then the preset time is 20210402100807454, and the value range of the maximum execution time of the task in the task queue to be scheduled is set to 10 seconds-3600 seconds, and the value of the maximum execution time of the task in the task queue to be scheduled is preferably 1000 seconds. If a single task does not have a historical execution time, the execution time of the single task that does not have a historical execution time is determined according to 80% of the maximum execution time of the task in the task queue to be scheduled. For example, if the task does not have a historical execution time, and the maximum execution time of the task in the task queue to be scheduled is 1000 seconds, then the execution time of the single task that does not have a historical execution time is 800 seconds.
[0061] The present invention preliminarily determines the priority of a task based on the comparison result of the execution completion time of a single task with the preset time. When the execution completion time is greater than or equal to the preset time, it indicates that the task is about to reach the deadline, so the priority of the task is set to the first priority. When the execution completion time is less than the preset completion time, the priority of the task is further determined. The above method avoids the phenomenon that urgent tasks cannot be executed in time due to the inability to execute tasks in time, improves the accuracy of Spark task analysis and thus improves resource utilization.
[0062] Specifically, when the priority of the task is determined for the second time, the priority of the task is determined according to the comparison result of the number N of other tasks that have a dependency relationship with the task and the preset number N0 of tasks;
[0063] When N≥N0, determining the priority of the task to be the second priority;
[0064] When N<N0, determining the priority of the task to be the third priority;
[0065] Among them, the value of the preset task number N0 is the difference between the average value of the number of tasks with dependencies in the task queue to be scheduled and one. For example, in the task queue to be scheduled, task Z has a dependency relationship with task Y, task X, task P and task W, and task V has a dependency relationship with task O and task P. Then the value of the preset task number is 3, but the above value is not limited to this. Those skilled in the art can also adjust the value according to actual needs.
[0066] The present invention further determines the priority of the task by comparing the number of other tasks that have a dependency relationship with the task with the preset number of tasks. When the number of other tasks is greater than or equal to the preset number of tasks, the priority of the task is determined to be the second priority. When the number of other tasks is less than the preset number of tasks, the priority of the task is determined to be the third priority. The above method can avoid the failure to execute tasks that depend on the task due to the failure to execute tasks with dependencies in time, thereby reducing the task execution efficiency, improving the accuracy of Spark task analysis and thus improving resource utilization.
[0067] Specifically, in step S3, when determining the execution order of each task, the execution order of each task is determined according to the comparison result between the idle resource memory M of the cluster resources when executing task scheduling and the memory M0 required for the execution of the scheduled task, including:
[0068] Determine the task with the highest priority to be scheduled according to a first comparison result of the idle resource memory M of the cluster resources when executing task scheduling and the memory M0 required for execution of the highest priority task in the task queue to be executed;
[0069] According to the second comparison result of the idle resource memory M of the cluster resources and the memory M0 required for execution of the highest priority task in the task queue to be executed when executing task scheduling and the first result of the priority of the highest priority task, it is determined to wait until the idle resource memory of the cluster resources is greater than the memory required for execution of the highest priority task and then schedule the highest priority task;
[0070] According to the second comparison result of the idle resource memory M of the cluster resources and the memory M0 required for execution of the highest priority task in the task queue to be executed when executing task scheduling and the second result of the priority of the highest priority task, it is determined that the memory required for execution of the scheduled task is less than the highest priority task in the idle resource memory of the cluster resources.
[0071] In a specific embodiment, it is set that:
[0072] M>M0 is the first comparison result between the idle resource memory of the cluster resources and the memory required for the execution of the highest priority task in the task queue to be executed when executing task scheduling;
[0073] M≤M0 is the second comparison result of the idle resource memory of the cluster resources and the memory required for the execution of the highest priority task in the task queue to be executed when executing task scheduling;
[0074] The first priority is the first result of the priority of the highest priority task;
[0075] The second priority or the third priority is a second result of the priority of the highest priority task.
[0076] In the embodiment of the present invention, the memory required for executing the highest priority task is determined based on the historical average of the memory occupied by the highest priority task. For example, the historical memory occupied by the highest priority task is 25GB, 30GB, 35GB, 40GB and 45GB respectively, then the memory occupied by the highest priority task is 35GB. If the highest priority task has no historical occupied memory, it is determined based on 90% of the maximum required memory in the task queue to be scheduled. For example, the highest priority task has no historical occupied memory, and the maximum required memory in the task queue to be scheduled is 100GB, then the memory occupied by the highest priority task is 90GB. However, the above value is not limited to this, and those skilled in the art may also adjust the value according to actual needs.
[0077] The present invention determines the execution order of tasks according to the comparison result of idle resource memory and memory required for execution of tasks to be scheduled. When the idle resource memory is greater than the memory required for execution of tasks to be scheduled, it indicates that the idle resource memory can support the execution of the highest priority task. When the idle resource memory is less than or equal to the memory required for execution of tasks to be scheduled, it indicates that the idle resource memory is insufficient to support the execution of the highest priority task. At this time, the task is determined to be urgent according to the priority of the highest priority task being the first priority, and the idle resource memory of cluster resources is determined to be greater than the memory required for execution of the highest priority task before scheduling the highest priority task. The task is determined to be not urgent according to the priority of the highest priority task being not the first priority, and the memory required for execution of the scheduled task is determined to be less than the highest priority task in the idle resource memory of cluster resources. The above method can avoid the phenomenon that the urgent task of the first priority cannot be executed in time due to the insufficient idle resources to support the execution of the highest priority task, thereby improving the accuracy of Spark task analysis and thus improving resource utilization.
[0078] Specifically, in step S4, the scheduled task is sent to an available Spark cluster for execution. After the task is executed, the task status monitoring function of Spark is used to detect the completion status of the task, and the completion status information of the task is stored in the database.
[0079] Specifically, in step S5, when adjusting the task scheduling parameters, the task scheduling parameters are adjusted according to the comparison result of the time W when the idle resource ratio of the cluster resources is less than the preset ratio and the preset time W0 when the Spark task is executed, including:
[0080] According to a first comparison result of the duration W during which the idle resource ratio of cluster resources is less than the preset ratio and the preset duration W0 when the Spark task is executed, it is determined that the task scheduling parameters are adjusted;
[0081] According to the second comparison result of the duration W during which the idle resource ratio of cluster resources is less than the preset ratio and the preset duration W0 when the Spark task is executed, and the first comparison result of the task completion qualification level G and the preset task completion qualification level G0, it is determined to adjust the task scheduling parameters;
[0082] According to the second comparison result of the duration W during which the idle resource ratio of cluster resources is less than the preset ratio and the preset duration W0 during the execution of the Spark task and the second comparison result of the task completion qualification level G and the preset task completion qualification level G0, it is determined that the task scheduling parameters are not adjusted.
[0083] In a specific embodiment, it is set that:
[0084] W≥W0 is the first comparison result between the duration when the idle resource ratio of cluster resources is less than the preset ratio and the preset duration during the execution of the Spark task;
[0085] W<W0 is the second comparison result of the duration when the idle resource ratio of cluster resources is less than the preset ratio and the preset duration during the execution of the Spark task;
[0086] G≥G0 is the first comparison result between the task completion qualification level and the preset task completion qualification level;
[0087] G<G0 is the second comparison result between the task completion qualification level and the preset task completion qualification level;
[0088] Among them, the value of the preset duration W0 is thirteen tenths of the average waiting time for scheduling the highest priority task until the idle resource memory of the cluster resources is greater than the memory required for the execution of the highest priority task during the task scheduling process. The idle resource ratio is the ratio of the number of idle resources to the total number of resources. The number of resources includes but is not limited to "the number of CPU cores and memory capacity". The present invention preferably uses memory capacity as a parameter for calculating the idle resource ratio. The value range of the preset ratio is set to 0 to 0.3, and the value of the preset ratio is preferably 0.2, but the above value is not limited to this. Technical personnel in this field can also adjust the value according to actual needs.
[0089] In an embodiment of the present invention, when a scheduled task is of the second priority, the task scheduling order is determined according to the number of dependencies existing with the tasks. For example, the execution prerequisite of tasks B and C is that task A is completed, and the execution prerequisite of tasks E, F, and G is that task D is completed, and the priorities of tasks A and D are both the second priority. In this case, task D is scheduled first when scheduling tasks.
[0090] Specifically, the task completion qualification level G is calculated by the following formula:
[0091] ;
[0092] Among them, R0 represents the preset number of task retries, R represents the number of task retries, A represents the number of tasks executed during the task scheduling process, Yi represents the execution time of the i-th task, and Yi0 represents the preset execution time of the i-th task.
[0093] In the embodiment of the present invention, the value of the preset task completion qualification level G0 is the value of the task completion qualification level when the number of task retries is equal to the preset task retries and the execution time of the i-th task is equal to the preset execution time of the i-th task. The value of the preset task retry number R0 is the average value of the task retries during each task execution process. The value of the i-th task preset execution time Yi0 is the average value of the historical execution time of the task. However, the above values are not limited to this, and technical personnel in this field can also adjust the values according to actual needs.
[0094] The present invention determines to adjust the task scheduling parameters according to the comparison result of the duration when the idle resource proportion of cluster resources is less than the preset proportion and the preset duration when the Spark task is executed. When the duration is greater than or equal to the preset duration, it indicates that the task execution efficiency is low and the task scheduling parameters need to be adjusted. When the duration is less than the preset duration, it is necessary to further analyze the execution qualification of the task to determine whether to adjust the task scheduling parameters. The above method improves the accuracy of Spark task analysis and thus improves resource utilization. The present invention determines the qualification of the task execution process by the number of task retries and the task execution duration, avoids the phenomenon of misjudgment of the task execution process due to the failure of task execution and the duration of task execution being less than the preset duration. The above method improves the accuracy of Spark task analysis and thus improves the task execution efficiency.
[0095] Specifically, in step S5, when it is determined to adjust the task scheduling parameters, the adjustment method is determined according to the comparison result between the idle time P of the idle resource and the preset idle time P0;
[0096] When P≥P0, determine to adjust in the first adjustment mode;
[0097] When P<P0, determine to adjust in the second adjustment mode;
[0098] Among them, the value range of the preset idle time is set to 100 seconds-400 seconds, and the value of the preset idle time is preferably 200 seconds, but the above value is not limited to this, and technical personnel in this field can also adjust the value according to actual needs.
[0099] Specifically, when it is determined to adjust the task scheduling parameters in the first adjustment mode, it is determined to adjust the maximum execution time Z of the tasks in the task queue to be scheduled by the first adjustment coefficient K1;
[0100] When it is determined to adjust the task scheduling parameters in the second adjustment manner, it is determined to adjust the memory M0 required for executing the highest priority task by the second adjustment coefficient K2.
[0101] Specifically, the first adjustment coefficient K1 is calculated and set by the following formula:
[0102] ;
[0103] The second adjustment coefficient K2 is calculated and set by the following formula:
[0104] ;
[0105] The maximum execution time Z' of the tasks in the adjusted task queue to be scheduled is set to Z'=K1×Z;
[0106] The memory M0' required for execution of the adjusted highest priority task is set to M0'=K2×M0.
[0107] Specifically, the present invention determines the adjustment method by comparing the idle time of idle resources with the preset idle time. When the idle time is greater than or equal to the preset idle time, it means that the idle time is too long, resulting in low resource utilization. It is determined to reduce the maximum execution time of tasks in the task queue to be scheduled by a first adjustment coefficient, and then increase the judgment parameter of the first priority task to reduce the waiting time until the idle resource memory of the cluster resource is greater than the memory required for the execution of the highest priority task and then schedule the waiting time of the highest priority task. When the idle time is less than the preset idle time, it means that the highest priority task has a long execution time due to insufficient memory during execution, resulting in low efficiency of the task execution process. It is determined to adjust the memory required for the execution of the highest priority task by a second adjustment coefficient. The above method improves the accuracy of Spark task analysis and thus improves the efficiency of task execution.
[0108] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
[0109] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A task scheduling method based on Spark task identification, characterized in that: include: Define a unique identifier for each Spark task and store the identified Spark task in the task queue to be executed; Determine the priority of a single task based on the time it takes to complete the execution of the single task in the task queue and the number of other tasks that have dependencies on the single task; The execution order of each task is determined according to the free resource memory of the cluster resources when executing task scheduling and the priority of the highest priority task in the task queue to be executed; Send the scheduled tasks to the available Spark cluster for execution. After the tasks are completed, use Spark's task status monitoring function to detect the completion status of the tasks and store the completion status information of the tasks in the database. Determine the adjustment amount of the task scheduling parameters according to the duration during which the idle resource ratio of the cluster resources is less than the preset ratio and the degree of task completion qualification during the execution of the Spark task, wherein the task scheduling parameters include the maximum execution time of the tasks in the task queue to be scheduled and the memory required for the execution of the highest priority task; When determining the adjustment amount of task scheduling parameters, include: Determine the adjustment amount of the task scheduling parameters according to the comparison result of the duration during which the idle resource ratio of the cluster resources is less than the preset ratio and the preset duration when the Spark task is executed; Determine the adjustment amount of the task scheduling parameters according to the comparison result of the duration during which the idle resource ratio of the cluster resources is less than the preset ratio and the preset duration when the Spark task is executed, and according to the comparison result of the task completion qualification degree and the preset task completion qualification degree; The preset duration is determined according to the average waiting time of the highest priority task to be scheduled after the idle resource memory of the cluster resource is larger than the memory required for the execution of the highest priority task during the task scheduling process; The adjustment amount of the maximum execution time of the tasks in the to-be-scheduled task queue is negatively correlated with the idle time of the idle resources, and the adjustment amount of the memory required for the execution of the highest priority task is positively correlated with the idle time of the idle resources; The degree of completion of the task is calculated by the following formula: ; Among them, G represents the degree of task completion qualification, R0 represents the preset number of task retries, R represents the number of task retries, A represents the number of tasks executed during task scheduling, Yi represents the execution time of the i-th task, and Yi0 represents the preset execution time of the i-th task.
2. The task scheduling method based on Spark task identification according to claim 1, characterized in that: When prioritizing individual tasks, include: Determine the priority of the task according to the comparison result of the time when the single task is executed and completed and the preset time; The priority of the task is determined based on a comparison result of the time when a single task is executed and completed with a preset time and a comparison result of the number of other tasks that have a dependency relationship with the task and a preset number of tasks.
3. The task scheduling method based on Spark task identification according to claim 2 is characterized in that: The preset number of tasks is determined according to the difference between an average value of the number of tasks in the to-be-scheduled task queue that have a dependency relationship with each task and one.
4. The task scheduling method based on Spark task identification according to claim 3 is characterized in that: Determining the execution order of each task includes: The execution order of each task is determined based on the comparison result between the free resource memory of the cluster resources and the memory required for the execution of the highest priority task in the task queue to be executed when executing task scheduling; The execution order of each task is determined according to the comparison result between the free resource memory of the cluster resources when executing task scheduling and the memory required for the execution of the highest priority task in the task queue to be executed and the priority of the highest priority task; Among them, the priority of the first priority task is higher than the second priority task, and the priority of the second priority task is higher than the third priority task.
5. The task scheduling method based on Spark task identification according to claim 4 is characterized in that: The memory required for executing the highest priority task is determined according to the historical average value of the memory occupied by the execution of the highest priority task.
6. The task scheduling method based on Spark task identification according to claim 5 is characterized in that: When sending the scheduled task to the available Spark cluster for execution, the task status, running time and progress are also stored in the database.
