Thread anomaly detection method, thread anomaly detection device and computer program product
By encapsulating and adding exception detection timing tasks to business requests on the server, precise detection of thread execution exceptions is achieved, and the problems of failure to detect threads such as thread jamming and process crashes in the existing technology are solved, and the server thread is improved Pool's abnormal detection capability.
Patent Information
- Application Number
- CN202411186138.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-27
- Publication Date
- 2024-12-03
AI Technical Summary
In the prior art, the server thread pool thread cannot accurately detect the execution exception when responding to business requests, especially when there is no request response information such as thread jamming and process crashes, the exception cannot be detected quickly and accurately.
By receiving the client's business request, extracting the request information and encapsulating it into a monitoring event object, adding exception detection timing tasks, and regularly checking these tasks when executing business requests to detect exceptions, including timeout, excessive CPU usage and excessive memory applications, etc. Implement accurate detection of thread exceptions.
Based on the timed polling algorithm and a single independent thread, it can efficiently detect exceptions of hundreds or thousands of threads in the server thread pool, realizing accurate detection of thread execution exceptions, and solving the problem that cannot be accurately detected in the prior art.
Smart Images

Figure CN119065928A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of thread anomaly detection, and in particular to a thread anomaly detection method, a thread anomaly detection device, a computer-readable storage medium, and a computer program product. Background Art
[0002] With the development of consumer Internet and the deepening of informatization and digital transformation, people's food, clothing, housing, transportation, national economy, etc. are increasingly dependent on information technology. Information technology service providers are always facing huge access traffic. They need to ensure high concurrency of services while also ensuring high availability of services. This requires the server to be able to quickly and accurately detect problems and deal with them when abnormalities occur in response to client requests. At present, common thread execution exceptions on the server side include: long execution time, execution stuck, etc., resulting in insufficient available threads on the server side and thus unable to respond to client requests in time; too much business data or code bugs requesting a large amount of memory, resulting in memory exhaustion and process termination; code bugs occupying a large amount of CPU resources, etc.
[0003] There are two main methods for detecting abnormal execution of server threads in the prior art. One is to detect abnormal situations through a non-invasive bypass log system and a monitoring system. However, this type of method has two problems: First, an additional bypass log system needs to be introduced, which increases the access cost and operation and maintenance cost. Second, when the log cannot be printed (there is no request response information) due to thread stuck, process crash, etc., it is impossible to detect abnormal situations based on logs or request response information; the other type requires intrusion into the business system, that is, the timeout mechanism requires each business system to repeat the coding implementation or needs to explicitly introduce the encapsulated timeout detection function package, and there are scene restrictions, such as the "data processing timeout" scene, which is not universal enough. There are two disadvantages for the prior art to intercept request responses by plugging, and to use the abnormal information in the request response to realize abnormal detection. First, the applicable scenario is relatively narrow, and it is only applicable to the scenario where the abnormal information is directly exposed to the client; second, there are limitations. For abnormal scenarios such as thread stuck and process crash, there is no response information, no additional information such as abnormal logs, and when such abnormalities occur, they cannot be detected quickly and accurately. The existing technology uses non-instrumentation methods to detect anomalies, which has the disadvantage of intruding into business programs. The anomaly detection method that does not intrude into business programs requires the introduction of additional components such as log collection systems, which have high access costs, slow response speeds, and easy loss of logs. At the same time, it has the disadvantage of being unable to detect abnormal scenarios without logs, such as thread jams and process crashes. Summary of the invention
[0004] The main purpose of the present application is to provide a thread exception detection method, a thread exception detection device, a computer-readable storage medium and a computer program product, so as to at least solve the problem in the prior art that execution exceptions of server-side thread pool threads in response to business requests cannot be accurately detected.
[0005] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a thread exception detection method is provided, comprising: receiving a business request sent by a client; extracting the corresponding request information in the business request, and encapsulating the request information into a monitoring event object corresponding to the business request, and adding an exception detection timing task to the monitoring event object, wherein the request information at least includes the server interface, request identifier and current execution thread to which the business request belongs, one business request corresponds to one monitoring event object, one monitoring event object corresponds to multiple exception detection timing tasks, each of the exception detection timing tasks corresponds to one or more set delay times, and the set delay time is the time when the corresponding exception detection timing task is delayed in execution; executing the business request, and when the execution request time reaches the set delay time corresponding to any one of the exception detection timing tasks, executing the corresponding exception detection timing task to perform exception detection on the monitoring event object to obtain an abnormal event of the monitoring event object, the execution request time is the actual execution time of the business request, and the abnormal event is an event in which an abnormality is detected when the abnormality detection timing task is executed; and processing the abnormal event.
[0006] Optionally, after receiving the business request sent by the client, the method also includes: determining the current server framework, and querying the corresponding framework source code according to the current server framework to obtain a target entry, wherein the target entry is the execution start entry for executing the business request under the current server framework; intercepting the target entry at the interception point using the plug-in technology, wherein the interception point is the position where the target entry is intercepted; before the target entry, injecting a first plug-in code, wherein the first plug-in code is used to encapsulate the corresponding monitoring event object for the business request before executing the business request, and to add the anomaly detection timing task; after the target entry, injecting a second plug-in code, wherein the second plug-in code is used to remove the monitoring event object corresponding to the business request after executing the business request, and to remove the anomaly detection timing task.
[0007] Optionally, after receiving the service request sent by the client, the method further includes: when the current server framework changes, adding a new interception point to intercept the target entry according to the newly added interception point.
[0008] Optionally, adding an exception detection timer task to the monitoring event object includes: using the request identifier to identify the monitoring event object; adding the monitoring event object to a monitoring queue, the monitoring queue being a queue for monitoring the execution process of the business request; adding a plurality of the exception detection timer tasks to the monitoring event object according to a timing strategy, the timing strategy being a strategy for performing timed detection according to the set delay time corresponding to each of the exception detection timer tasks, the exception detection timer tasks being divided into time-type exception detection timer tasks and non-time-type exception detection timer tasks, the time-type exception detection timer tasks being timeout exception detection timer tasks, the non-time-type exception detection timer tasks at least including thread CPU occupancy excessive exception detection timer tasks and memory application excessive exception detection timer tasks, the monitoring event object and the exception detection timer tasks are associated through the request identifier.
[0009] Optionally, after executing the service request, the method further includes: when the execution of the service request is completed, removing the monitoring event object corresponding to the service request from the monitoring queue, and deleting all the anomaly detection scheduled tasks in the monitoring event object.
[0010] Optionally, executing the corresponding anomaly detection timing task to perform anomaly detection on the monitoring event object to obtain the abnormal event of the monitoring event object, including: using the timing task scheduling algorithm to schedule the anomaly detection timing task in sequence; querying the monitoring event object in the monitoring queue according to the request identifier; when the first monitoring condition and the second monitoring condition are met at the same time, determining the abnormal event detected in the time-type anomaly detection timing task as the abnormal event, the first monitoring condition is that the monitoring event object exists in the monitoring queue, and the second monitoring condition is that the anomaly detection timing task is the time-type anomaly detection timing task; when the first monitoring condition and the third monitoring condition are met at the same time, obtaining indicator data and judging whether the indicator data meets the judgment rule, the indicator data includes at least one of the following: CPU and memory percentage, the third monitoring condition is that the anomaly detection timing task is the non-time-type anomaly detection timing task; when the indicator data meets the judgment rule, determining the abnormal event detected in the non-time-type anomaly detection timing task as the abnormal event.
[0011] Optionally, processing the abnormal event includes: extracting the request information in the monitoring event object corresponding to the abnormal event; determining the corresponding business request based on the request information, and determining the business request as an abnormal request; issuing an alarm message based on the request information; printing the stack space of the abnormal request execution thread, and terminating the execution of the abnormal request.
[0012] According to another aspect of the present application, a thread exception detection device is provided, the device comprising: a receiving unit, configured to receive a service request sent by a client; an encapsulation unit, configured to extract request information corresponding to the service request, encapsulate the request information into a monitoring event object corresponding to the service request, and add an exception detection timing task to the monitoring event object, wherein the request information at least includes a server interface, a request identifier, and a current execution thread to which the service request belongs, one service request corresponds to one monitoring event object, one monitoring event object corresponds to multiple exception detection timing tasks, and each exception detection timing task corresponds to one or more set delay times; an execution unit, configured to execute the service request, and when the execution request time reaches the set delay time corresponding to any one of the exception detection timing tasks, execute the corresponding exception detection timing task to perform exception detection on the monitoring event object to obtain an abnormal event of the monitoring event object, wherein the execution request time is the actual execution time of the service request, and the abnormal event is an event in which an abnormality is detected when the abnormality detection timing task is executed; and a processing unit, configured to process the abnormal event.
[0013] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the methods described.
[0014] According to another aspect of the present application, a computer program product is provided, comprising computer instructions, wherein when the computer instructions are executed by a processor, any one of the methods described above is implemented.
[0015] Applying the technical solution of the present application, in a thread anomaly detection method, first, a business request sent by a client is received; then, the request information corresponding to the business request is extracted, and the request information is encapsulated as a monitoring event object of the business request, and an anomaly detection timer task is added to the monitoring event object, wherein the request information at least includes a server interface, a request identifier and a current execution thread to which the business request belongs, one business request corresponds to one monitoring event object, and one monitoring event object corresponds to multiple anomaly detection timer tasks, and a delay time is set, wherein the set delay time is the time for the corresponding anomaly detection timer task to be delayed in execution; thereafter, the business request is executed, and when the execution request time reaches the set delay time corresponding to any one of the anomaly detection timer tasks, the corresponding anomaly detection timer task is executed to perform anomaly detection on the monitoring event object, and an abnormal event of the monitoring event object is obtained, wherein the execution request time is the actual execution time of the business request, and the abnormal event is an event in which an abnormality is detected when the abnormality detection timer task is executed; finally, the abnormal event is processed. This application achieves accurate detection of anomalies by encapsulating business requests and adding anomaly detection timer tasks before executing business requests on the server side. After executing business requests on the server side, the anomaly detection timer tasks are executed on the abnormal requests to detect anomalies. Among them, in addition to detecting execution anomalies with request response information, the anomaly detection timer task can also detect execution anomalies without request response information, such as long thread execution time, thread stuck, excessive memory application leading to process crash. Based on the timed polling algorithm and a single independent thread, accurate detection of execution anomalies of hundreds or thousands of threads in the server thread pool can be efficiently achieved. This application solves the problem that execution anomalies cannot be accurately detected when the server thread pool threads respond to business requests. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 A hardware structure block diagram of a mobile terminal for executing a thread exception detection method provided in an embodiment of the present application is shown;
[0017] Figure 2 A schematic diagram of a process flow of a thread anomaly detection method provided according to an embodiment of the present application is shown;
[0018] Figure 3 A structural framework diagram of a thread anomaly detection system provided according to an embodiment of the present application is shown;
[0019] Figure 4 A target entry interception flow chart provided according to an embodiment of the present application is shown;
[0020] Figure 5 A monitoring event registration flow chart provided according to an embodiment of the present application is shown;
[0021] Figure 6 A monitoring event object removal flow chart provided according to an embodiment of the present application is shown;
[0022] Figure 7 A flowchart of a scheduling anomaly detection timing task provided according to an embodiment of the present application is shown;
[0023] Figure 8 A flowchart of handling abnormal events provided according to an embodiment of the present application is shown;
[0024] Fig. 9 A structural block diagram of a thread anomaly detection device provided according to an embodiment of the present application is shown.
[0025] The above drawings include the following reference numerals:
[0026] 102, processor; 104, memory; 106, transmission device; 108, input and output devices. DETAILED DESCRIPTION
[0027] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0028] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] For the convenience of description, some nouns or terms involved in the embodiments of the present application are explained below:
[0031] Lightweight: Lightweight and simple, easy to use, this application does not require reliance on additional components, and the access cost is low.
[0032] Non-intrusive: Independent of the business code, no code needs to be changed when the business is connected.
[0033] Stub: A technique for injecting a piece of code into a target program. This technique is often used for program testing, monitoring, and tracing. Currently, mainstream languages all support stub technology, such as Java's agent, C / C++'s Pin, Go's gomonkey, Python's Hook, etc.
[0034] Timing Wheel Algorithm: An efficient timed task scheduling algorithm with O(1) time complexity, implemented by using a circular array and a linked list. Each element of the array represents a time slot. If there is a task to be executed in the current time slot, a linked list of tasks to be executed will be associated with it.
[0035] As introduced in the background technology, the prior art uses the plugging method to intercept request responses and uses the exception information in the request response to implement exception detection, which has two disadvantages. First, the applicable scenario is relatively narrow, and it is only applicable to the scenario where the exception information is directly exposed to the client; second, there are limitations. For abnormal scenarios such as thread stuck and process crash, there is no response information, no additional information such as exception logs, and when such exceptions occur, they cannot be detected quickly and accurately. In order to solve the problem in the prior art that the server thread pool thread cannot accurately detect the execution exception when responding to a business request, the embodiments of the present application provide a thread exception detection method, a thread exception detection device, a computer-readable storage medium, and a computer program product.
[0036] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0037] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a thread exception detection method according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is for illustration only and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0038] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the display method of device information in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the above method is implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. The transmission device 106 is used to receive or send data via a network. The above-mentioned specific examples of the network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0039] In this embodiment, a thread anomaly detection method running on a mobile terminal, a computer terminal or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0040] Figure 2 is a flow chart of a thread exception detection method according to an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0041] Step S201: receiving a service request sent by a client.
[0042] Specifically, Figure 3 FIG. 4 shows a structural framework diagram of a thread anomaly detection system provided according to an embodiment of the present application, such as Figure 3As shown, the thread exception detection system includes a request receiving device, a monitoring event registration plugging device, a business request execution device, a target entry interception plugging device, an abnormal monitoring plugging device, an abnormal handling plugging device and a monitoring event removal plugging device. The request receiving device is used to receive the business request sent by the client. The request receiving device is the original business code and does not require any modification.
[0043] Step S202, extract the request information corresponding to the above-mentioned business request, and encapsulate the above-mentioned request information into a monitoring event object corresponding to the above-mentioned business request, and add an abnormality detection timing task to the above-mentioned monitoring event object. The above-mentioned request information at least includes the server interface, request identifier and current execution thread to which the above-mentioned business request belongs. One of the above-mentioned business request corresponds to one of the above-mentioned monitoring event object, and one of the above-mentioned monitoring event object corresponds to multiple of the above-mentioned abnormality detection timing tasks. Each of the above-mentioned abnormality detection timing tasks corresponds to one or more of the above-mentioned set delay times. The above-mentioned set delay time is the time for delaying the execution of the corresponding above-mentioned abnormality detection timing task.
[0044] Specifically, Figure 3 The monitoring event registration plug-in device in is used to execute the above step S202. The monitoring event registration plug-in device will register an abnormal monitoring event for each business request, that is, by extracting the service interface, request identifier, and current execution thread and other request information to which the business request belongs, and encapsulating these request information into a monitoring event object, and adding an abnormal detection timer task to the monitoring event object for abnormal monitoring. When an abnormal event occurs, detailed abnormal information can be provided to the operation and maintenance personnel based on these request information to achieve accurate abnormal alarms, thereby facilitating the operation and maintenance personnel to quickly locate and deal with problems. Among them, each of the above-mentioned abnormal detection timer tasks corresponds to one or more of the above-mentioned set delay times. For example, for the timeout abnormal detection timer task, a set delay time corresponds to the timer task, which is executed for 30 seconds each time. For the abnormal detection timer task of excessive CPU usage of the thread, a set delay time also corresponds to the timer task, which is executed for 20 seconds each time. For the abnormal detection timer task of excessive memory application, there are multiple set delay times. The first time is executed for 15 seconds, and then only 3 seconds each time. The specific set delay time can be set according to the actual situation.
[0045] Step S203, execute the above-mentioned business request. When the execution request time reaches the above-mentioned set delay time corresponding to any one of the above-mentioned abnormality detection timing tasks, execute the corresponding above-mentioned abnormality detection timing task to perform abnormality detection on the above-mentioned monitoring event object, and obtain the abnormal event of the above-mentioned monitoring event object. The above-mentioned execution request time is the current actual execution time of the above-mentioned business request, and the above-mentioned abnormal event is an event in which an abnormality is detected when executing the above-mentioned abnormality detection timing task.
[0046] Specifically, Figure 3 The service request execution device in is used to respond to the service request of the client and execute the corresponding service program. The above service request execution device is the original service code and does not need any modification. Figure 3 The abnormal monitoring instrumentation device in performs abnormal detection based on the registered and unremoved monitoring events, and efficiently implements abnormal detection through the time wheel algorithm and a single monitoring thread. The time wheel algorithm implements the scheduling of abnormal detection timed tasks, such as timed abnormal detection timed tasks, thread CPU occupancy excessive abnormal detection timed tasks, and excessive memory application abnormal detection timed tasks. It should be noted that the data statistics of CPU occupancy and memory application are thread-dimensional. The timed abnormal detection timed task can detect long thread execution time and thread execution stuck, but it is not limited to the above two types; a single monitoring thread is used to obtain valid scheduled tasks from the time wheel in chronological order and execute them. When it is determined that an abnormal event occurs, the abnormal event is sent to the abnormal handling instrumentation device. The abnormal monitoring instrumentation device only performs abnormal monitoring, and does not perform abnormal handling, to avoid the abnormal handling time being too long, resulting in the subsequent scheduled tasks not being able to be executed in time. This "monitoring-handling" decoupling method is used to efficiently implement abnormal detection.
[0047] Step S204, processing the above abnormal event.
[0048] Specifically, Figure 3 The exception handling plug device receives the exception event sent by the exception monitoring plug device for processing.
[0049] It should also be noted that the exception handling plug-in device can also be removed, but the handling function of the exception handling plug-in device needs to be integrated into the exception monitoring plug-in device, and then the number of threads in the exception monitoring plug-in device can be increased from 1 to multiple.
[0050] In this embodiment, first, a business request sent by a client is received; then, request information corresponding to the business request is extracted, and the request information is encapsulated as a monitoring event object corresponding to the business request, and an abnormality detection timing task is added to the monitoring event object, wherein the request information at least includes a server interface, a request identifier and a current execution thread to which the business request belongs, one business request corresponds to one monitoring event object, one monitoring event object corresponds to multiple abnormality detection timing tasks, each abnormality detection timing task corresponds to one or more set delay times, and the set delay time is the time for delayed execution of the corresponding abnormality detection timing task; then, the business request is executed, and when the execution request time reaches the set delay time corresponding to any one of the abnormality detection timing tasks, the corresponding abnormality detection timing task is executed to perform abnormality detection on the monitoring event object, and an abnormal event of the monitoring event object is obtained, the execution request time is the actual execution time of the business request, and the abnormal event is an event in which an abnormality is detected when executing the abnormality detection timing task; finally, the abnormal event is processed. This application achieves accurate detection of anomalies by encapsulating the business request and adding an anomaly detection timer task before the server executes the business request. After the server executes the business request, the anomaly detection timer task is executed on the abnormal request to detect the anomaly. Among them, in addition to detecting execution anomalies with request response information, the anomaly detection timer task can also detect execution anomalies without request response information, such as long thread execution time, thread stuck, excessive memory application leading to process crash. Based on the timed polling algorithm and a single independent thread, accurate detection of execution anomalies of hundreds or thousands of threads in the server thread pool can be efficiently achieved. This application solves the problem in the prior art that execution anomalies cannot be accurately detected when the server thread pool thread responds to business requests.
[0051] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the implementation process of the thread exception detection method of the present application will be described in detail below in combination with specific embodiments.
[0052] In order to enhance the business program capability to achieve lightweight, non-intrusive and accurate detection capability of thread execution exceptions, in an optional implementation, after the above step S201, the above method further includes:
[0053] Step S301, determining the current server framework, and querying the corresponding framework source code according to the current server framework to obtain a target entry, where the target entry is an execution start entry for executing the service request under the current server framework;
[0054] Step S302, intercepting the target entrance at the interception point by using the plugging technology, where the interception point is the position where the target entrance is intercepted;
[0055] Step S303, injecting a first plug-in code before the target entry, wherein the first plug-in code is used to encapsulate a corresponding monitoring event object for the business request before executing the business request, and to add the anomaly detection timer task;
[0056] Step S304, injecting a second plug-in code after the target entry, wherein the second plug-in code is used to remove the monitoring event object corresponding to the business request and the anomaly detection timing task after executing the business request.
[0057] In the above embodiment, the target entry interception flow chart is as follows: Figure 4 As shown in the figure, determine the framework used by the server, find the execution start entry (usually a fixed function) of the business request execution from the framework source code, mark the execution start entry as the target entry (that is, the location of the interception point), and use the stub technology to intercept the target entry when the business program starts, and dynamically Figure 3 The code corresponding to the monitoring event registration plug-in device in the program is injected before the target entry, and the code corresponding to the monitoring event removal plug-in device is injected after the target entry. After the code is injected, the monitoring event registration plug-in device will be executed before the original business code executes the business request, and the monitoring event removal plug-in device will be executed after the original business code executes the business request. The above embodiment belongs to the plug-in program function, which is independent of the business program. By dynamically injecting code, the business program capability is enhanced to achieve lightweight, non-invasive thread execution exception accurate detection capability. In extreme cases, when the business program does not use any server-side framework, the program source code of the above business program is directly queried, and an interception point is added to the unified start entry of the business request execution corresponding to the above business program.
[0058] In order to improve the maintainability and reusability of the code, in an optional implementation manner, after the above step S201, the above method further includes:
[0059] Step S401, when the current server framework changes, a new interception point is added to intercept the target entry according to the newly added interception point.
[0060] In the above embodiment, Figure 3 In the , the target entry interception plug device, monitoring event registration plug device, monitoring event removal plug device, exception monitoring plug device and exception handling plug device are all plug programs, which are implemented once and can be reused. Only when the server framework changes, that is, the execution entry of the server response to the business request changes, only one interception point needs to be added to the target entry interception plug device, and other plug devices do not need any changes. The newly added interception point will intercept the changed target entry.
[0061] In order to improve the efficiency of anomaly detection and quickly locate the anomaly problem, in an optional implementation, the above step S202 includes:
[0062] Step S2021, using the request identifier to identify the monitoring event object;
[0063] Step S2022, adding the monitoring event object to a monitoring queue, where the monitoring queue is a queue for monitoring the execution process of the service request;
[0064] Step S2023: Add multiple abnormality detection timing tasks to the monitoring event object according to the timing strategy. The timing strategy is a strategy for performing timing detection according to the set delay time corresponding to each abnormality detection timing task. The abnormality detection timing tasks are divided into time-type abnormality detection timing tasks and non-time-type abnormality detection timing tasks. The time-type abnormality detection timing tasks are timeout abnormality detection timing tasks. The non-time-type abnormality detection timing tasks at least include thread CPU occupancy excessive abnormality detection timing tasks and memory application excessive abnormality detection timing tasks. The monitoring event object is associated with the abnormality detection timing task through the request identifier.
[0065] In the above embodiment, before executing the service code corresponding to the service request sent by the client, the server will first register a monitoring event for the service request, that is, extract the request information, encapsulate the request information into a monitoring event object, and add an exception detection timer task to the monitoring event object, thus completing the registration. Since the monitoring event must be registered before the service code is executed, it can realize the abnormal detection when there is no request response information such as thread stuck and process crash. The monitoring event registration process is as follows: Figure 5As shown, ① extract or generate a unique id for the business request, that is, the above-mentioned request identifier. The unique id is used to identify the monitoring event object, and the id is unique within the process. ② Extract the service interface name corresponding to the business request. Usually the server will expose many interfaces. In order to facilitate the operation and maintenance personnel to quickly locate the specific abnormal interface, the service interface name corresponding to the business request is specially extracted, which is used to alert the operation and maintenance personnel in case of abnormalities. ③ Extract the full-link monitoring identifier corresponding to the business request, that is, traceId. If the business program is connected to the full-link monitoring, each business request will be accompanied by an identical full-link monitoring identifier when called between different clients and servers. Through the full-link monitoring identifier, the operation and maintenance personnel can quickly query the detailed call status of the business request, and it is easier to locate the problem when an abnormality occurs. Therefore, the present invention specially extracts the full-link monitoring identifier for alerting the operation and maintenance personnel in case of abnormalities. ④ Extract the business attributes corresponding to the business request, support configuration attribute identifiers, such as transaction codes, and attribute identifiers are also used to alert the operation and maintenance personnel in case of abnormalities, which is convenient for quick location of problems. ⑤ Extract the timeout time corresponding to the business request. If the timeout time is not extracted from the business request, the default timeout time is used. The timeout time can be used to calculate the set delay time corresponding to the timeout anomaly detection timer task. ⑥ Package the monitoring event object. A monitoring event object is encapsulated for the business request. The object contains the service interface name, full-link monitoring identifier, business attributes, timeout time and current execution thread corresponding to this request, and the monitoring event object is identified by the request identifier in step ①. ⑦ Put the packaged monitoring event object into the monitoring queue and query it through the request identifier. It should be noted that the monitoring queue does not involve polling, but is only used to temporarily store monitoring event objects. The abnormal monitoring plugging device will take out the monitoring event object from the monitoring queue according to the request identifier id for abnormal detection. If it does not exist in the monitoring queue, it is considered that the request has ended normally and no abnormal detection is performed. ⑧ Add abnormal detection timer tasks for the monitoring event object, specifically, add timeout abnormal detection timer tasks, thread CPU occupancy abnormal detection timer tasks and memory application excessive abnormal detection timer tasks according to the set delay time corresponding to various types of abnormal detection timer tasks. The abnormal detection timer task is associated with the monitoring event object through the request identifier. When an abnormal event occurs, detailed abnormal information can be provided to the operation and maintenance personnel based on these request information to achieve accurate abnormal alarms, so as to facilitate the operation and maintenance personnel to quickly locate and deal with the problem. The abnormal detection scheduled task and the monitoring event object are associated through the abnormal detection manager. It can be simply understood that each abnormal detection scheduled task has a handle; there is an abnormal detection manager on the monitoring event object, and the abnormal detection manager stores the handle of the abnormal detection scheduled task. When the monitoring event object ends normally, the scheduled task is canceled according to the associated scheduled task handle.The request identifier of the monitoring event object is the identifier of the monitoring event object placed in the monitoring queue. According to the identifier, the monitoring event object can be removed from the monitoring queue (including canceling the anomaly detection scheduled task).
[0066] In order to reduce the consumption of thread resources, in an optional implementation manner, after the above step S203, the above method further includes:
[0067] Step S501, when the execution of the business request is completed, the monitoring event object corresponding to the business request is removed from the monitoring queue, and all the abnormality detection scheduled tasks in the monitoring event object are deleted.
[0068] In the above embodiment, after a business request is executed, regardless of whether all the above-mentioned anomaly detection timed tasks do not detect anomalies during anomaly detection, or all the anomaly detection timed tasks have not been executed, or the above-mentioned anomaly detection timed tasks detect anomalies during anomaly detection, as long as the business request is executed, the monitoring event object and the anomaly detection timed task will be removed. Of course, when an anomaly is detected during the anomaly detection process of the anomaly detection timed task, you can also set whether to terminate the business request. If it is not set, the business request will continue to execute, and the anomaly detection will continue until the business request is executed. This is because the anomaly monitoring plug-in device only performs anomaly monitoring and does not perform other operations such as exception handling. After executing the business code corresponding to the business request of the client, the server will remove the monitoring event object and the anomaly detection timed task registered for the business request. After the removal, the anomaly monitoring plug-in device will no longer monitor the monitoring event object for anomalies. The removal process of the monitoring event object is as follows. Figure 6 As shown in the figure, by removing the normal request monitoring event strategy and decoupling the above-mentioned exception monitoring from exception handling, exception monitoring only requires a single thread to monitor the execution exceptions of hundreds or thousands of thread pool threads.
[0069] It should also be noted that when the monitoring event removal plug-in device can be executed, it means that there must be request response information. The above request response information is the information returned to the client after executing the above business request. Because only when the business request is normally executed will it be removed by the monitoring event removal plug-in device, so the abnormal detection of request response information can also be realized. In addition, the monitoring event removal device may be replaced because it is necessary to monitor the abnormalities with request response information, such as the abnormalities captured by the business program. A possible alternative is that after the business request is executed, in addition to removing the registered monitoring events, the results of the request response information will be analyzed, and if there is an abnormality, it will be sent to the abnormality handling device.
[0070] In order to improve the comprehensiveness and accuracy of thread anomaly detection, in an optional implementation, the above step S204 includes:
[0071] Step S2041, using a scheduled task scheduling algorithm to schedule the above-mentioned abnormality detection scheduled tasks in sequence;
[0072] Step S2042, querying the monitoring event object in the monitoring queue according to the request identifier;
[0073] Step S2043, when both the first monitoring condition and the second monitoring condition are satisfied, determining the abnormal event detected in the time-type anomaly detection timing task as the abnormal event, the first monitoring condition being that the monitoring event object exists in the monitoring queue, and the second monitoring condition being that the anomaly detection timing task is the time-type anomaly detection timing task;
[0074] Step S2044, when the first monitoring condition and the third monitoring condition are met at the same time, obtain indicator data and determine whether the indicator data meets the determination rule, the indicator data includes at least one of the following: CPU and memory share, the third monitoring condition is that the anomaly detection scheduled task is the non-time anomaly detection scheduled task;
[0075] Step S2045: When the indicator data satisfies the determination rule, an abnormal event detected in the non-time anomaly detection scheduled task is determined as the abnormal event.
[0076] In the above embodiment, the abnormality detection timed tasks added in the monitoring event registration step are efficiently scheduled and executed based on the time wheel algorithm, such as timeout abnormality detection timed tasks, thread CPU usage excessive abnormality detection timed tasks, thread memory application excessive abnormality detection timed tasks, etc. Figure 7As shown, the specific steps are as follows: Each scheduled task will be attached to a time slot of the time wheel based on its waiting execution time. When the corresponding time slot time arrives, all the uncancelled scheduled tasks attached to the time slot will be executed, and the corresponding exception detection scheduled task will be executed. When each scheduled task is executed, it will first query the monitoring event object from the monitoring queue according to the request id. If it does not exist, it is considered that the request is executed normally, and the scheduled task ends immediately. The scheduling and execution of time-type anomaly detection scheduled tasks such as long thread execution time and thread execution stuck means that an abnormality has occurred. At this time, the abnormal event is directly sent to the abnormal handling plug-in device; non-time-type anomaly detection scheduled tasks such as high thread CPU occupancy and excessive memory application will first obtain indicator data to determine whether it is abnormal. If the indicator data is abnormal, the abnormal event is sent to the abnormal handling plug-in device. In the case that there is no abnormality in the above indicator data, it is determined that the above business request is executed normally without abnormality, and it is only the abnormal monitoring caused by the actual execution time of the business request exceeding the set execution time. Now, for example, a thread CPU occupancy excessive abnormality detection timing task is currently being carried out, and then the indicator data CPU is judged as abnormal. If the CPU does have a problem of excessive occupancy, the excessive CPU occupancy is determined as an abnormal event and sent to the abnormal handling plug-in device; if the CPU occupancy is normal and the business request is still being executed, the CPU occupancy excessive abnormality detection timing task continues to be attached to a time slot of the time wheel to re-execute the thread CPU occupancy excessive abnormality detection timing task. If the business request is completed and the CPU occupancy is still normal, it means that there is no abnormal event in the execution of the business request. If the business request is not completed and the CPU occupancy is abnormal, the CPU occupancy is determined as an abnormal event and sent to the abnormal handling plug-in device. Based on the above, it is possible to realize abnormal detection without request response information such as long thread execution time, thread execution stuck, process crash, etc., instead of only realizing abnormal detection with request response information. It should be noted that the CPU occupancy and memory percentage are collected and calculated by a separate bypass thread, not calculated in real time by the current execution thread of the abnormality detection timing task.
[0077] It should also be noted that, in addition to using the time wheel algorithm to implement scheduled task scheduling in the abnormal monitoring plugging device, other less efficient scheduled task scheduling algorithms or more efficient scheduled task scheduling algorithms can also be used.
[0078] In order to handle the exception in time to avoid causing cascading failures, in an optional implementation, the above step S205 includes:
[0079] Step S2051, extracting the request information in the monitoring event object corresponding to the abnormal event;
[0080] Step S2052, determining the corresponding service request according to the request information, and determining the service request as an abnormal request;
[0081] Step S2053, issuing an alarm message according to the request message;
[0082] Step S2054, print the stack space of the thread executing the above exception request, and terminate the execution of the above exception request.
[0083] In the above embodiment, Figure 3 The exception handling plug device in the embodiment is used to receive and process abnormal events. The flowchart of the abnormal handling is as follows: Figure 8 As shown, the abnormal detection timer task is associated with the monitoring event object through the request identifier, and the monitoring event object is associated with the business request through the request identifier. When the abnormal detection timer task detects an abnormal event, the request information in the monitoring event object corresponding to the abnormal event is extracted to determine which business request is abnormal according to the request information, and the business request is determined as an abnormal request. Supported processing methods include: printing the execution stack of the abnormal thread; realizing accurate alarm of abnormalities based on the request information extracted by the monitoring event registration plug-in device, and the alarm method can be SMS, phone, email or combination; for stuck or high CPU, high memory abnormalities, support terminating the execution of the current request task of the abnormal thread, which is used to release the thread, CPU, and memory resources in time to avoid cascading failures, such as insufficient available thread resources in the thread pool, the request cannot be responded to in time, resulting in a large number of request timeouts, insufficient memory resources, and the process crashes and cannot respond to requests. Print the stack space of the execution thread of the above-mentioned abnormal request, and print the stack space of the execution thread of the above-mentioned abnormal request. Accurate detection is achieved by informing the server interface, the full-link monitoring ID and the abnormal stack space.
[0084] It should also be noted that the monitoring event registration plug-in device and the exception monitoring plug-in device are both single application dimensions. A unified and centralized monitoring event registration center and a distributed timed task scheduling solution can be used to implement monitoring of abnormal events and abnormal handling. Although additional components are added, the separation of abnormal detection from business programs reduces the loss of business program performance and the risk of problems that may be caused by the abnormal detection plug-in program. Therefore, in this scenario, the abnormal handling plug-in device can be removed.
[0085] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0086] The embodiment of the present application also provides a thread exception detection device. It should be noted that the thread exception detection device of the embodiment of the present application can be used to execute the thread exception detection method provided by the embodiment of the present application. The device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware for a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.
[0087] The following is an introduction to the thread anomaly detection device provided in an embodiment of the present application.
[0088] Fig. 9 is a structural block diagram of a thread anomaly detection device according to an embodiment of the present application. Fig. 9 As shown, the device comprises:
[0089] The receiving unit 10 is used to receive a service request sent by a client.
[0090] Specifically, Figure 3 FIG. 4 shows a structural framework diagram of a thread anomaly detection system provided according to an embodiment of the present application, such as Figure 3 As shown, the thread exception detection system includes a request receiving device, a monitoring event registration plugging device, a business request execution device, a target entry interception plugging device, an abnormal monitoring plugging device, an abnormal handling plugging device and a monitoring event removal plugging device. The request receiving device is used to receive the business request sent by the client. The request receiving device is the original business code and does not require any modification.
[0091] The encapsulation unit 20 is used to extract the request information corresponding to the above-mentioned business request, and encapsulate the above-mentioned request information into a monitoring event object corresponding to the above-mentioned business request, and add an abnormality detection timing task to the above-mentioned monitoring event object. The above-mentioned request information at least includes the server interface, request identifier and current execution thread to which the above-mentioned business request belongs. One of the above-mentioned business request corresponds to one of the above-mentioned monitoring event object, and one of the above-mentioned monitoring event object corresponds to multiple of the above-mentioned abnormality detection timing tasks. Each of the above-mentioned abnormality detection timing tasks corresponds to one or more of the above-mentioned set delay times. The above-mentioned set delay time is the time for delaying the execution of the corresponding above-mentioned abnormality detection timing task.
[0092] Specifically, Figure 3The monitoring event registration plug-in device in is used to execute the above step S202. The monitoring event registration plug-in device will register an abnormal monitoring event for each business request, that is, by extracting the service interface, request identifier, and current execution thread and other request information to which the business request belongs, and encapsulating these request information into a monitoring event object, and adding an abnormal detection timer task to the monitoring event object for abnormal monitoring. When an abnormal event occurs, detailed abnormal information can be provided to the operation and maintenance personnel based on these request information to achieve accurate abnormal alarms, thereby facilitating the operation and maintenance personnel to quickly locate and deal with problems. Among them, each of the above-mentioned abnormal detection timer tasks corresponds to one or more of the above-mentioned set delay times. For example, for the timeout abnormal detection timer task, a set delay time corresponds to the timer task, which is executed for 30 seconds each time. For the CPU occupancy is too high abnormal detection timer task, a set delay time also corresponds to the timer task, which is executed for 20 seconds each time. For the excessive memory application abnormal detection timer task, there are multiple set delay times. The first time is executed for 15 seconds, and then only 3 seconds each time. The specific set delay time can be set according to the actual situation.
[0093] The execution unit 30 is used to execute the above-mentioned business request. When the execution request time reaches the above-mentioned set delay time corresponding to any one of the above-mentioned exception detection timing tasks, the corresponding above-mentioned exception detection timing task is executed to perform anomaly detection on the above-mentioned monitoring event object to obtain the abnormal event of the above-mentioned monitoring event object. The above-mentioned execution request time is the current actual execution time of the above-mentioned business request, and the above-mentioned abnormal event is an event in which an abnormality is detected when executing the above-mentioned exception detection timing task.
[0094] Specifically, Figure 3 The service request execution device in is used to respond to the service request of the client and execute the corresponding service program. The above service request execution device is the original service code and does not need any modification. Figure 3 The abnormal monitoring instrumentation device in performs abnormal detection based on the registered and unremoved monitoring events, and efficiently implements abnormal detection through the time wheel algorithm and a single monitoring thread. The time wheel algorithm implements the scheduling of abnormal detection timed tasks, such as timed abnormal detection timed tasks, thread CPU occupancy excessive abnormal detection timed tasks, and excessive memory application abnormal detection timed tasks. It should be noted that the data statistics of CPU occupancy and memory application are thread-dimensional. The timed abnormal detection timed task can detect long thread execution time and thread execution stuck, but it is not limited to the above two types; a single monitoring thread is used to obtain valid scheduled tasks from the time wheel in chronological order and execute them. When it is determined that an abnormal event occurs, the abnormal event is sent to the abnormal handling instrumentation device. The abnormal monitoring instrumentation device only performs abnormal monitoring, and does not perform abnormal handling, to avoid the abnormal handling time being too long, resulting in the subsequent scheduled tasks not being able to be executed in time. This "monitoring-handling" decoupling method is used to efficiently implement abnormal detection.
[0095] The processing unit 40 is used to process the above abnormal events.
[0096] Specifically, Figure 3 The exception handling plug device receives the exception event sent by the exception monitoring plug device for processing.
[0097] It should also be noted that the exception handling plug-in device can also be removed, but the handling function of the exception handling plug-in device needs to be integrated into the exception monitoring plug-in device, and then the number of threads in the exception monitoring plug-in device can be increased from 1 to multiple.
[0098] In this embodiment, a receiving unit is used to receive a business request sent by a client; an encapsulation unit is used to extract request information corresponding to the business request, and encapsulate the request information into a monitoring event object corresponding to the business request, and add an abnormality detection timing task to the monitoring event object, wherein the request information at least includes a server interface, a request identifier and a current execution thread to which the business request belongs, one business request corresponds to one monitoring event object, and one monitoring event object corresponds to multiple abnormality detection timing tasks. The set delay time is the time for delaying the execution of the corresponding abnormality detection timing task, and each abnormality detection timing task corresponds to one or more set delay times; an execution unit is used to execute the business request, and when the execution request time reaches the set delay time corresponding to any one of the abnormality detection timing tasks, the corresponding abnormality detection timing task is executed to perform abnormality detection on the monitoring event object, and obtain an abnormal event of the monitoring event object, wherein the abnormal event is an event in which an abnormality is detected when executing the abnormality detection timing task; a processing unit is used to process the abnormal event. This application achieves accurate detection of anomalies by encapsulating the business request and adding an anomaly detection timer task before the server executes the business request. After the server executes the business request, the anomaly detection timer task is executed on the abnormal request to detect the anomaly. Among them, in addition to detecting execution anomalies with request response information, the anomaly detection timer task can also detect execution anomalies without request response information, such as long thread execution time, thread stuck, excessive memory application leading to process crash. Based on the timed polling algorithm and a single independent thread, accurate detection of execution anomalies of hundreds or thousands of threads in the server thread pool can be efficiently achieved. This application solves the problem in the prior art that execution anomalies cannot be accurately detected when the server thread pool thread responds to business requests.
[0099] In order to enhance the business program capability to achieve lightweight, non-intrusive and accurate detection capability of thread execution exceptions, in an optional implementation, the above-mentioned device further includes:
[0100] A query unit, configured to determine the current server framework after receiving the service request sent by the client, and query the corresponding framework source code according to the current server framework to obtain a target entry, wherein the target entry is an execution start entry for executing the service request under the current server framework;
[0101] An interception unit, used to intercept the target entrance at an interception point by using a plugging technique, wherein the interception point is a position where the target entrance is intercepted;
[0102] A first injection unit, used for injecting a first plug-in code before the target entry, wherein the first plug-in code is used for encapsulating a corresponding monitoring event object for the business request before executing the business request, and adding the anomaly detection timer task;
[0103] The second injection unit is used to inject a second plug-in code after the above-mentioned target entry, and the above-mentioned second plug-in code is used to remove the above-mentioned monitoring event object corresponding to the above-mentioned business request after executing the above-mentioned business request, and remove the above-mentioned abnormality detection timing task.
[0104] In the above embodiment, the target entry interception flow chart is as follows: Figure 4 As shown in the figure, determine the framework used by the server, find the execution start entry (usually a fixed function) of the business request execution from the framework source code, mark the execution start entry as the target entry (that is, the location of the interception point), and use the stub technology to intercept the target entry when the business program starts, and dynamically Figure 3 The code corresponding to the monitoring event registration plug-in device in the program is injected before the target entry, and the code corresponding to the monitoring event removal plug-in device is injected after the target entry. After the code is injected, the monitoring event registration plug-in device will be executed before the original business code executes the business request, and the monitoring event removal plug-in device will be executed after the original business code executes the business request. The above embodiment belongs to the plug-in program function, which is independent of the business program. By dynamically injecting code, the business program capability is enhanced to achieve lightweight, non-invasive thread execution exception accurate detection capability. In extreme cases, when the business program does not use any server-side framework, the program source code of the above business program is directly queried, and an interception point is added to the unified start entry of the business request execution corresponding to the above business program.
[0105] In order to improve the maintainability and reusability of the code, in an optional implementation manner, the above device further includes:
[0106] A new unit is used to add a new interception point after receiving a business request sent by a client, in the case that the current server framework changes, so as to intercept the target entry according to the newly added interception point.
[0107] In the above embodiment, Figure 3 In the , the target entry interception plug device, monitoring event registration plug device, monitoring event removal plug device, exception monitoring plug device and exception handling plug device are all plug programs, which are implemented once and can be reused. Only when the server framework changes, that is, the execution entry of the server response to the business request changes, only one interception point needs to be added to the target entry interception plug device, and other plug devices do not need any changes. The newly added interception point will intercept the changed target entry.
[0108] In order to improve the efficiency of anomaly detection and quickly locate the anomaly problem, in an optional implementation, the encapsulation unit includes:
[0109] An identification unit, used to identify the monitoring event object using the request identification;
[0110] A queue adding unit, used to add the monitoring event object to a monitoring queue, where the monitoring queue is a queue for monitoring the execution process of the business request;
[0111] Add a task unit, which is used to add multiple anomaly detection timing tasks to the above-mentioned monitoring event object according to the timing strategy. The above-mentioned timing strategy is a strategy for performing timing detection according to the above-mentioned set delay time corresponding to each of the above-mentioned anomaly detection timing tasks. The above-mentioned anomaly detection timing tasks are divided into time-type anomaly detection timing tasks and non-time-type anomaly detection timing tasks. The above-mentioned time-type anomaly detection timing tasks are timeout anomaly detection timing tasks. The above-mentioned non-time-type anomaly detection timing tasks at least include thread CPU occupancy excessive anomaly detection timing tasks and memory application excessive anomaly detection timing tasks. The above-mentioned monitoring event object and the above-mentioned anomaly detection timing tasks are associated through the above-mentioned request identifier.
[0112] In the above embodiment, before executing the service code corresponding to the service request sent by the client, the server will first register a monitoring event for the service request, that is, extract the request information, encapsulate the request information into a monitoring event object, and add an exception detection timer task to the monitoring event object, thus completing the registration. Since the monitoring event must be registered before the service code is executed, it can realize the abnormal detection when there is no request response information such as thread stuck and process crash. The monitoring event registration process is as follows: Figure 5As shown, ① extract or generate a unique id for the business request, that is, the above-mentioned request identifier. The unique id is used to identify the monitoring event object, and the id is unique within the process. ② Extract the service interface name corresponding to the business request. Usually the server exposes many interfaces. In order to facilitate the operation and maintenance personnel to quickly locate the specific abnormal interface, the service interface name corresponding to the business request is specially extracted, which is used to alert the operation and maintenance personnel in case of abnormalities. ③ Extract the full-link monitoring identifier corresponding to the business request, that is, traceId. If the business program is connected to the full-link monitoring, each business request will be accompanied by an identical full-link monitoring identifier when called between different clients and servers. Through the full-link monitoring identifier, the operation and maintenance personnel can quickly query the detailed call status of the business request, and it is easier to locate the problem when an abnormality occurs. Therefore, the present invention specially extracts the full-link monitoring identifier for alerting the operation and maintenance personnel in case of abnormalities. ④ Extract the business attributes corresponding to the business request, support configuration attribute identifiers, such as transaction codes, and attribute identifiers are also used to alert the operation and maintenance personnel in case of abnormalities, which is convenient for quick location of problems. Package the monitoring event object. ⑤ Extract the timeout time corresponding to the business request. If the timeout time is not extracted from the business request, the default timeout time is used. The timeout time can be used to calculate the set delay time corresponding to the timeout anomaly detection timer task. ⑥ Encapsulate a monitoring event object for the business request, which contains the service interface name, full-link monitoring identifier, business attributes, timeout time and current execution thread corresponding to this request, and use the request identifier in step ① to identify the monitoring event object. ⑦ Put the packaged monitoring event object into the monitoring queue and query it through the request id. It should be noted that the monitoring queue does not involve polling, but is only used to temporarily store monitoring event objects. The abnormal monitoring plugging device will take out the monitoring event object from the monitoring queue according to the request id for abnormal detection. If it does not exist in the monitoring queue, it is considered that the request has ended normally and no abnormal detection is performed. ⑧ Add an abnormal detection timer task for the monitoring event object, specifically, add a timeout abnormal detection timer task, a thread CPU occupancy abnormal detection timer task, and a memory application excessive abnormal detection timer task according to the set delay time corresponding to various types of abnormal detection timer tasks. The abnormal detection timer task is associated with the monitoring event object through the request identifier id. When an abnormal event occurs, detailed abnormal information can be provided to the operation and maintenance personnel based on these request information to achieve accurate abnormal alarms, so as to facilitate the operation and maintenance personnel to quickly locate and deal with the problem. The abnormal detection scheduled task and the monitoring event object are associated through the abnormal detection manager. It can be simply understood that each abnormal detection scheduled task has a handle; there is an abnormal detection manager on the monitoring event object, and the abnormal detection manager stores the handle of the abnormal detection scheduled task. When the monitoring event object ends normally, the scheduled task is canceled according to the associated scheduled task handle.The request identifier of the monitoring event object is the identifier of the monitoring event object placed in the monitoring queue. According to this identifier, the monitoring event object can be removed from the monitoring queue (including canceling the anomaly detection scheduled task). It should be noted that the CPU usage and memory usage are collected and calculated by a separate bypass thread, not calculated in real time by the execution thread of the anomaly detection scheduled task.
[0113] In order to reduce the consumption of thread resources, in an optional implementation manner, the above device further includes:
[0114] A removing unit is used to remove the monitoring event object corresponding to the business request from the monitoring queue and delete all the anomaly detection scheduled tasks in the monitoring event object after executing the business request and when the execution of the business request is completed.
[0115] In the above embodiment, after a business request is executed, regardless of whether all the above-mentioned anomaly detection timed tasks do not detect anomalies during anomaly detection, or all the anomaly detection timed tasks have not been executed, or the above-mentioned anomaly detection timed tasks detect anomalies during anomaly detection, as long as the business request is executed, the monitoring event object and the anomaly detection timed task will be removed. Of course, when an anomaly is detected during the anomaly detection process of the anomaly detection timed task, you can also set whether to terminate the business request. If it is not set, the business request will continue to execute, and the anomaly detection will continue until the business request is executed. This is because the anomaly monitoring plug-in device only performs anomaly monitoring and does not perform other operations such as exception handling. After executing the business code corresponding to the business request of the client, the server will remove the monitoring event object and the anomaly detection timed task registered for the business request. After the removal, the anomaly monitoring plug-in device will no longer monitor the monitoring event object for anomalies. The removal process of the monitoring event object is as follows. Figure 6 As shown in the figure, by removing the normal request monitoring event strategy and decoupling the above-mentioned exception monitoring from exception handling, exception monitoring only requires a single thread to monitor the execution exceptions of hundreds or thousands of thread pool threads.
[0116] It should also be noted that when the monitoring event removal plug-in device can be executed, it means that there must be request response information. The above request response information is the information returned to the client after executing the above business request. Because only when the business request is normally executed will it be removed by the monitoring event removal plug-in device, so the abnormal detection of request response information can also be realized. In addition, the monitoring event removal device may be replaced because it is necessary to monitor the abnormalities with request response information, such as the abnormalities captured by the business program. A possible alternative is that after the business request is executed, in addition to removing the registered monitoring events, the results of the request response information will be analyzed, and if there is an abnormality, it will be sent to the abnormality handling device.
[0117] In order to improve the comprehensiveness and accuracy of thread anomaly detection, in an optional implementation, the detection unit includes:
[0118] A scheduling module, used to schedule the above-mentioned anomaly detection scheduled tasks in sequence using a scheduled task scheduling algorithm;
[0119] A first query module, used for querying the monitoring event object in the monitoring queue according to the request identifier;
[0120] A first determination module is used to determine an abnormal event detected in the above-mentioned time-type anomaly detection timing task as the above-mentioned abnormal event when a first monitoring condition and a second monitoring condition are met at the same time, the above-mentioned first monitoring condition is that the above-mentioned monitoring event object exists in the above-mentioned monitoring queue, and the above-mentioned second monitoring condition is that the above-mentioned anomaly detection timing task is the above-mentioned time-type anomaly detection timing task;
[0121] A judgment module is used to obtain indicator data and judge whether the indicator data satisfies the judgment rule when the first monitoring condition and the third monitoring condition are met at the same time, wherein the indicator data includes at least one of the following: CPU and memory share, and the third monitoring condition is that the anomaly detection scheduled task is the non-time anomaly detection scheduled task;
[0122] The second determination module determines the abnormal event detected in the non-time anomaly detection scheduled task as the abnormal event when the indicator data satisfies the determination rule.
[0123] In the above embodiment, the abnormality detection timed tasks added in the monitoring event registration step are efficiently scheduled and executed based on the time wheel algorithm, such as timeout abnormality detection timed tasks, thread CPU usage excessive abnormality detection timed tasks, thread memory application excessive abnormality detection timed tasks, etc. Figure 7As shown, the specific steps are as follows: Each scheduled task will be attached to a time slot of the time wheel based on its waiting execution time. When the corresponding time slot time arrives, all the uncancelled scheduled tasks attached to the time slot will be executed, and the corresponding exception detection scheduled task will be executed. When each scheduled task is executed, it will first query the monitoring event object from the monitoring queue according to the request id. If it does not exist, it is considered that the request is executed normally, and the scheduled task ends immediately. The scheduling and execution of time-type anomaly detection scheduled tasks such as long thread execution time and thread execution stuck means that an abnormality has occurred. At this time, the abnormal event is directly sent to the abnormal handling plug-in device; non-time-type anomaly detection scheduled tasks such as high thread CPU occupancy and excessive memory application will first obtain indicator data to determine whether it is abnormal. If the indicator data is abnormal, the abnormal event is sent to the abnormal handling plug-in device. In the case that there is no abnormality in the above indicator data, it is determined that the above business request is executed normally without abnormality, and it is only the abnormal monitoring caused by the actual execution time of the business request exceeding the set execution time. Now, for example, a thread CPU occupancy excessive abnormality detection timing task is currently being carried out, and then the indicator data CPU is judged as abnormal. If the CPU does have a problem of excessive occupancy, the excessive CPU occupancy is determined as an abnormal event and sent to the abnormal handling plug-in device; if the CPU occupancy is normal and the business request is still being executed, the CPU occupancy excessive abnormality detection timing task continues to be attached to a time slot of the time wheel to re-execute the thread CPU occupancy excessive abnormality detection timing task. If the business request is completed and the CPU occupancy is still normal, it means that there is no abnormal event in the execution of the business request. If the business request is not completed and the CPU occupancy is abnormal, the CPU occupancy is determined as an abnormal event and sent to the abnormal handling plug-in device. Based on the above, it is possible to realize abnormal detection without request response information such as long thread execution time, thread execution stuck, process crash, etc., instead of only realizing abnormal detection with request response information. It should be noted that the CPU occupancy and memory percentage are collected and calculated by a separate bypass thread, not calculated in real time by the current execution thread of the abnormality detection timing task.
[0124] It should also be noted that, in addition to using the time wheel algorithm to implement scheduled task scheduling in the abnormal monitoring plugging device, other less efficient scheduled task scheduling algorithms or more efficient scheduled task scheduling algorithms can also be used.
[0125] In order to handle the exception in time to avoid cascading failures, in an optional implementation, the processing unit includes:
[0126] An extraction module extracts the request information in the monitoring event object corresponding to the abnormal event;
[0127] A second query module determines the corresponding service request according to the request information, and determines the service request as an abnormal request;
[0128] The issuing module issues an alarm message according to the above request information;
[0129] The execution module is terminated, the stack space of the execution thread of the above exception request is printed, and the execution of the above exception request is terminated.
[0130] In the above embodiment, Figure 3 The exception handling plug device in the embodiment is used to receive and process abnormal events. The flowchart of the abnormal handling is as follows: Figure 8 As shown, the abnormal detection timer task is associated with the monitoring event object through the request identifier, and the monitoring event object is associated with the business request through the request identifier. When the abnormal detection timer task detects an abnormal event, the request information in the monitoring event object corresponding to the abnormal event is extracted to determine which business request is abnormal according to the request information, and the business request is determined as an abnormal request. Supported processing methods include: printing the execution stack of the abnormal thread; realizing accurate alarm of abnormalities based on the request information extracted by the monitoring event registration plug-in device, and the alarm method can be SMS, phone, email or combination; for stuck or high CPU, high memory abnormalities, support terminating the execution of the current request task of the abnormal thread, which is used to release the thread, CPU, and memory resources in time to avoid cascading failures, such as insufficient available thread resources in the thread pool, the request cannot be responded to in time, resulting in a large number of request timeouts, insufficient memory resources, and the process crashes and cannot respond to requests. Print the stack space of the execution thread of the above-mentioned abnormal request, and print the stack space of the execution thread of the above-mentioned abnormal request. Accurate detection is achieved by informing the server interface, the full-link monitoring ID and the abnormal stack space.
[0131] It should also be noted that the monitoring event registration plug-in device and the exception monitoring plug-in device are both single application dimensions. A unified and centralized monitoring event registration center and a distributed timed task scheduling solution can be used to implement monitoring of abnormal events and abnormal handling. Although additional components are added, the separation of abnormal detection from business programs reduces the loss of business program performance and the risk of problems that may be caused by the abnormal detection plug-in program. Therefore, in this scenario, the abnormal handling plug-in device can be removed.
[0132] The thread anomaly detection device includes a processor and a memory. The receiving unit, encapsulation unit, and execution unit are all stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions. The modules are all located in the same processor; or, the modules are located in different processors in any combination.
[0133] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the problem that the execution exception of the server thread pool thread in response to the service request cannot be accurately detected in the prior art is solved by adjusting the kernel parameters.
[0134] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0135] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the thread exception detection method.
[0136] An embodiment of the present invention provides a processor, which is used to run a program, wherein the thread exception detection method is executed when the program is running.
[0137] An embodiment of the present invention provides a thread anomaly detection system, the thread anomaly detection system comprising a processor, a memory, and a program stored in the memory and executable on the processor, and when the processor executes the program, at least the following steps are implemented:
[0138] Step S201, receiving a service request sent by a client;
[0139] Step S202, extract the request information corresponding to the above-mentioned business request, and encapsulate the above-mentioned request information into a monitoring event object corresponding to the above-mentioned business request, and add an abnormality detection timer task to the above-mentioned monitoring event object, wherein the above-mentioned request information at least includes the server interface, request identifier and current execution thread to which the above-mentioned business request belongs, one above-mentioned business request corresponds to one above-mentioned monitoring event object, one above-mentioned monitoring event object corresponds to multiple above-mentioned abnormality detection timer tasks, each above-mentioned abnormality detection timer task corresponds to one or more set delay times, and the above-mentioned set delay time is the time for delaying the execution of the corresponding above-mentioned abnormality detection timer task;
[0140] Step S203, executing the above-mentioned business request. When the execution request time reaches the above-mentioned set delay time corresponding to any of the above-mentioned abnormality detection timing tasks, the corresponding above-mentioned abnormality detection timing task is executed to perform abnormality detection on the above-mentioned monitoring event object to obtain the abnormal event of the above-mentioned monitoring event object. The above-mentioned execution request time is the current actual execution time of the above-mentioned business request. The above-mentioned abnormal event is an event in which an abnormality is detected when executing the above-mentioned abnormality detection timing task;
[0141] Step S204, processing the above abnormal event.
[0142] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing at least the following method steps:
[0143] Step S201, receiving a service request sent by a client;
[0144] Step S202, extract the request information corresponding to the above-mentioned business request, and encapsulate the above-mentioned request information into a monitoring event object corresponding to the above-mentioned business request, and add an abnormality detection timer task to the above-mentioned monitoring event object, wherein the above-mentioned request information at least includes the server interface, request identifier and current execution thread to which the above-mentioned business request belongs, one above-mentioned business request corresponds to one above-mentioned monitoring event object, one above-mentioned monitoring event object corresponds to multiple above-mentioned abnormality detection timer tasks, each above-mentioned abnormality detection timer task corresponds to one or more set delay times, and the above-mentioned set delay time is the time for delaying the execution of the corresponding above-mentioned abnormality detection timer task;
[0145] Step S203, executing the above-mentioned business request. When the execution request time reaches the above-mentioned set delay time corresponding to any of the above-mentioned abnormality detection timing tasks, the corresponding above-mentioned abnormality detection timing task is executed to perform abnormality detection on the above-mentioned monitoring event object to obtain the abnormal event of the above-mentioned monitoring event object. The above-mentioned execution request time is the current actual execution time of the above-mentioned business request. The above-mentioned abnormal event is an event in which an abnormality is detected when executing the above-mentioned abnormality detection timing task;
[0146] Step S204, processing the above abnormal event.
[0147] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0148] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0149] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes 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.
[0150] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0151] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0152] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0153] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0154] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0155] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0156] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0157] 1) The thread exception detection method of the present application encapsulates the business request and adds an exception detection timer task before the service request is executed on the server side. After the service request is executed on the server side, the exception detection timer task is executed on the exception request to detect the exception, thereby realizing the accurate detection function of the exception. Among them, in addition to detecting execution exceptions with request response information, the exception detection timer task can also detect execution exceptions without request response information, such as long thread execution time, thread stuck, excessive memory application leading to process crash. Based on the timed polling algorithm and a single independent thread, the accurate detection of execution exceptions of hundreds or thousands of threads in the server thread pool can be efficiently realized. The present application solves the problem in the prior art that execution exceptions cannot be accurately detected when the server thread pool thread responds to a service request.
[0158] 2) The thread exception detection device of the present application encapsulates the business request and adds an exception detection timer task before the service request is executed on the server side. After the service request is executed on the server side, the exception detection timer task is executed on the exception request to detect the exception, thereby realizing the accurate detection function of the exception. Among them, in addition to detecting the execution exception with request response information, the exception detection timer task can also detect the execution exception without request response information, such as long thread execution time, thread stuck, excessive memory application leading to process crash. Based on the timed polling algorithm and a single independent thread, the accurate detection of the execution exception of hundreds or thousands of threads in the server thread pool can be efficiently realized. The present application solves the problem in the prior art that the execution exception of the server thread pool thread cannot be accurately detected when responding to a service request.
[0159] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A thread anomaly detection method, It is characterized in that include: Receive business requests sent by clients; Extract the request information corresponding to the business request, encapsulate the request information into a monitoring event object corresponding to the business request, and add an abnormality detection timer task to the monitoring event object, wherein the request information at least includes the server interface, request identifier and current execution thread to which the business request belongs, one business request corresponds to one monitoring event object, one monitoring event object corresponds to multiple abnormality detection timer tasks, each abnormality detection timer task corresponds to one or more set delay times, and the set delay time is the time for delaying the execution of the corresponding abnormality detection timer task; Execute the business request, and when the execution request time reaches the set delay time corresponding to any one of the anomaly detection timing tasks, execute the corresponding anomaly detection timing task to perform anomaly detection on the monitoring event object to obtain an abnormal event of the monitoring event object, the execution request time is the actual execution time of the business request, and the abnormal event is an event in which an abnormality is detected when executing the anomaly detection timing task; The abnormal event is processed.
2. The method according to claim 1, It is characterized in that After receiving the service request sent by the client, the method further includes: Determine the current server framework, and query the corresponding framework source code according to the current server framework to obtain a target entry, where the target entry is an execution start entry for executing the service request under the current server framework; Using the insertion technique to intercept the target entrance at the interception point, where the interception point is the position where the target entrance is intercepted; Injecting a first plug-in code before the target entry, wherein the first plug-in code is used to encapsulate a corresponding monitoring event object for the business request before executing the business request, and to add the anomaly detection timing task; After the target entry, a second plug-in code is injected, where the second plug-in code is used to remove the monitoring event object corresponding to the business request and the anomaly detection timing task after executing the business request.
3. The method according to claim 2, It is characterized in that After receiving the service request sent by the client, the method further includes: In the case where the current server framework changes, a new interception point is added to intercept the target entry according to the newly added interception point.
4. The method according to claim 1, It is characterized in that Adding anomaly detection timer tasks to the monitoring event object includes: Using the request identifier to identify the monitoring event object; Adding the monitoring event object to a monitoring queue, where the monitoring queue is a queue for monitoring the execution process of the service request; According to the timing strategy, multiple types of anomaly detection timing tasks are added to the monitoring event object. The timing strategy is a strategy for performing timing detection according to the set delay time corresponding to each anomaly detection timing task. The anomaly detection timing tasks are divided into time-type anomaly detection timing tasks and non-time-type anomaly detection timing tasks. The time-type anomaly detection timing tasks are timeout anomaly detection timing tasks, and the non-time-type anomaly detection timing tasks include at least thread CPU occupancy excessive anomaly detection timing tasks and memory application excessive anomaly detection timing tasks. The monitoring event object is associated with the anomaly detection timing task through the request identifier.
5. The method according to claim 4, It is characterized in that After executing the service request to execute the corresponding abnormality detection timing task, the method further includes: When the execution of the service request is completed, the monitoring event object corresponding to the service request is removed from the monitoring queue, and all the abnormality detection scheduled tasks in the monitoring event object are deleted.
6. The method according to claim 4, It is characterized in that Executing the corresponding anomaly detection scheduled task to perform anomaly detection on the monitoring event object to obtain an abnormal event of the monitoring event object includes: Schedule the anomaly detection scheduled tasks in sequence and on a regular basis using a scheduled task scheduling algorithm; Querying the monitoring event object in the monitoring queue according to the request identifier; When the first monitoring condition and the second monitoring condition are met at the same time, an abnormal event detected in the time-type anomaly detection timing task is determined as the abnormal event, the first monitoring condition is that the monitoring event object exists in the monitoring queue, and the second monitoring condition is that the anomaly detection timing task is the time-type anomaly detection timing task; When the first monitoring condition and the third monitoring condition are met at the same time, obtain indicator data and determine whether the indicator data meets the determination rule, the indicator data includes at least one of the following: CPU and memory share, and the third monitoring condition is that the anomaly detection scheduled task is the non-time anomaly detection scheduled task; When the indicator data satisfies the determination rule, an abnormal event detected in the non-time anomaly detection scheduled task is determined as the abnormal event.
7. The method according to claim 1, It is characterized in that Processing the abnormal event includes: Extracting the request information in the monitoring event object corresponding to the abnormal event; Determine the corresponding service request according to the request information, and determine the service request as an abnormal request; Sending warning information according to the request information; The stack space of the thread executing the exception request is printed, and the execution of the exception request is terminated.
8. A thread anomaly detection device, It is characterized in that The device comprises: A receiving unit, used for receiving a service request sent by a client; An encapsulation unit is used to extract the request information corresponding to the business request, encapsulate the request information into a monitoring event object corresponding to the business request, and add an abnormality detection timer task to the monitoring event object, wherein the request information at least includes the server interface, request identifier and current execution thread to which the business request belongs, one business request corresponds to one monitoring event object, one monitoring event object corresponds to multiple abnormality detection timer tasks, each abnormality detection timer task corresponds to one or more set delay times, and the set delay time is the time for delaying the execution of the corresponding abnormality detection timer task; An execution unit is used to execute the service request, and when the execution request time reaches the set delay time corresponding to any one of the anomaly detection timing tasks, execute the corresponding anomaly detection timing task to perform anomaly detection on the monitoring event object, and obtain an abnormal event of the monitoring event object, wherein the execution request time is the actual execution time of the service request, and the abnormal event is an event in which an abnormality is detected when executing the anomaly detection timing task; A processing unit is used to process the abnormal event.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the method according to any one of claims 1 to 7.
10. A computer program product comprising computer instructions, It is characterized in that When the computer instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
