Task anomaly early warning method and device, electronic equipment and readable storage medium
By monitoring the execution duration and number of Spark task tasks, alarm information is generated to identify abnormal task tasks, solving the problem of fine-grained monitoring of abnormal tasks in Spark task scheduling and improving task stability and parallelism management.
Patent Information
- Application Number
- CN202211231310.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-09
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2042-10-09
AI Technical Summary
In Spark task scheduling, how to effectively monitor and warn of abnormal tasks to ensure the stable operation of tasks, especially under concurrent requests, is a challenge that existing technologies struggle to achieve fine-grained monitoring of abnormal tasks.
By monitoring the execution duration and number of Tasks in each scheduling stage, comparing the execution duration of Tasks with a set threshold, alarm information is generated to identify abnormal Tasks, including the Task identifier.
It enables fine-grained anomaly monitoring of Spark tasks, improving the detection accuracy and efficiency of abnormal tasks, reducing computational load, and enhancing the optimization effect of task parallelism.
Smart Images

Figure CN115509864B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and particularly relates to a task exception early warning method and device, electronic equipment and readable storage medium. BACKGROUND
[0002] Apache Spark (Spark) is a big data processing framework built around speed, ease of use and complex analysis. Spark has multiple working modes. In a Spark Service mode, Spark task scheduling adopts a Fair mode. In the case of concurrent requests for Spark Service, a large number of Spark tasks will be generated. In order to ensure the stable operation of each Spark task, how to monitor the running state of the Spark task to perform early warning when there is an abnormal task in the Spark task becomes a problem to be solved. SUMMARY
[0003] Embodiments of the present application provide a task exception early warning method, device, electronic equipment and readable storage medium, which are used for Spark abnormal task early warning.
[0004] In order to solve the above problems, the present application embodiment discloses a task exception early warning method, which comprises:
[0005] For any scheduling stage Stage in each Job included in the Spark task to be monitored, the execution duration of a plurality of Task tasks in the scheduling stage Stage is obtained, and a first number of Task tasks included in the scheduling stage Stage is obtained;
[0006] When the first number is less than a Task task number threshold, the execution duration of each Task task is compared with a first execution duration threshold;
[0007] When there is an abnormal Task task with an execution duration greater than the first execution duration threshold in the plurality of Task tasks, an alarm information is generated, and the alarm information comprises a task identifier of the abnormal Task task.
[0008] The present application embodiment further discloses a task monitoring device, which comprises:
[0009] The acquisition module is configured to, for any scheduling stage Stage in each Job included in the Spark task to be monitored, obtain the execution duration of a plurality of Task tasks in the scheduling stage Stage, and obtain a first number of Task tasks included in the scheduling stage Stage;
[0010] a comparison module configured to compare the execution duration of each of the Task tasks with a first execution duration threshold when the first number is less than a Task task number threshold;
[0011] a generation module configured to generate an alarm information when there is an abnormal Task task with an execution duration greater than the first execution duration threshold in the plurality of Task tasks, the alarm information including a task identification of the abnormal Task task.
[0012] The embodiment of the application further discloses an electronic device including a processor, a memory, and a computer program stored in the memory and executable on the processor, and the computer program implements the steps in the task abnormality early warning method according to any one of the first aspect when executed by the processor.
[0013] The embodiment of the application further provides a readable storage medium, and the readable storage medium stores a computer program, and the computer program implements the steps in the task abnormality early warning method according to any one of the first aspect when executed by a processor.
[0014] In the embodiment of the application, any scheduling stage Stage in each Job included in a required monitored Spark task. The execution duration of the plurality of Task tasks in the scheduling stage Stage is obtained, and the first number of the Task tasks included in the scheduling stage Stage. When the first number is less than a Task task number threshold, the execution duration of each Task task is compared with a first execution duration threshold, so that when there is an abnormal Task task with an execution duration greater than the first execution duration threshold in the plurality of Task tasks, an alarm information is generated, and the alarm information includes a task identification of the abnormal Task task. Wherein, one Spark task includes a plurality of Jobs, one Job corresponds to a plurality of Stages, and one Stage corresponds to a plurality of Tasks. In the embodiment of the application, the execution duration of the Task task under the Spark task is monitored, and the timeout abnormal Task task with an execution duration greater than the first execution duration threshold is alarmed. Compared with the scheme of alarming the timeout abnormal Task task of the Spark task by using the execution time of the Spark task, the monitoring and alarming granularity of the abnormal Task task is finer, and the monitoring effect of the abnormal Task task is better. BRIEF DESCRIPTION OF DRAWINGS
[0015] Figure 1 is an interaction flow diagram of each terminal device in a Spark Service mode provided by the embodiment of the application;
[0016] Figure 2 is a schematic diagram of a task abnormality early warning method provided by the embodiment of the application;
[0017] Figure 3 is a schematic diagram of the relationship between Spark indexes provided by an embodiment of the present application;
[0018] Figure 4 is a schematic diagram of a task abnormality early warning method provided by an embodiment of the present application;
[0019] Figure 5 is a schematic diagram of a task abnormality early warning method provided by an embodiment of the present application;
[0020] Figure 6 is a structural block diagram of a task monitoring device provided by an embodiment of the present application;
[0021] Figure 7 is a structural block diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0022] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0023] In order to facilitate understanding of the task abnormality early warning method provided by the embodiments of the present application, the following content is first introduced:
[0024] As shown in Figure 1 , the Spark Service mode is that a Spark task is started by submitting the task through a Spark client (Client), an HTTP server (Http Server) is started at the same time at a Spark driver end (Driver), the Http Server can interact with a Web server (Web Server), the Http Server receives a request transmitted from the Web Server, parses the request parameters, generates a Spark task by grouping with a domain name (GroupId), sends the task to an execution end (Executor) for execution, returns the execution result to the Spark Driver after the execution is completed, and finally returns the execution result to the request end, i.e., the Web Server.
[0025] Please refer to Figure 2 , which shows a flowchart of a task abnormality early warning method according to an embodiment of the present application. The task abnormality early warning method can be applied to Figure 1The Http server, the execution end or the early warning device are shown. The early warning device can communicate with the Http server and / or the execution end. The following embodiments are described by taking an example of a task exception early warning method executed by the early warning device. As shown in Figure 2 The method can include the following steps:
[0026] In step 201, the execution time of each Task in any scheduling stage Stage of each Job included in the required monitoring Spark task is obtained, and the first number of Task included in the scheduling stage Stage is obtained.
[0027] As shown in Figure 3 As shown in, a Spark application (App) includes one or more GroupId. Each GroupId generates a Spark task including one or more Job. Each Job includes one or more scheduling stage Stage. Each scheduling stage Stage includes one or more Task. Or it can also be said that a scheduling stage Stage is a Task set. In the embodiments of the present application, the abnormal task early warning of the Spark task is from the Task level. Therefore, each Task in each scheduling stage Stage of each Job included in a Spark task can be monitored.
[0028] In the embodiments of the present application, for any scheduling stage Stage in each Job included in the required monitoring Spark task, whether there is an execution timeout exception is determined according to the execution time of the multiple Task in the scheduling stage Stage. Wherein, the required monitoring Spark task can be each Spark task. Or, the required monitoring Spark task can be a user-specified task. For example, the early warning device can receive the user's selection input of the required monitoring Spark task. The early warning device determines the Spark task corresponding to the selection input as the required monitoring Spark task in response to the selection input. And the execution time of the multiple Task of the required monitoring Spark task is obtained.
[0029] Optionally, the early warning device can execute a Spark monitoring (SparkListener) method to monitor the SparkListenerTaskStart interface and the SparkListenerTaskEnd interface to obtain the launch time (Launch Time) and the finish time (Finish Time) of each Task in the Spark task. The early warning device can calculate the difference between the finish time and the launch time of each Task to obtain the execution time of each Task.
[0030] In an embodiment of the present invention, after obtaining the execution duration of multiple Task tasks in the scheduling stage Stage and the first number of Task tasks included in the scheduling stage Stage, the early warning device can compare the first number with the Task number threshold to determine whether the number of Task tasks in the scheduling stage Stage is small. The first number is the actual number of Task tasks included in a currently monitored scheduling stage Stage. The Task number threshold refers to the minimum comparison threshold of the Task tasks included in a scheduling stage Stage. Optionally, the value of the Task number threshold can be a positive integer greater than or equal to 4.
[0031] When the first number is less than the Task number threshold, it indicates that the number of Tasks in the scheduling stage is small. The early warning device can perform the following step 202 to compare the execution time of each Task with the execution time threshold.
[0032] Step 202: When the first number is smaller than the Task number threshold, compare the execution time of each Task with the first execution time threshold.
[0033] In an embodiment of the present application, the early warning device may store the first execution time threshold value itself. Alternatively, the early warning device may obtain the first execution time threshold value from other devices. Optionally, the first execution time threshold value may be the average value, maximum value, or half median of the execution time of historical normal Task tasks. It should be noted that the value of the first execution time threshold value may be adjusted according to actual needs, and this embodiment of the present application does not limit this.
[0034] When the first number is less than the Task number threshold, the early warning device determines, for each Task, whether there is an execution timeout anomaly in the Task by comparing the execution time of the Task with the first execution time threshold. When the execution time of the Task is greater than the first execution time threshold, it is determined that there is an execution timeout anomaly in the Task, and the Task is an abnormal Task. When the execution time of the Task is less than or equal to the first execution time threshold, it is determined that there is no execution timeout in the Task, and the Task is a normal Task.
[0035] Optionally, the pre-warning device can calculate a difference between the execution duration of each Task task and the first execution duration threshold when the first number is less than the Task task number threshold, to compare the execution duration of the Task task with the first execution duration threshold. When the difference between the execution duration of the Task task and the first execution duration threshold is greater than zero, it indicates that the Task task has an abnormal situation of execution timeout, and the Task task is determined as an abnormal Task task. When the difference between the execution duration of the Task task and the first execution duration threshold is less than or equal to zero, it indicates that the Task task does not have an execution timeout situation, and the Task task is determined as a normal Task task.
[0036] Step 203, when there is an abnormal Task task with an execution duration greater than the first execution duration threshold in the plurality of Task tasks, generating an alarm information. The alarm information includes the task identifier of the abnormal Task task.
[0037] In the embodiment of the application, when there is a comparison result indicating that the execution duration of the Task task is greater than the first execution duration threshold in the comparison result of the execution duration of each Task task with the first execution duration threshold, it is determined that there is an abnormal Task task with an execution duration greater than the first execution duration threshold in the plurality of Task tasks. The pre-warning device can obtain the task identifiers of all abnormal Task tasks with an execution duration greater than the first execution duration threshold, and generate an alarm information including all the task identifiers. The task identifier is used to uniquely identify the Task task. The task identifier can be the Task identity certificate identifier (Identity document, ID) of the Task task.
[0038] In addition, the Task task currently running in one scheduling stage Stage needs to be less than or equal to the Task parallel degree. Therefore, if there is an abnormal Task task with an execution duration greater than the first execution duration threshold when the first number is less than the Task task number threshold. It is highly probable that the reason for the abnormal Task task is that the number of Task tasks is small and the set value of the Task parallel degree is too small. Therefore, the alarm information can also include warning information for indicating that the set value of the Task parallel degree is too small, to remind the optimization of the Task parallel degree and improve the number of concurrent execution of Task tasks. The Task parallel degree CTN refers to the set value of the number of Task tasks included in one scheduling stage Stage, that is, the number of parallel Task tasks of one scheduling stage Stage.
[0039] Of course, when there is no abnormal Task task with an execution duration greater than the first execution duration threshold in the plurality of Task tasks, i.e., the execution duration of each Task task is less than the first execution duration threshold, it indicates that there is no execution timeout for each Task task, and it is determined that the monitored Spark task is normal.
[0040] In the embodiment of the application, any scheduling stage Stage in each Job included in the monitored Spark task. The execution duration of the plurality of Task tasks in the scheduling stage Stage is obtained, and the first number of Task tasks included in the scheduling stage Stage is obtained. When the first number is less than the Task task number threshold, the execution duration of each Task task is compared with the first execution duration threshold, so that when there is an abnormal Task task with an execution duration greater than the first execution duration threshold in the plurality of Task tasks, an alarm information is generated, and the alarm information includes the task identifier of the abnormal Task task. In the embodiment of the application, a Spark task includes a plurality of Jobs, a Job corresponds to a plurality of Stages, and a Stage corresponds to a plurality of Tasks. In the embodiment of the application, the execution duration of the Task task under the Spark task is monitored to alarm the timeout abnormal Task task with an execution duration greater than the first execution duration threshold. Compared with the scheme of using the execution time of the Spark task to alarm the timeout abnormal Task task, the monitoring and alarming granularity of the abnormal Task task is finer, and the monitoring effect of the abnormal Task task is better.
[0041] In the embodiment of the application, when the first number is greater than or equal to the Task task number threshold, it indicates that the number of Task tasks of the scheduling stage Stage is large. At this time, if the execution duration of each Task task is compared with the first execution duration threshold, the calculation amount of the warning device is large, and the power consumption is high. Therefore, the warning device can set a screening step to screen the Task task with a large probability of timeout abnormality from the plurality of Task tasks when the first number is greater than or equal to the Task task number threshold, and determine whether the execution duration of the Task task is timeout, so as to reduce the calculation amount of the warning device.
[0042] Optionally, as shown in Figure 4 the method further includes:
[0043] In step 401, when the first quantity is greater than or equal to a Task task quantity threshold value, a Task task with an execution duration greater than a reference execution duration in the plurality of Task tasks is determined as a high-probability abnormal task. The reference execution duration is an execution duration of a Task task in a first sequence in the plurality of Task tasks sorted in descending order of execution duration.
[0044] In the embodiments of the present application, the early warning device can select the high-probability abnormal task with the execution duration greater than the reference execution duration from the plurality of Task tasks.
[0045] Optionally, the first sequence can have a value of [2 / N, N], where N is the number of the plurality of Task tasks. For example, the first sequence can have a value of 2 / 3N, 3 / 4N, or 4 / 5N, etc. The reference execution duration can be three-fourths of the median, two-thirds of the median, or four-fifths of the median of the execution durations of the plurality of Task tasks, etc. The greater the value of the first sequence, the fewer the high-probability abnormal tasks after the selection, and the smaller the calculation amount of the subsequent execution step. It should be noted that the value of the first sequence can be determined according to actual conditions. For example, the higher the accuracy of the abnormal early warning of the Task task, the smaller the value of the first sequence.
[0046] In some embodiments of the present application, before step 401, the method further includes: the early warning device sorts the plurality of Task tasks in descending order of execution duration to obtain a plurality of sorted Task tasks. The execution duration of a Task task in a first sequence in the plurality of sorted Task tasks is determined as the reference execution duration.
[0047] In step 402, when the ratio of the first quantity to the Task parallelism of the scheduling stage Stage is less than a concurrent execution ratio threshold value, the execution time of each high-probability abnormal task is compared with a second execution duration threshold value.
[0048] In the embodiments of the present application, the early warning device can first calculate the ratio of the first quantity to the Task parallelism of the scheduling stage Stage, and then compare the ratio with the concurrent execution ratio threshold value.
[0049] When the ratio of the first number and the Task parallelism of the scheduling stage Stage is less than the concurrent execution ratio threshold, it indicates that the number of Task tasks actually included in the scheduling stage Stage is not very large. The early warning device compares the execution time of each high-probability abnormal task with the size of the second execution time threshold. The second execution time threshold can be the same as the first execution time threshold. Alternatively, the second execution time threshold can be different from the first execution time threshold. Optionally, the second execution time threshold is greater than the first execution time threshold. It should be noted that the value of the second execution time threshold can be adjusted according to actual needs, and the embodiments of the present application do not limit this.
[0050] It should be noted that the implementation of comparing the execution time of each high-probability abnormal task with the size of the second execution time threshold can refer to the implementation of comparing the execution time of each Task task with the size of the first execution time threshold, and the embodiments of the present application do not repeat it here.
[0051] Step 403, when there is an abnormal Task task with an execution time greater than the second execution time threshold in the high-probability abnormal task, generating an alarm information. The alarm information includes the task identifier of the abnormal Task task.
[0052] In the embodiments of the present application, when the comparison result of the execution time of each high-probability abnormal task and the second execution time threshold indicates that the execution time is greater than the second execution time threshold, it is determined that there is an abnormal Task task with an execution time greater than the second execution time threshold in the high-probability abnormal task. The early warning device can obtain the task identifier of all abnormal Task tasks with an execution time greater than the second execution time threshold, and generate an alarm information including all task identifiers. The task identifier is used to uniquely identify the Task task. The task identifier can be the Task identity certificate identifier (Identity document, ID) of the Task task.
[0053] Of course, when there is no abnormal Task task with an execution time greater than the second execution time threshold in the high-probability abnormal task, that is, the execution time of each high-probability abnormal task is less than the second execution time threshold, it indicates that each high-probability abnormal task does not exist execution timeout, so it is determined that each Task task in the scheduling stage Stage is abnormal, and then it is determined that the monitored Spark task is abnormal.
[0054] Optionally, when the ratio of the first number and the Task parallelism of the scheduling stage Stage is greater than or equal to the concurrent execution ratio threshold, the early warning device can further perform the following steps 404 and 405.
[0055] Step 404: When the ratio of the first number to the Task parallelism of the scheduling stage Stage is greater than or equal to the concurrent execution ratio threshold, calculate the difference between the execution time of each high-probability abnormal task and the execution time of the reference Task task, and the target ratio of the difference to the execution time of the high-probability abnormal task, and obtain the target ratio corresponding to each high-probability abnormal task.
[0056] The reference task is the task in the second order among the multiple tasks sorted in ascending order of execution time. The value of the second order is smaller than the value of the first order.
[0057] Optionally, the value of the second order can be [1, 2 / N], where N is the number of multiple Tasks. For example, the value of the second order can be 1 / 3N, 1 / 4N, or 1 / 2N, etc. The execution time of the reference Task can be one-third, one-quarter, or one-half the median of the execution time of multiple Tasks, etc. It should be noted that the value of the second order can be determined according to actual conditions. For example, if the accuracy of the abnormal warning of the Task is required to be higher, the value of the second order should be smaller.
[0058] In this embodiment of the present application, when the ratio of the first number to the Task parallelism of the scheduling stage is greater than or equal to the concurrent execution ratio threshold, it indicates that the scheduling stage actually includes a large number of Tasks. The early warning device can determine whether a high-probability abnormal task has timed out based on the ratio by which the execution time of each high-probability abnormal task exceeds the execution time of the reference Task.
[0059] Step 405: When there is an abnormal task whose target ratio is greater than the task timeout ratio threshold among the high-probability abnormal tasks, an alarm message is generated. The alarm message includes the task identifier of the abnormal task.
[0060] In an embodiment of the present application, the early warning device can compare the target ratio corresponding to each high-probability abnormal task with the Task timeout ratio threshold. When the target ratio corresponding to the high-probability abnormal task is greater than the Task timeout ratio threshold, it indicates that the high-probability abnormal task has an execution timeout. When the target ratio corresponding to the high-probability abnormal task is less than or equal to the Task timeout ratio threshold, it indicates that the high-probability abnormal task has not an execution timeout.
[0061] When the comparison result indicates that the target ratio is greater than the Task timeout ratio threshold, the pre-warning device determines that there is an abnormal Task task in the high-probability abnormal task, where the target ratio of the abnormal Task task is greater than the Task timeout ratio threshold. The pre-warning device can obtain the task identifier of all abnormal Task tasks with a target ratio greater than the Task timeout ratio threshold, and generate alarm information including all task identifiers. The task identifier is used to uniquely identify the Task task. The task identifier can be the Task identity document (ID) of the Task task.
[0062] Of course, when there is no abnormal Task task in the high-probability abnormal task, that is, the target ratio of each high-probability abnormal task is less than or equal to the Task timeout ratio threshold, it indicates that each high-probability abnormal task does not have an execution timeout, and thus it is determined that each Task task in the scheduling stage Stage is normal, and further it is determined that the monitored Spark task is normal.
[0063] Optionally, the Task timeout ratio threshold can be determined according to the execution timeout capacity of the Task task and the target value of the execution duration of the plurality of historical Task tasks. The execution timeout capacity refers to the capacity value of the execution duration of the Task task exceeding the target value. The target value can be the average value, half median, or maximum value of the execution duration of the plurality of historical Task tasks. For example, the Task timeout ratio threshold can be 0.85, 0.9, or 0.95.
[0064] In the embodiments of the present application, the values of the first execution duration threshold and the second execution duration threshold can be adjusted by the user according to the actual situation, so that the accuracy of determining abnormal Task tasks based on the first execution duration threshold and / or the second execution duration threshold is higher.
[0065] Optionally, the method further comprises: obtaining an execution duration initial threshold, a first threshold adjustment coefficient, and a second threshold adjustment coefficient. The first execution duration threshold is calculated based on the execution duration initial threshold and the first threshold adjustment coefficient, and the second execution duration threshold is calculated based on the execution duration initial threshold and the second threshold adjustment coefficient, and the second execution duration threshold is greater than the first execution duration threshold.
[0066] The first threshold adjustment coefficient and the second threshold adjustment coefficient can be positive numbers less than 1. Optionally, the first threshold adjustment coefficient can be 1 / 10, 1 / 9, or 1 / 8. The second threshold adjustment coefficient can be 1 / 3, 1 / 2, 1 / 4, or the like. Optionally, the initial threshold of the execution duration, the first threshold adjustment coefficient, and the second threshold adjustment coefficient can be data written by a user in a parameter setting page. The initial threshold of the execution duration can be an average value, a maximum value, or a half median of the execution duration of a historical normal Task.
[0067] It should be noted that the early warning device can also listen to the return information of the Task End Reason interface corresponding to each Task. The Task End Reason interface is used to return the end reason of the Task when the Task is interrupted abnormally. Thus, the early warning device can also determine that the Task is interrupted abnormally when it is found that the return information of the Task End Reason interface corresponding to the Task is not empty, and generate the alarm information including the task identifier of the Task.
[0068] In summary, in the task abnormality early warning method provided by the embodiments of the present application, any scheduling stage Stage in each Job included in the required monitored Spark Task is targeted. The execution duration of each Task in the scheduling stage Stage is obtained, and the first number of Task included in the scheduling stage Stage is obtained. When the first number is less than the Task number threshold, the execution duration of each Task is compared with the first execution duration threshold, so that when there is an abnormal Task whose execution duration is greater than the first execution duration threshold in the multiple Tasks, the alarm information is generated, and the alarm information includes the task identifier of the abnormal Task. In the present application, one Spark Task includes multiple Jobs, one Job corresponds to multiple Stages, and one Stage corresponds to multiple Tasks. In the embodiments of the present application, the Task under the Spark Task is targeted, and the execution duration of the Task is monitored to alarm the timeout abnormal Task whose execution duration is greater than the first execution duration threshold. Compared with the scheme of using the execution time of the Spark Task to alarm the timeout abnormal Task of the Spark Task, the monitoring and alarming granularity of the abnormal Task is finer, and the monitoring effect of the abnormal Task is better.
[0069] Please refer to Figure 5 which shows a flowchart of a task abnormality early warning method provided by the embodiments of the present application. The task abnormality early warning method can be applied to Figure 1The Http server, the execution end or the early warning device are shown. The early warning device can communicate with the Http server and / or the execution end. The following embodiments are described by taking the task anomaly early warning method executed by the early warning device as an example. As shown in the figure Figure 5 The method includes the following steps:
[0070] Step 501, for each scheduling stage Stage included in the required monitored Spark task, the first number of Task tasks included in the scheduling stage Stage is counted, and the execution time of the plurality of Task tasks in the scheduling stage Stage is obtained.
[0071] Step 502, determine whether the first number is less than the Task task number threshold. If yes, execute step 503; if no, execute step 505.
[0072] Step 503, compare the execution time of each Task task with the first execution time threshold.
[0073] Step 504, when there is an abnormal Task task with an execution time greater than the first execution time threshold in the plurality of Task tasks, generate an alarm information. The alarm information includes the task identifier of the abnormal Task task.
[0074] Step 505, the Task task with an execution time greater than the reference execution time in the plurality of Task tasks is regarded as a high-probability abnormal task.
[0075] The reference execution time is the execution time of the Task task at the first order in the plurality of Task tasks sorted in descending order of execution time.
[0076] Step 506, determine whether the ratio of the first number to the Task parallelism of the scheduling stage Stage is less than the concurrent execution ratio threshold. If yes, execute step 507; if no, execute step 509.
[0077] Step 507, compare the execution time of each high-probability abnormal task with the second execution time threshold.
[0078] Step 508, when there is an abnormal Task task with an execution time greater than the second execution time threshold in the high-probability abnormal task, generate an alarm information. The alarm information includes the task identifier of the abnormal Task task.
[0079] Step 509, calculate the difference between the execution time of each high-probability abnormal task and the execution time of the reference Task task, and the target ratio of the difference to the execution time of the high-probability abnormal task, to obtain the target ratio corresponding to each high-probability abnormal task.
[0080] The reference Task task is a Task task in a plurality of Task tasks sorted in descending order of execution duration, and is located at a second order.
[0081] At step 510, when the target ratio of the abnormal Task task in the high-probability abnormal task is greater than the Task timeout ratio threshold, alarm information is generated. The alarm information includes the task identifier of the abnormal Task task.
[0082] It should be noted that steps 501 to 510 can refer to the related explanations and implementation manners in the foregoing embodiments, and the present embodiment will not be repeated here.
[0083] In summary, in the task abnormality early warning method provided by the present embodiment, any scheduling stage Stage in each Job included in the Spark task to be monitored is targeted. The execution duration of the plurality of Task tasks in the scheduling stage Stage and the first number of Task tasks included in the scheduling stage Stage are obtained. When the first number is less than the Task task number threshold, the execution duration of each Task task is compared with the first execution duration threshold, so that when there is an abnormal Task task with an execution duration greater than the first execution duration threshold in the plurality of Task tasks, alarm information is generated, and the alarm information includes the task identifier of the abnormal Task task. One Spark task includes a plurality of Jobs, one Job corresponds to a plurality of Stages, and one Stage corresponds to a plurality of Tasks. In the present embodiment, the Task task level under the Spark task is started, and the execution duration of the Task task is monitored to alarm the timeout abnormal Task task with an execution duration greater than the first execution duration threshold. Compared with the scheme of using the execution time of the Spark task to alarm the timeout abnormal Task task of the Spark task, the monitoring and alarm granularity of the abnormal Task task is finer, and the monitoring effect of the abnormal Task task is better.
[0084] Please refer to Figure 6 which shows a block diagram of a task abnormality early warning device provided by an embodiment of the present application. As Figure 6 shown, the task abnormality early warning device 600 includes an acquisition module 601, a comparison module 602, and a generation module 603.
[0085] The acquisition module 601 is configured to, for any scheduling stage Stage in each Job included in the Spark task to be monitored, obtain the execution duration of the plurality of Task tasks in the scheduling stage Stage and the first number of Task tasks included in the scheduling stage Stage.
[0086] The comparison module 602 is configured to compare the execution duration of each Task task with the first execution duration threshold when the first quantity is less than the Task task quantity threshold.
[0087] The generation module 603 is configured to generate alarm information when there is an abnormal Task task with an execution duration greater than the first execution duration threshold in the plurality of Task tasks, the alarm information including the task identifier of the abnormal Task task.
[0088] Optionally, the apparatus further includes a determination module configured to, when the first quantity is greater than or equal to the Task task quantity threshold, regard a Task task with an execution duration greater than a reference execution duration as a high-probability abnormal task, the reference execution duration being the execution duration of a Task task at a second order in the plurality of Task tasks sorted in ascending order of execution duration.
[0089] The comparison module 602 is further configured to compare the execution time of each high-probability abnormal task with the second execution duration threshold when the ratio of the first quantity to the Task parallelism of the scheduling stage Stage is less than the concurrent execution ratio threshold.
[0090] The generation module 603 is configured to generate alarm information when there is an abnormal Task task with an execution duration greater than the second execution duration threshold in the high-probability abnormal tasks, the alarm information including the task identifier of the abnormal Task task.
[0091] Optionally, the apparatus further includes a calculation module configured to, when the ratio of the first quantity to the Task parallelism of the scheduling stage Stage is greater than or equal to the concurrent execution ratio threshold, calculate the difference between the execution time of each high-probability abnormal task and the execution time of a reference Task task, and a target ratio of the difference to the execution time of the high-probability abnormal task, to obtain a target ratio corresponding to each high-probability abnormal task, the reference Task task being a Task task at a second order in the plurality of Task tasks sorted in ascending order of execution duration, the value of the second order being less than the value of the first order.
[0092] The generation module 603 is configured to generate alarm information when there is an abnormal Task task with a target ratio greater than the Task timeout ratio threshold in the high-probability abnormal tasks, the alarm information including the task identifier of the abnormal Task task.
[0093] Optionally, the acquisition module 601 is configured to acquire an initial execution duration threshold, a first threshold adjustment coefficient, and a second threshold adjustment coefficient.
[0094] A calculation module is used to calculate a first execution duration threshold based on an initial execution duration threshold and a first threshold adjustment coefficient; and is also used to calculate a second execution duration threshold based on the initial execution duration threshold and a second threshold adjustment coefficient, wherein the second execution duration threshold is greater than the first execution duration threshold.
[0095] Optionally, the reference execution duration is a median of three quarters of the execution durations of the multiple Task tasks, and the execution duration of the reference Task task is a median of one half of the execution durations of the multiple Task tasks.
[0096] In summary, in the task abnormality warning device provided in the embodiment of the present application, for any scheduling stage Stage in each Job included in the Spark task to be monitored. By obtaining the execution time of multiple Task tasks in the scheduling stage Stage, and the first number of Task tasks included in the scheduling stage Stage. When the first number is less than the Task task number threshold, the execution time of each Task task is compared with the first execution time threshold, so that when there is an abnormal Task task with an execution time greater than the first execution time threshold among the multiple Task tasks, an alarm information is generated, and the alarm information includes the task identifier of the abnormal Task task. Among them, a Spark task includes multiple Jobs, a Job corresponds to multiple Stages, and a Stage corresponds to multiple Tasks. In the embodiment of the present invention, starting from the Task level under the Spark task, by monitoring the execution time of the Task task, an alarm is issued for the timeout abnormal Task task with an execution time greater than the first execution time threshold. Compared with the solution of using the execution time of Spark tasks to issue timeout exception alarms for Spark tasks, the monitoring alarm granularity of Spark abnormal tasks is finer and the monitoring effect of abnormal tasks is better.
[0097] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0098] Please refer to Figure 7 , which shows a block diagram of an electronic device provided by an embodiment of the present application. Figure 7 As shown, the electronic device 700 includes: one or more processors 701; and one or more memories 702 having instructions stored thereon. When executed by the one or more processors 701, the electronic device 700 executes the method described in the embodiment of the present invention.
[0099] The embodiments of the present invention further provide one or more machine-readable media having instructions stored thereon, which, when executed by one or more processors, enable the processors to perform the methods described in the embodiments of the present invention.
[0100] An embodiment of the present invention further provides a readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described in the embodiment of the present invention is implemented.
[0101] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0102] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0103] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the process in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0104] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0105] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1steps of a function specified in one or more blocks.
[0106] While the preferred embodiments of the application have been described above, it should be understood that many modifications and variations to these embodiments will be apparent to those skilled in the art once they learn of the basic inventive concepts. Therefore, the attached claims are intended to cover all such modifications and variations.
[0107] Finally, it is to be understood that the phraseology or terminology employed herein, such as "first" and "second", etc., are for descriptive purposes only and should not be construed to be indicative of a necessary order of occurrence, the relationships or sequences of elements or steps, etc., unless expressly so limited. Moreover, the terms "comprising", "including", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises a... " does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the recited element.
[0108] The task exception early warning method and device, electronic equipment and readable storage medium provided by the present application are described in detail above, and the principles and implementation manners of the present application are described by applying specific examples in the present article. The above description of the embodiments is only used to help understand the method of the present application and its core idea; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manners and application ranges will be changed, and the above description of the present application should not be understood as a limitation of the present application.
Claims
1. A task abnormality warning method, characterized in that: The method comprises: For any scheduling stage in each job included in the Spark task to be monitored, obtain the execution duration of multiple Task tasks in the scheduling stage and the first number of Task tasks included in the scheduling stage; When the first number is less than the Task number threshold, comparing the execution time of each Task with the first execution time threshold; When there is an abnormal Task task whose execution time is longer than the first execution time threshold among the multiple Task tasks, generating an alarm message, the alarm message including a task identifier of the abnormal Task task; When the first number is greater than or equal to the Task number threshold, the Task task whose execution time among the multiple Task tasks is longer than the reference execution time is regarded as a high-probability abnormal task, and the reference execution time is the execution time of the Task task in the first order among the multiple Task tasks after the execution time is sorted in ascending order.
2. The method according to claim 1, characterized in that The method further comprises: When the ratio of the first number to the Task parallelism of the scheduling stage Stage is less than the concurrent execution ratio threshold, comparing the execution time of each of the high-probability abnormal tasks with the second execution time threshold; When there is an abnormal Task task whose execution time is longer than the second execution time threshold among the high-probability abnormal tasks, generating an alarm message, the alarm message including the task identifier of the abnormal Task task; When the ratio of the first number to the Task parallelism of the scheduling stage Stage is greater than or equal to the concurrent execution ratio threshold, the difference between the execution time of each of the high-probability abnormal tasks and the execution time of the reference Task task is calculated, as well as the target ratio of the difference to the execution time of the high-probability abnormal task, to obtain the target ratio corresponding to each of the high-probability abnormal tasks, where the reference Task task is the Task task in the second order among the multiple Task tasks sorted in ascending order of execution time, and the value of the second order is smaller than the value of the first order.
3. The method according to claim 2, characterized in that The method further comprises: When there is an abnormal Task task whose target ratio is greater than a Task timeout ratio threshold among the high-probability abnormal tasks, an alarm message is generated, where the alarm message includes a task identifier of the abnormal Task task.
4. The method according to claim 2, characterized in that The method further comprises: Obtaining an initial execution time threshold, a first threshold adjustment coefficient, and a second threshold adjustment coefficient; The first execution duration threshold is calculated based on the execution duration initial threshold and the first threshold adjustment coefficient; The second execution duration threshold is calculated based on the initial execution duration threshold and the second threshold adjustment coefficient, and the second execution duration threshold is greater than the first execution duration threshold.
5. The method according to claim 3, characterized in that The reference execution duration is three-quarters of the median of the execution durations of the multiple Task tasks, and the execution duration of the reference Task task is one-half of the median of the execution durations of the multiple Task tasks.
6. A task abnormality warning device, characterized in that: The device comprises: An acquisition module is used to acquire, for any scheduling stage in each job included in the Spark task to be monitored, the execution duration of multiple Task tasks in the scheduling stage and the first number of Task tasks included in the scheduling stage; a comparison module, configured to compare the execution time of each Task task with a first execution time threshold when the first number is less than a Task number threshold; a generating module, configured to generate an alarm message when there is an abnormal Task task whose execution duration is greater than the first execution duration threshold among the plurality of Task tasks, wherein the alarm message includes a task identifier of the abnormal Task task; A determination module is used to, when the first number is greater than or equal to a Task number threshold, treat a Task task among the multiple Task tasks whose execution time is greater than a reference execution time as a high-probability abnormal task, where the reference execution time is the execution time of the Task task in the first order among the multiple Task tasks sorted in ascending order of execution time.
7. The device according to claim 6, characterized in that The device further comprises: The comparison module is further configured to compare the execution time of each of the high-probability abnormal tasks with a second execution duration threshold when the ratio of the first number to the Task parallelism of the scheduling stage Stage is less than a concurrent execution ratio threshold; The generating module is configured to generate an alarm message when there is an abnormal task whose execution time is longer than the first execution time threshold among the high-probability abnormal tasks, wherein the alarm message includes a task identifier of the abnormal task; A calculation module is used to calculate the difference between the execution time of each of the high-probability abnormal tasks and the execution time of the reference Task task when the ratio of the first number to the Task parallelism of the scheduling stage Stage is greater than or equal to the concurrent execution ratio threshold, and the target ratio of the difference to the execution time of the high-probability abnormal task, to obtain the target ratio corresponding to each of the high-probability abnormal tasks, wherein the reference Task task is the Task task in the second order among the multiple Task tasks sorted in ascending order of execution time, and the value of the second order is smaller than the value of the first order.
8. The device according to claim 7, characterized in that The device further comprises: The generating module is configured to generate an alarm message when there is an abnormal task whose target ratio is greater than a task timeout ratio threshold among the high-probability abnormal tasks, wherein the alarm message includes a task identifier of the abnormal task.
9. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the task abnormality warning method as claimed in any one of claims 1 to 5.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the task abnormality warning method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for diagnosing Spark application
CN110175124A
Resource monitoring method and device based on YARN, and terminal equipment
CN111290917A