An exception handling method based on MCP

By combining multi-objective constraint optimization and reinforcement learning with multivariate Gaussian distribution, partial differential equations and Bayesian localization, the passive response and insufficient localization accuracy of traditional MCP tools in anomaly handling are solved, thereby improving the anomaly handling efficiency and system recovery capability of distributed microservice systems.

CN123114805APending Publication Date: 2026-11-17CHINA UNITED NETWORK COMM GRP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611044798.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-14
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Traditional MCP tools lack proactive response capabilities in anomaly handling, resulting in low location accuracy and long response latency. Furthermore, existing methods have poor adaptability to distributed microservice architectures, making it difficult to achieve highly reliable and low-latency system management.

Method used

By acquiring the running status data of microservice nodes, a Markov decision process model is constructed using a multi-objective constraint optimization model and reinforcement learning. Combined with multivariate Gaussian distribution anomaly detection and partial differential equation prediction of anomaly propagation, the anomaly source is determined based on Bayesian localization, and a fault-tolerant repair model is constructed to optimize resource allocation.

Benefits of technology

It achieves proactive, accurate, and timely exception handling in a distributed microservice architecture, reducing exception recovery cycle and operation and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114805A_ABST
    Figure CN123114805A_ABST
Patent Text Reader

Abstract

This invention discloses an anomaly handling method based on Multi-Objective Calculation (MCP), belonging to the field of distributed microservice anomaly handling technology. The method includes: acquiring standardized runtime status and task requirement data; generating a dynamically adaptable MCP call planning scheme through multi-objective optimization and reinforcement learning; executing the scheme and detecting anomalies based on a multivariate Gaussian distribution; constructing partial differential equations to predict the spread trend using anomaly nodes as initial conditions; accurately identifying the anomaly source by combining Bayesian localization; constructing a fault-tolerant repair model and solving for the optimal repair scheme using gradient descent; and finally updating the model parameters through closed-loop learning. This invention can proactively predict anomaly spread, accurately locate anomaly sources, and achieve continuous adaptive optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of distributed microservice exception handling technology, and in particular to an exception handling method based on MCP. Background Technology

[0002] In the context of the digital economy, distributed microservice systems have become the core architecture supporting complex businesses, with increasingly prominent demands for dynamic resource scheduling, multi-task collaboration, and cross-node interaction. As a core component of the intelligent agent platform, the Model Context Protocol (MCP) is responsible for the orchestration and process control of computing power, interfaces, and node resources in the distributed microservice system, and its exception handling capabilities directly affect the system's operational stability and business continuity.

[0003] However, traditional MCP tools often employ passive response mechanisms for anomaly handling, relying on static thresholds to trigger alarms. They lack the ability to predict and proactively intervene in typical system anomalies such as node failures, interface call failures, and resource overload. This reactive approach results in low anomaly localization accuracy, long response delays, and system recovery cycles that often far exceed the rapid self-healing reliability requirements of core businesses in a distributed environment, severely restricting high business availability.

[0004] Furthermore, existing planning methods are poorly adapted to distributed microservice architectures, and anomaly handling results are not effectively fed back to the model training stage. Although advanced technologies such as reinforcement learning have been attempted to be introduced into this field, in practical applications with multiple constraints such as computing power constraints, latency constraints, and dynamic resource fluctuations, problems such as weak dynamic adaptability to the environment, high training resource requirements, and difficulty in lightweight deployment still exist. This limits the system's ability to autonomously evolve and continuously optimize in dynamic environments such as task priority adjustments and changes in microservice running states.

[0005] Therefore, there is an urgent need for an MCP anomaly handling method that deeply integrates distributed microservice architecture and has intelligent anomaly prediction and proactive repair capabilities, in order to improve the robustness and anomaly response efficiency of the system under multiple constraints and meet the system management requirements of high reliability and low latency in complex business scenarios. Summary of the Invention

[0006] The technical problem to be solved by this invention is to address the shortcomings of existing technologies, specifically by providing an exception handling method based on MCP, as follows: 1) In a first aspect, the present invention provides an exception handling method based on MCP, the specific technical solution of which is as follows: S1, Obtain the model input data generated from the running status data and task requirement data of each microservice node in the distributed microservice system after standardization, and input the model input data into the multi-objective constraint optimization model to determine the initial MCP call planning scheme; S2, the initial MCP call planning scheme is used as the initial policy of the reinforcement learning agent to construct a Markov decision process model. The value function of the Markov decision process model is iteratively updated through the temporal difference learning method, and the dynamically adapted MCP call planning scheme is output. S3, execute the MCP call planning scheme, and input the current running status data of each microservice node into the anomaly detection model based on multivariate Gaussian distribution in real time, and calculate the anomaly score between the running status data of each microservice node and the normal state benchmark model. S4. When the anomaly score of at least one microservice node exceeds a preset dynamic threshold, it is determined that the distributed microservice system has an anomaly, and the microservice node with the highest anomaly score is identified as the suspected anomaly source node. S5. Using the suspected abnormal source node as the initial condition, construct an abnormal diffusion prediction model based on partial differential equations, solve the abnormal diffusion prediction model, iteratively calculate the influence distribution of each microservice node within a preset future time step, and obtain the diffusion trend of the abnormal along the microservice call chain. S6, based on the Bayesian localization method, calculates the posterior probability of each microservice node as an anomaly source based on the current running status data of each microservice node, and determines the microservice node with the highest posterior probability as the final anomaly source node. S7. Based on the final abnormal source node and the diffusion trend, construct a fault-tolerant repair model with the optimization objectives of minimizing repair cost and maximizing system recoverability. S8. Solve the fault tolerance and repair model using the gradient descent method to obtain the optimal repair resource allocation scheme for each microservice node, and perform the abnormal repair operation according to the optimal repair resource allocation scheme.

[0007] The beneficial effects of the MCP-based anomaly handling method provided by this invention are as follows: This invention collects and standardizes microservice node operating status and task requirement data, calculates anomaly scores using a multivariate Gaussian distribution model, and identifies suspected anomaly sources using dynamic thresholds. It then constructs a diffusion prediction model using partial differential equations to iteratively calculate the influence distribution of each node within future time steps. Based on Bayesian localization, it calculates the posterior probability to determine the final anomaly source. Finally, it constructs a fault-tolerant repair model with the goal of minimizing repair costs and maximizing recovery, and solves the optimal repair resource allocation scheme using gradient descent. This addresses the problems of traditional MCP tools, such as passive anomaly response, insufficient localization accuracy, lack of diffusion prediction, and unreasonable repair resource allocation. It improves the initiative, accuracy, and timeliness of anomaly handling in a distributed microservice architecture, while reducing anomaly recovery cycles and operational costs.

[0008] Based on the above solution, the present invention can be further improved as follows.

[0009] Furthermore, the process of determining the initial MCP call planning scheme is as follows: Obtain the cost coefficient, optimal efficiency allocation point, minimum effective allocation amount, and maximum capacity allocation amount of different types of resources in the distributed microservice system; Based on the cost coefficient of each type of resource, the quadratic cost terms of all types of resources are weighted and summed to construct a cost objective function in the form of a quadratic cost function. Based on the optimal allocation point and slope coefficient, the sigmoid efficiency terms of all types of resources are weighted and summed to construct a system efficiency objective function in the form of a sigmoid function. Based on the minimum effective allocation amount of resources and the maximum carrying capacity allocation amount of resources, the linear utilization rate terms of all types of resources are weighted and summed to construct a resource utilization rate objective function in the form of a linear normalized function. Obtain system resource total constraints and business priority resource constraints. The system resource total constraints are: the sum of all resource allocations equals the total available resources. The business priority resource constraints are: the allocation of each type of resource is not less than the product of the minimum business allocation coefficient and the task priority coefficient of that resource. The cost objective function, the system efficiency objective function, the resource utilization objective function, the total system resource constraint, and the business priority resource constraint are fused into a Lagrange function using the Lagrange multiplier method. Take the partial derivatives of each resource allocation variable and each Lagrange multiplier in the Lagrange function, set all partial derivatives to zero, and solve the KKT conditions in conjunction with the complementary relaxation conditions to obtain the optimal allocation of each type of resource. The optimal allocation of each type of resource is used as the initial MCP call planning scheme.

[0010] Furthermore, the specific process of S2 includes: S21, the resource allocation of each type in the initial MCP call planning scheme is used as the action selection benchmark of the initial policy of the reinforcement learning agent; S22, Define the state space of the Markov decision process model, the state space including: the used resource percentage vector, the task progress vector, and the microservice running state vector; Define the action space of the Markov decision process model, the action space including: resource allocation adjustment action, task execution order optimization action, and cross-node resource scheduling action. S23. Based on the historical operation data of the distributed microservice system, a Gaussian mixture model is used to fit the state transition probability, where the state transition probability represents the probability of transitioning to the next state under the current state and the current action. S24, Set a reward function, which includes an immediate reward item and a long-term reward item. The immediate reward item is calculated based on the change in system cost, efficiency, and resource utilization after the current action is executed. The long-term reward item is calculated based on the cumulative impact of the current action on the execution time of subsequent tasks. S25, initialize the value function of the Markov decision process model, and set the value of each state in the value function to a preset initial value; S26, at each decision time step, an ε-greedy strategy is adopted to select an action based on the current state. The ε-greedy strategy randomly selects an action with a probability of ε and selects the optimal action under the current value function with a probability of 1-ε. ε decays with each decision time step. S27, execute the selected action, observe the next state and calculate the immediate reward, calculate the temporal difference objective based on the immediate reward, the preset discount factor and the value function of the next state, and update the value function of the current state according to the temporal difference learning formula; S28, repeat S26 and S27 until the change in the value function is less than the preset convergence threshold or the preset maximum number of iterations is reached. S29, the optimal strategy corresponding to the converged value function is output as the dynamically adapted MCP call planning scheme.

[0011] Furthermore, the specific implementation process of S3 includes: According to the MCP call planning scheme, computing resources, interface call quotas, and task queue capacity are allocated to each microservice node. Within each sampling period, the current running status data of each microservice node is collected. The current running status data includes: response time, call frequency, and data transmission volume. Obtain historical operational status data for each microservice node under normal conditions. The historical operational status data includes: historical response time, historical call frequency, and historical data transmission volume. The historical operating status data is processed in batches using an iterative batch statistical method. For each batch, a local mean vector and a local covariance matrix are calculated, and the local mean vector and the local covariance matrix are merged and updated into a global mean vector and a global covariance matrix. The global mean vector and the global covariance matrix are used as parameters of the normal state benchmark model, which is a three-dimensional multivariate Gaussian distribution. The current running status data is used as input data and substituted into the probability density function of the three-dimensional multivariate Gaussian distribution to calculate the multidimensional probability density value of the current running status data of each microservice node relative to the normal state baseline model. Taking the negative natural logarithm of the multidimensional probability density value yields the anomaly score for each microservice node.

[0012] Furthermore, the specific process of S4 is as follows: Obtain the anomaly score for each microservice node, where the anomaly score is a multidimensional probability density value in negative logarithmic form; A preset dynamic threshold, determined in advance through receiver operating characteristic curve analysis, is obtained, which enables the true positive rate and false positive rate of anomaly detection to reach a preset balance condition. The anomaly score of each microservice node is compared with the preset dynamic threshold. When the anomaly score of at least one microservice node exceeds the preset dynamic threshold, the distributed microservice system is determined to have encountered an anomaly. After determining that an anomaly has occurred, select the microservice node with the highest anomaly score from all microservice nodes. The microservice node with the highest abnormal score is marked as a suspected abnormal source node.

[0013] Furthermore, the S5 process is as follows: The initial value of the influence of the suspected abnormal source node is set to 1, the initial value of the influence of each other microservice node is set to 0, and the influence of the boundary nodes at both ends of the microservice call chain is fixed to 0. For each microservice node, a diffusion coefficient is set based on the call coupling between the node and its neighboring nodes, and a node vulnerability coefficient is set based on the node's ability to withstand exceptions. A two-dimensional partial differential equation is constructed as the anomaly propagation prediction model. The two-dimensional partial differential equation includes a time dimension and a microservice node spatial dimension. The two-dimensional partial differential equation is discretized using the finite difference method, the time dimension is discretized into the preset future time step, and the spatial dimension of the microservice nodes is discretized into the number sequence of each microservice node. Starting from the initial time step, based on the influence distribution of each microservice node in the current time step, the influence distribution of each microservice node in the next time step is iteratively calculated using the difference format of the finite difference method, until the preset future time step is reached; The impact distribution of each microservice node calculated at each time step is used as the diffusion trend of the anomaly along the microservice call chain.

[0014] Furthermore, the specific process of S6 includes: Obtain the frequency of anomalies for each microservice node in historical running data, and use the frequency of anomalies as the prior probability of each microservice node; For each microservice node, assuming that the node is the source of the anomaly, the likelihood probability of the running status data of each microservice node at the current moment is obtained by reverse deduction based on the anomaly propagation prediction model. Multiply the prior probability of each microservice node by its corresponding likelihood probability to obtain the joint probability of each microservice node. The marginal probability is obtained by summing the joint probabilities of all microservice nodes. Divide the joint probability of each microservice node by the marginal probability to obtain the posterior probability of each microservice node as an anomaly source. The posterior probabilities of each microservice node are compared, and the microservice node with the highest posterior probability is selected as the final anomaly source node.

[0015] Furthermore, the S7 process specifically includes: Define a repair resource allocation variable for each microservice node, whereby the repair resource allocation variable represents the proportion of repair resources allocated to the corresponding microservice node out of the total repair resources; Set a unit repair cost coefficient for each microservice node, and sum the products of the repair resource allocation variable for each microservice node and the corresponding unit repair cost coefficient to obtain the total repair cost item; Based on the influence distribution of each microservice node in the diffusion trend and the location of the final abnormal source node, a recovery contribution weight is assigned to each microservice node. The recovery contribution weight is determined based on the criticality of the microservice node in the call chain and the degree of influence of the diffusion. The system recovery function is obtained by summing the products of the repair resource allocation variable and the corresponding recovery contribution weight of each microservice node. The objective function of the fault-tolerant repair model is formed by subtracting the preset recovery coefficient from the total repair cost and multiplying it by the system recovery function. Set a value range constraint for the repair resource allocation variable for each microservice node. The lower bound of the value range constraint is 0, the upper bound is 1, and the sum of the repair resource allocation variables of all microservice nodes is equal to 1.

[0016] Furthermore, the S8 process is as follows: S81, initialize the repair resource allocation variable for each microservice node, set the repair resource allocation variable of all microservice nodes to the same value and satisfy that the sum of all variables is equal to 1; S82, Substitute the repair resource allocation variables of each microservice node into the objective function of the fault tolerance repair model, and calculate the partial derivative of the objective function with respect to the repair resource allocation variables of each microservice node; S83, based on the product of the partial derivative and the preset learning rate, update the repair resource allocation variable of each microservice node along the negative gradient direction to obtain the updated repair resource allocation variable; S84, Perform a projection operation on the updated repair resource allocation variables, set variable values ​​less than 0 to 0, and normalize all variables so that their sum equals 1; S85, repeat S82 to S84 until the change in the objective function is less than the preset convergence threshold; S86, the repair resource allocation variable of each microservice node obtained after convergence is taken as the optimal repair resource allocation scheme; S87. Based on the value of the repair resource allocation variable of each microservice node in the optimal repair resource allocation scheme, repair resources are allocated to the corresponding microservice node, and an anomaly repair operation is performed. The anomaly repair operation includes at least one of task diversion, backup computing power activation, and node restart.

[0017] Furthermore, it also includes: Collect planning effect evaluation indicators and anomaly handling effect evaluation indicators of the distributed microservice system within a preset time window. The planning effect evaluation indicators include: task timeliness achievement rate, resource utilization rate and task completion rate. The anomaly handling effect evaluation indicators include: anomaly handling time consumption, system recovery rate and anomaly recurrence rate. The planning effect evaluation index and the anomaly handling effect evaluation index are normalized to the interval between zero and one, and the normalized indexes are weighted and summed to obtain a comprehensive feedback signal. The global mean vector, global covariance matrix, and preset dynamic threshold in the anomaly detection model are updated based on the comprehensive feedback signal, wherein the preset dynamic threshold is decreased when the comprehensive feedback signal is positive and increased when the comprehensive feedback signal is negative. The updated global mean vector, global covariance matrix, and adjusted preset dynamic threshold are fed back to the multi-objective constrained optimization model and the reinforcement learning agent to adjust the resource planning strategy and anomaly detection benchmark in subsequent cycles. Attached Figure Description

[0018] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 This is one of the flowcharts illustrating an exception handling method based on MCP according to an embodiment of the present invention; Figure 2 This is a schematic diagram of one of the exception handling methods based on MCP according to an embodiment of the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.

[0020] like Figure 1 as well as Figure 2 As shown in the figure, an exception handling method based on MCP according to an embodiment of the present invention includes the following steps: S1, Obtain the model input data generated from the running status data and task requirement data of each microservice node in the distributed microservice system after standardization, and input the model input data into the multi-objective constraint optimization model to determine the initial MCP call planning scheme; S2, the initial MCP call planning scheme is used as the initial policy of the reinforcement learning agent to construct a Markov decision process model. The value function of the Markov decision process model is iteratively updated through the temporal difference learning method, and the dynamically adapted MCP call planning scheme is output. S3, execute the MCP call planning scheme, and input the current running status data of each microservice node into the anomaly detection model based on multivariate Gaussian distribution in real time, and calculate the anomaly score between the running status data of each microservice node and the normal state benchmark model. S4. When the anomaly score of at least one microservice node exceeds a preset dynamic threshold, it is determined that the distributed microservice system has an anomaly, and the microservice node with the highest anomaly score is identified as the suspected anomaly source node. S5. Using the suspected abnormal source node as the initial condition, construct an abnormal diffusion prediction model based on partial differential equations, solve the abnormal diffusion prediction model, iteratively calculate the influence distribution of each microservice node within a preset future time step, and obtain the diffusion trend of the abnormal along the microservice call chain. S6, based on the Bayesian localization method, calculates the posterior probability of each microservice node as an anomaly source based on the current running status data of each microservice node, and determines the microservice node with the highest posterior probability as the final anomaly source node. S7. Based on the final abnormal source node and the diffusion trend, construct a fault-tolerant repair model with the optimization objectives of minimizing repair cost and maximizing system recoverability. S8. Solve the fault tolerance and repair model using the gradient descent method to obtain the optimal repair resource allocation scheme for each microservice node, and perform the abnormal repair operation according to the optimal repair resource allocation scheme.

[0021] The beneficial effects of the MCP-based anomaly handling method provided by this invention are as follows: This invention collects and standardizes microservice node operating status and task requirement data, calculates anomaly scores using a multivariate Gaussian distribution model, and identifies suspected anomaly sources using dynamic thresholds. It then constructs a diffusion prediction model using partial differential equations to iteratively calculate the influence distribution of each node within future time steps. Based on Bayesian localization, it calculates the posterior probability to determine the final anomaly source. Finally, it constructs a fault-tolerant repair model with the goal of minimizing repair costs and maximizing recovery, and solves the optimal repair resource allocation scheme using gradient descent. This addresses the problems of traditional MCP tools, such as passive anomaly response, insufficient localization accuracy, lack of diffusion prediction, and unreasonable repair resource allocation. It improves the initiative, accuracy, and timeliness of anomaly handling in a distributed microservice architecture, while reducing anomaly recovery cycles and operational costs.

[0022] This embodiment uses the online business support system of a provincial branch of a telecommunications service company as an example. This system contains five microservice nodes: Node 1 is the authentication microservice, Node 2 is the API gateway microservice, Node 3 is the core order microservice, Node 4 is the inventory microservice, and Node 5 is the notification microservice. The Model Context Protocol (MCP) server acts as the execution entity, responsible for resource planning, task scheduling, and exception handling.

[0023] The specific process of S1 may include: The MCP server acquires runtime status data and task requirement data for each microservice node in the distributed microservice system. Runtime status data includes each node's response time (in milliseconds), call frequency (in times / minute), and data transfer volume (in MB / s). Task requirement data includes each task's priority coefficient, execution latency requirements, and cross-node coordination rules.

[0024] To eliminate the influence of different units of measurement on the subsequent optimization model, the MCP server performs standardization processing on the above data. The standardization formula is as follows: , where μ and σ are the mean and standard deviation of the historical normal period, respectively. The numerical vector obtained after standardization is called the model input data. For example, the standardized data of node 3 is X3=(3.5,67,4).

[0025] The model input data is fed into a multi-objective constrained optimization model. This model simultaneously optimizes three conflicting objectives: cost control, system efficiency, and resource utilization. Specifically, the MCP server calculates the cost coefficient c for each type of resource. i0 c i1 c i2 (i represents the resource type, including computing power, customer service seats, system interfaces, and review personnel), construct a cost objective function in the form of a quadratic cost function: Where, x i ω is the amount of MCP call allocation for resource type i. 1i Cost weights are used. The optimal allocation point x is determined based on efficiency. i,opt With slope coefficient k i Construct the system efficiency objective function in the form of a sigmoid function: Based on the minimum effective allocation amount of resources x i,min With maximum load distribution x i,max Construct a resource utilization objective function in the form of a linearly normalized function: The system has total resource constraints. (R) total (Total available resources) and business priority resource constraints x i ≥ (r) i,min T is the minimum matching factor for business operations. j (This refers to the task priority coefficient). The MCP server uses the Lagrange multiplier method to fuse the three objective functions and two constraints into a Lagrange function L(X,λ,μ). It then obtains the optimal allocation of each type of resource by solving the Cartesian-Kun-Tucker (KKT) conditions (i.e., taking the partial derivative of each variable and setting it to zero, combined with complementary relaxation conditions). These optimal allocations constitute the initial MCP call planning scheme, for example, allocating computing resources as follows: node 1:30, node 2:25, node 3:20, node 4:15, node 5:10 (normalized units).

[0026] The Lagrange function is constructed as follows: in The transformation coefficient represents the goal of maximizing the system's objectives (efficiency, utilization) and unifying them into a minimization problem. Let these be the Lagrange multipliers, corresponding to the total resource constraints for business processing and the resource constraints for business priority, respectively; by taking the partial derivative and setting it to 0, combined with... , By applying complementary relaxation conditions, the optimal resource allocation scheme can be obtained. The total amount of resources that can be called for MCP processing of business (normalized total of comprehensive computing power, seats, interfaces, and review personnel). Tj is the minimum allocation coefficient for the i-th resource; Tj is the priority coefficient for the j-th business task (Tj takes the maximum value for government and enterprise VIP and emergency card replacement business).

[0027] The specific process of S2 may include: The initial MCP call plan may deviate from the optimal approach under dynamic system changes (such as fluctuations in resource supply and adjustments in task priorities). Therefore, the MCP server uses this plan as the initial policy for the reinforcement learning agent and constructs a Markov decision process model.

[0028] The Markov decision process model comprises a state space, an action space, state transition probabilities, and a reward function. The state space consists of a vector representing the percentage of resources used, a vector representing task progress, and a vector representing the running state of the microservices. The action space includes resource allocation adjustment actions (e.g., transferring 5 units of resources from node 3 to node 4), task execution order optimization actions (e.g., prioritizing high-priority tasks), and cross-node resource scheduling actions (e.g., transferring some order queries to the inventory node). The state transition probabilities are obtained by fitting a Gaussian mixture model based on historical data. The reward function includes both immediate and long-term rewards. ,in The discount factor (value 0.9) represents the long-term reward, which reflects the cumulative impact of the current action on the execution time of subsequent tasks.

[0029] The MCP server uses a temporal difference learning method to update the value function online. The value function V(s) is initialized with a preset initial value (e.g., all zeros). At each decision time step, based on the current state s... t Use an ε-greedy strategy to select action a t (ε decays with the number of iterations). After performing the action, observe the new state s. t+1 And calculate the instant reward r t Then, update according to the time-series difference formula: Where α is the learning rate. Repeat the above steps until the change in the value function is less than the preset convergence threshold. Finally, the optimal policy corresponding to the converged value function is output as a dynamically adapted MCP call planning scheme, which can respond to system changes in real time.

[0030] The specific process of S3 may include: The MCP server executes the MCP call planning scheme output by S2, that is, it allocates computing resources, interface call quotas, and task queue capacity to each microservice node according to the resource allocation in the scheme. At the same time, it collects the current running status data (response time, call frequency, data transfer volume) of each microservice node in each sampling period (e.g., every 5 seconds).

[0031] To determine if the system has encountered an anomaly, the MCP server inputs current operational status data into an anomaly detection model based on a multivariate Gaussian distribution. This model relies on a normal state baseline model, which is trained from historical normal data using an iterative batch statistical method. Specifically, the MCP server acquires historical operational status data for each node under normal conditions (including historical response time, historical call frequency, and historical data transfer volume) and processes it in batches. For each batch, a local mean vector μ is calculated. new With the local covariance matrix Σ new Then merge and update the global mean. With global covariance The fusion formula is: The covariance matrix is ​​updated using a method similar to a weighted average. Ultimately, the normal state baseline model has a mean of [missing value]. Covariance is The three-dimensional multivariate Gaussian distribution.

[0032] For the running status data X of node i at the current time... i The MCP server calculates its multidimensional probability density value relative to the normal state baseline model. Then take the negative natural logarithm to obtain the outlier score: The higher the anomaly score, the more severely the current operating status deviates from the normal baseline.

[0033] The specific process of S4 may include: The MCP server pre-determines a preset dynamic threshold S through receiver operating characteristic (ROC) curve analysis. th (e.g. S) th =3.2), this threshold ensures that the true positive rate and false positive rate of anomaly detection reach a preset balance condition. The anomaly score of each microservice node is then compared with S... th Compare them.

[0034] If the anomaly score of at least one node is greater than S th If the anomaly score is 4.5, which is greater than 3.2, and all other nodes are below the threshold, then the distributed microservice system is determined to be abnormal. In this embodiment, node 3 has an anomaly score of 4.5, which is greater than 3.2, while all other nodes are below the threshold, so the system is determined to be abnormal. Subsequently, the MCP server selects the node with the highest anomaly score (i.e., node 3) from all nodes and identifies it as the suspected source node of the anomaly.

[0035] The specific process of S5 may include: In order to predict the possible propagation path of anomalies along the microservice call chain, the MCP server uses the suspected anomaly source node as the initial condition to build an anomaly propagation prediction model based on partial differential equations.

[0036] The influence distribution U(t,x) is defined to represent the degree of anomaly influence at node position x at time t (discrete time step), with a value range of [0,1]. Initial conditions are set: the initial influence value of the suspected anomaly source node (node ​​3) is set to 1, and the influence values ​​of the other nodes are set to 0; at the same time, the influence values ​​of the boundary nodes at both ends of the microservice call chain (nodes 1 and 5 in this system) are fixed to 0.

[0037] For each node, a diffusion coefficient D (based on the coupling degree between nodes, e.g., D=0.1 between nodes 2 and 3, D=0.08 between nodes 3 and 4) and a node vulnerability coefficient s(x) (based on the node's ability to resist anomalies, e.g., s=0.7 for node 3, s=0.5 for node 2, and s=0.4 for node 4) are constructed. A two-dimensional partial differential equation is then constructed: Where D is the diffusion coefficient, which is set according to the coupling degree between microservice nodes (the higher the coupling degree, the larger D is); s(x) is the node vulnerability coefficient, which reflects the node's ability to resist anomalies; This is a Logistic growth model used to simulate the saturation characteristics of the impact of outliers. Initial conditions... Indicates the source node of the anomaly. (Representing normal nodes), boundary conditions: The abnormal source node is represented; the finite difference method is used for numerical solution, and the partial differential equation is transformed into an algebraic equation through time discretization and spatial discretization. The abnormal impact distribution in the next T time steps is calculated iteratively to accurately predict the diffusion trend.

[0038] The MCP server uses the finite difference method to solve this partial differential equation. The time dimension is discretized into a preset future time step (e.g., 10 steps, each step spaced 1 second apart), and the spatial dimension is discretized into a node number sequence x = 1, 2, ..., 5. Using the difference scheme: The calculation iterates from the initial time step n=0 until the preset future time step is reached. The final result is the influence distribution of each node at each time step; for example, at second 10, the influence of node 2 is 0.7, and the influence of node 4 is 0.6. This sequence of influence values ​​that changes with time and node position is called the anomaly propagation trend along the microservice call chain.

[0039] The specific process of S6 may include: Although S4 has identified a suspected source node (node ​​3), further verification is needed because the anomaly may spread and cause downstream nodes to have higher anomaly scores. The MCP server uses a Bayesian localization method to accurately locate the true source of the anomaly.

[0040] By statistically analyzing the historical frequency of each node as an anomaly source over the past year, the prior probability P(C=i) of each node is obtained: Node 1: 0.05, Node 2: 0.10, Node 3: 0.60, Node 4: 0.15, Node 5: 0.10.

[0041] For each node i, assuming it is the source of the anomaly, the anomaly propagation prediction model in S5 is used to reverse-engineer the likelihood probability P(X|C=i) of the observed running status data X (i.e., the current running status data) of each node at the current moment. For example, assuming node 3 is the source, the expected response time obtained by reverse engineering is highly consistent with the actual 1200 milliseconds, with a likelihood probability of 0.95; assuming node 2 is the source, reverse engineering predicts that node 2 should be the first to become anomalous, but the actual response time of node 2 is only 30 milliseconds, with a likelihood probability of only 0.03.

[0042] Calculate the joint probability P(C=i,X) for each node. The marginal probability P(X) is obtained by summing the joint probabilities of all nodes. The posterior probability of each node is: The calculated posterior probability of node 3 was 0.92, which was much higher than that of other nodes. The MCP server selected the node with the highest posterior probability as the final source node of the anomaly (still node 3), thus confirming the previous suspected judgment.

[0043] The specific process of S7 may include: After identifying the final source node of the anomaly and understanding its spread trend, the MCP server constructs a fault-tolerant repair model with dual optimization objectives: minimizing repair costs and maximizing system recoverability.

[0044] Define a repair resource allocation variable `yi` for each microservice node, representing the proportion of repair resources (such as backup computing power, maintenance personnel man-hours, and traffic scheduling quotas) allocated to node i out of the total repair resources. The constraint is as follows: , .

[0045] Set a unit repair cost coefficient (costi) for each node. For example, the cost for node 3 is 0.5 (due to the high difficulty of repairing core business processes), the cost for node 2 is 0.3, and the costs for nodes 1, 4, and 5 are 0.2, 0.2, and 0.1 respectively. The total repair cost is... .

[0046] Based on the influence distribution of each node in the diffusion trend and the location of the final anomaly source node, a recovery contribution weight w is assigned to each node. iFor example, the final anomaly source node 3 has a weight of 0.4, nodes 2 and 4, which are severely affected by the diffusion, each have a weight of 0.25, and edge nodes 1 and 5 each have a weight of 0.05. The system resilience function is defined as ϕ(Y) = .

[0047] Subtracting the preset recovery coefficient λ (e.g., λ=0.8) from the total repair cost and multiplying by the system recovery function yields the objective function of the fault-tolerant repair model: The optimization goal is to minimize That is, to minimize repair costs and maximize system recoverability while satisfying constraints.

[0048] The specific process of S8 may include: The MCP server uses the gradient descent method to solve the above fault-tolerant repair model and obtain the optimal repair resource allocation scheme.

[0049] Initialize all repair resource allocation variables to equal values: (Satisfying the sum of 1). In the current iteration step k, compute the objective function. Partial derivatives with respect to each variable For the linear objective function in this embodiment, the partial derivatives are constants: ∇=[0.16,0.1,0.18,0,0.06].

[0050] Update the variable according to the direction of the negative gradient: α is the preset learning rate (e.g., 0.1). Project the updated variables: set values ​​less than 0 to 0, then normalize so that the sum of all variables is 1. Repeat the above iterations until the change in the objective function is less than a preset convergence threshold (e.g., 0.0001).

[0051] The final converged optimal solution is the optimal repair resource allocation scheme.

[0052] The MCP server performed the following troubleshooting steps: the inventory query portion of the order processing task from node 3 (the final source node of the anomaly) was offloaded to node 4; backup computing power was activated for node 4 (increasing the number of instances); node 3 was gracefully restarted to clear the temporary fault; and a small amount of resources were allocated to nodes 1, 2, and 5 to enhance stability.

[0053] Furthermore, the process of determining the initial MCP call planning scheme is as follows: Obtain the cost coefficient, optimal efficiency allocation point, minimum effective allocation amount, and maximum capacity allocation amount of different types of resources in the distributed microservice system; Based on the cost coefficient of each type of resource, the quadratic cost terms of all types of resources are weighted and summed to construct a cost objective function in the form of a quadratic cost function. Based on the optimal allocation point and slope coefficient, the sigmoid efficiency terms of all types of resources are weighted and summed to construct a system efficiency objective function in the form of a sigmoid function. Based on the minimum effective allocation amount of resources and the maximum carrying capacity allocation amount of resources, the linear utilization rate terms of all types of resources are weighted and summed to construct a resource utilization rate objective function in the form of a linear normalized function. Obtain system resource total constraints and business priority resource constraints. The system resource total constraints are: the sum of all resource allocations equals the total available resources. The business priority resource constraints are: the allocation of each type of resource is not less than the product of the minimum business allocation coefficient and the task priority coefficient of that resource. The cost objective function, the system efficiency objective function, the resource utilization objective function, the total system resource constraint, and the business priority resource constraint are fused into a Lagrange function using the Lagrange multiplier method. Take the partial derivatives of each resource allocation variable and each Lagrange multiplier in the Lagrange function, set all partial derivatives to zero, and solve the KKT conditions in conjunction with the complementary relaxation conditions to obtain the optimal allocation of each type of resource. The optimal allocation of each type of resource is used as the initial MCP call planning scheme.

[0054] Furthermore, the specific process of S2 includes: S21, the resource allocation of each type in the initial MCP call planning scheme is used as the action selection benchmark of the initial policy of the reinforcement learning agent; S22, Define the state space of the Markov decision process model, the state space including: the used resource percentage vector, the task progress vector, and the microservice running state vector; Define the action space of the Markov decision process model, the action space including: resource allocation adjustment action, task execution order optimization action, and cross-node resource scheduling action. S23. Based on the historical operation data of the distributed microservice system, a Gaussian mixture model is used to fit the state transition probability, where the state transition probability represents the probability of transitioning to the next state under the current state and the current action. S24, Set a reward function, which includes an immediate reward item and a long-term reward item. The immediate reward item is calculated based on the change in system cost, efficiency, and resource utilization after the current action is executed. The long-term reward item is calculated based on the cumulative impact of the current action on the execution time of subsequent tasks. S25, initialize the value function of the Markov decision process model, and set the value of each state in the value function to a preset initial value; S26, at each decision time step, an ε-greedy strategy is adopted to select an action based on the current state. The ε-greedy strategy randomly selects an action with a probability of ε and selects the optimal action under the current value function with a probability of 1-ε. ε decays with each decision time step. S27, execute the selected action, observe the next state and calculate the immediate reward, calculate the temporal difference objective based on the immediate reward, the preset discount factor and the value function of the next state, and update the value function of the current state according to the temporal difference learning formula; S28, repeat S26 and S27 until the change in the value function is less than the preset convergence threshold or the preset maximum number of iterations is reached. S29, the optimal strategy corresponding to the converged value function is output as the dynamically adapted MCP call planning scheme.

[0055] Furthermore, the specific implementation process of S3 includes: According to the MCP call planning scheme, computing resources, interface call quotas, and task queue capacity are allocated to each microservice node. Within each sampling period, the current running status data of each microservice node is collected. The current running status data includes: response time, call frequency, and data transmission volume. Obtain historical operational status data for each microservice node under normal conditions. The historical operational status data includes: historical response time, historical call frequency, and historical data transmission volume. The historical operating status data is processed in batches using an iterative batch statistical method. For each batch, a local mean vector and a local covariance matrix are calculated, and the local mean vector and the local covariance matrix are merged and updated into a global mean vector and a global covariance matrix. The global mean vector and the global covariance matrix are used as parameters of the normal state benchmark model, which is a three-dimensional multivariate Gaussian distribution. The current running status data is used as input data and substituted into the probability density function of the three-dimensional multivariate Gaussian distribution to calculate the multidimensional probability density value of the current running status data of each microservice node relative to the normal state baseline model. Taking the negative natural logarithm of the multidimensional probability density value yields the anomaly score for each microservice node.

[0056] Furthermore, the specific process of S4 is as follows: Obtain the anomaly score for each microservice node, where the anomaly score is a multidimensional probability density value in negative logarithmic form; A preset dynamic threshold, determined in advance through receiver operating characteristic curve analysis, is obtained, which enables the true positive rate and false positive rate of anomaly detection to reach a preset balance condition. The anomaly score of each microservice node is compared with the preset dynamic threshold. When the anomaly score of at least one microservice node exceeds the preset dynamic threshold, the distributed microservice system is determined to have encountered an anomaly. After determining that an anomaly has occurred, select the microservice node with the highest anomaly score from all microservice nodes. The microservice node with the highest abnormal score is marked as a suspected abnormal source node.

[0057] Furthermore, the S5 process is as follows: The initial value of the influence of the suspected abnormal source node is set to 1, the initial value of the influence of each other microservice node is set to 0, and the influence of the boundary nodes at both ends of the microservice call chain is fixed to 0. For each microservice node, a diffusion coefficient is set based on the call coupling between the node and its neighboring nodes, and a node vulnerability coefficient is set based on the node's ability to withstand exceptions. A two-dimensional partial differential equation is constructed as the anomaly propagation prediction model. The two-dimensional partial differential equation includes a time dimension and a microservice node spatial dimension. The two-dimensional partial differential equation is discretized using the finite difference method, the time dimension is discretized into the preset future time step, and the spatial dimension of the microservice nodes is discretized into the number sequence of each microservice node. Starting from the initial time step, based on the influence distribution of each microservice node in the current time step, the influence distribution of each microservice node in the next time step is iteratively calculated using the difference format of the finite difference method, until the preset future time step is reached; The impact distribution of each microservice node calculated at each time step is used as the diffusion trend of the anomaly along the microservice call chain.

[0058] Furthermore, the specific process of S6 includes: Obtain the frequency of anomalies for each microservice node in historical running data, and use the frequency of anomalies as the prior probability of each microservice node; For each microservice node, assuming that the node is the source of the anomaly, the likelihood probability of the running status data of each microservice node at the current moment is obtained by reverse deduction based on the anomaly propagation prediction model. Multiply the prior probability of each microservice node by its corresponding likelihood probability to obtain the joint probability of each microservice node. The marginal probability is obtained by summing the joint probabilities of all microservice nodes. Divide the joint probability of each microservice node by the marginal probability to obtain the posterior probability of each microservice node as an anomaly source. The posterior probabilities of each microservice node are compared, and the microservice node with the highest posterior probability is selected as the final anomaly source node.

[0059] Furthermore, the S7 process specifically includes: Define a repair resource allocation variable for each microservice node, whereby the repair resource allocation variable represents the proportion of repair resources allocated to the corresponding microservice node out of the total repair resources; Set a unit repair cost coefficient for each microservice node, and sum the products of the repair resource allocation variable for each microservice node and the corresponding unit repair cost coefficient to obtain the total repair cost item; Based on the influence distribution of each microservice node in the diffusion trend and the location of the final abnormal source node, a recovery contribution weight is assigned to each microservice node. The recovery contribution weight is determined based on the criticality of the microservice node in the call chain and the degree of influence of the diffusion. The system recovery function is obtained by summing the products of the repair resource allocation variable and the corresponding recovery contribution weight of each microservice node. The objective function of the fault-tolerant repair model is formed by subtracting the preset recovery coefficient from the total repair cost and multiplying it by the system recovery function. Set a value range constraint for the repair resource allocation variable for each microservice node. The lower bound of the value range constraint is 0, the upper bound is 1, and the sum of the repair resource allocation variables of all microservice nodes is equal to 1.

[0060] Furthermore, the S8 process is as follows: S81, initialize the repair resource allocation variable for each microservice node, set the repair resource allocation variable of all microservice nodes to the same value and satisfy that the sum of all variables is equal to 1; S82, Substitute the repair resource allocation variables of each microservice node into the objective function of the fault tolerance repair model, and calculate the partial derivative of the objective function with respect to the repair resource allocation variables of each microservice node; S83, based on the product of the partial derivative and the preset learning rate, update the repair resource allocation variable of each microservice node along the negative gradient direction to obtain the updated repair resource allocation variable; S84, Perform a projection operation on the updated repair resource allocation variables, set variable values ​​less than 0 to 0, and normalize all variables so that their sum equals 1; S85, repeat S82 to S84 until the change in the objective function is less than the preset convergence threshold; S86, the repair resource allocation variable of each microservice node obtained after convergence is taken as the optimal repair resource allocation scheme; S87. Based on the value of the repair resource allocation variable of each microservice node in the optimal repair resource allocation scheme, repair resources are allocated to the corresponding microservice node, and an anomaly repair operation is performed. The anomaly repair operation includes at least one of task diversion, backup computing power activation, and node restart.

[0061] Furthermore, it also includes: Collect planning effect evaluation indicators and anomaly handling effect evaluation indicators of the distributed microservice system within a preset time window. The planning effect evaluation indicators include: task timeliness achievement rate, resource utilization rate and task completion rate. The anomaly handling effect evaluation indicators include: anomaly handling time consumption, system recovery rate and anomaly recurrence rate. The planning effect evaluation index and the anomaly handling effect evaluation index are normalized to the interval between zero and one, and the normalized indexes are weighted and summed to obtain a comprehensive feedback signal. The global mean vector, global covariance matrix, and preset dynamic threshold in the anomaly detection model are updated based on the comprehensive feedback signal, wherein the preset dynamic threshold is decreased when the comprehensive feedback signal is positive and increased when the comprehensive feedback signal is negative. The updated global mean vector, global covariance matrix, and adjusted preset dynamic threshold are fed back to the multi-objective constrained optimization model and the reinforcement learning agent to adjust the resource planning strategy and anomaly detection benchmark in subsequent cycles.

[0062] In another embodiment of this solution, the MCP server sets a preset time window (e.g., 24 hours after the anomaly repair is completed). Within this time window, it continuously monitors and collects two types of evaluation metrics for the distributed microservice system. The first type is the planning effect evaluation metric, including: task timeliness achievement rate, which is the percentage of tasks completed on time out of the total number of tasks; resource utilization rate, which is the ratio of actual computing resources and interface call quotas used to the total available resources of the system; and task completion rate, which is the percentage of successfully completed tasks out of the total number of submitted tasks. The second type is the anomaly handling effect evaluation metric, including: anomaly handling time, which is the time (in minutes) elapsed from the triggering of an anomaly to the completion of the repair; system recovery rate, which is the percentage of the system function returning to normal after repair, calculated by comparing the response time, throughput, and other indicators of each node before and after repair; and anomaly recurrence rate, which is the probability of the same type of anomaly recurring after repair, obtained by statistically analyzing the ratio of the number of occurrences of the same type of anomaly within the preset time window to the total number of processing times.

[0063] Since the above six indicators have different dimensions and value ranges, the MCP server first normalizes them to the range of zero to one. For positive indicators (the larger the value, the better the effect), the normalized value is calculated using the formula: Normalized value = (Actual value - Minimum value) / (Maximum value - Minimum value); for negative indicators (the smaller the value, the better the effect, such as anomaly handling time and anomaly recurrence rate), the normalized value is calculated using the formula: Normalized value = (Maximum value - Actual value) / (Maximum value - Minimum value). For example, the minimum anomaly handling time is 0 minutes, the maximum is 15 minutes (required by system reliability standards), and the actual time is 10 minutes, so the normalized value is (15-10) / (15-0) = 0.333; the minimum anomaly recurrence rate is 0%, the maximum is 100%, and the actual recurrence rate is 2%, so the normalized value is (100-2) / (100-0) = 0.98; the task timeliness achievement rate, resource utilization rate, task completion rate, and system recovery rate are all positive indicators, and their normalized values ​​are obtained by directly dividing by 100.

[0064] The MCP server pre-sets weights for the planning effectiveness evaluation index and the anomaly handling effectiveness evaluation index, for example, a weight of 0.4 for planning effectiveness and a weight of 0.6 for anomaly handling effectiveness. Then, the normalized indicators are weighted and averaged according to their respective categories, and the weighted results from both categories are summed to obtain the comprehensive feedback signal F. The calculation formula is: in and These are the planning effect weights and the anomaly handling effect weights, respectively, R time R res R comp T norm R rec R relapse These represent the normalized task timeliness achievement rate, resource utilization rate, task completion rate, anomaly handling time, system recovery rate, and anomaly recurrence rate, respectively. The value of F ranges from [-1, 1], with a positive value indicating that the anomaly handling effect is better than the benchmark, and a negative value indicating that it is worse than the benchmark.

[0065] The MCP server updates the global mean vector in the anomaly detection model based on the sign and magnitude of the comprehensive feedback signal F. Global covariance matrix and preset dynamic threshold S th Specifically, the global mean vector and global covariance matrix are updated using an exponential moving average to smooth the relationship between historical information and current feedback. Where β is the learning rate (e.g., 0.1). and This represents the mean and covariance matrix of the runtime status data collected during this anomaly handling period. This update method is only executed when the absolute value of F exceeds a preset threshold (e.g., 0.2) to avoid model instability caused by frequent fine-tuning.

[0066] For the preset dynamic threshold S th The MCP server adjusts based on the sign of F: when F > 0, it indicates good anomaly handling and the system can detect anomalies more sensitively, therefore the threshold is lowered, and the adjustment formula is as follows: When F < 0, it indicates that the current anomaly handling is ineffective, and there may be false alarms or missed alarms. Therefore, the threshold should be increased to reduce false alarms, and the formula should be adjusted accordingly. Where η is the adjustment coefficient (e.g., 0.1). The adjusted threshold must be limited to a reasonable range, for example, S. th ∈[1.0,5.0], to avoid over-adjustment that could lead to detection failure.

[0067] The MCP server will update the global mean vector. Global covariance matrix and the adjusted preset dynamic threshold The updated parameters are fed back to the multi-objective constrained optimization model and the reinforcement learning agent. Specifically, the multi-objective constrained optimization model uses the updated threshold to adjust the weight parameters (e.g., the balance coefficients of cost, efficiency, and utilization) in its objective function, making the resource planning in the next cycle more adaptable to the dynamic changes of the system. The reinforcement learning agent uses the updated normal state baseline model parameters as the reference baseline in the state space of the Markov decision process and adjusts the abnormal penalty term in the reward function using the new dynamic threshold, thereby achieving a complete closed loop. All updated parameters are persistently stored through the configuration interface of the MCP server and automatically loaded at the beginning of the next decision cycle.

[0068] Through the above closed-loop learning steps, the MCP server can adaptively optimize the sensitivity of anomaly detection and the accuracy of resource planning. As the number of system runs increases, the anomaly detection threshold and the normal state benchmark model gradually approach the true optimal value, significantly reducing the workload of manual parameter tuning and continuously improving the robustness and anomaly response efficiency of the distributed microservice system under multiple constraints.

[0069] It should be noted that the terms "first" and "second" in the specification and claims of this application are used to distinguish similar objects and represent a limitation on a specific order or sequence. Where appropriate, the order of use for similar objects can be interchanged so that the embodiments of this application described herein can be implemented in an order other than that shown or described.

[0070] Those skilled in the art will recognize that this invention can be implemented as a system, method, or computer program product. Therefore, this disclosure can be specifically implemented in the following forms: it can be entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, the invention can also be implemented as a computer program product contained in one or more computer-readable media, which includes computer-readable program code.

[0071] Any combination of one or more computer-readable media may be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.

[0072] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. An exception handling method based on MCP, characterized in that, include: S1, Obtain the model input data generated from the running status data and task requirement data of each microservice node in the distributed microservice system after standardization, and input the model input data into the multi-objective constraint optimization model to determine the initial MCP call planning scheme; S2, the initial MCP call planning scheme is used as the initial policy of the reinforcement learning agent to construct a Markov decision process model. The value function of the Markov decision process model is iteratively updated through the temporal difference learning method, and the dynamically adapted MCP call planning scheme is output. S3, execute the MCP call planning scheme, and input the current running status data of each microservice node into the anomaly detection model based on multivariate Gaussian distribution in real time, and calculate the anomaly score between the running status data of each microservice node and the normal state benchmark model. S4. When the anomaly score of at least one microservice node exceeds a preset dynamic threshold, it is determined that the distributed microservice system has an anomaly, and the microservice node with the highest anomaly score is identified as the suspected anomaly source node. S5. Using the suspected abnormal source node as the initial condition, construct an abnormal diffusion prediction model based on partial differential equations, solve the abnormal diffusion prediction model, iteratively calculate the influence distribution of each microservice node within a preset future time step, and obtain the diffusion trend of the abnormal along the microservice call chain. S6, based on the Bayesian localization method, calculates the posterior probability of each microservice node as an anomaly source based on the current running status data of each microservice node, and determines the microservice node with the highest posterior probability as the final anomaly source node. S7. Based on the final abnormal source node and the diffusion trend, construct a fault-tolerant repair model with the optimization objectives of minimizing repair cost and maximizing system recoverability. S8. Solve the fault tolerance and repair model using the gradient descent method to obtain the optimal repair resource allocation scheme for each microservice node, and perform the abnormal repair operation according to the optimal repair resource allocation scheme.

2. The anomaly handling method based on MCP according to claim 1, characterized in that, The process of determining the initial MCP call planning scheme is as follows: Obtain the cost coefficient, optimal efficiency allocation point, minimum effective allocation amount, and maximum capacity allocation amount of different types of resources in the distributed microservice system; Based on the cost coefficient of each type of resource, the quadratic cost terms of all types of resources are weighted and summed to construct a cost objective function in the form of a quadratic cost function. Based on the optimal allocation point and slope coefficient, the sigmoid efficiency terms of all types of resources are weighted and summed to construct a system efficiency objective function in the form of a sigmoid function. Based on the minimum effective allocation amount of resources and the maximum carrying capacity allocation amount of resources, the linear utilization rate terms of all types of resources are weighted and summed to construct a resource utilization rate objective function in the form of a linear normalized function. Obtain system resource total constraints and business priority resource constraints. The system resource total constraints are: the sum of all resource allocations equals the total available resources. The business priority resource constraints are: the allocation of each type of resource is not less than the product of the minimum business allocation coefficient and the task priority coefficient of that resource. The cost objective function, the system efficiency objective function, the resource utilization objective function, the total system resource constraint, and the business priority resource constraint are fused into a Lagrange function using the Lagrange multiplier method. Take the partial derivatives of each resource allocation variable and each Lagrange multiplier in the Lagrange function, set all partial derivatives to zero, and solve the KKT conditions in conjunction with the complementary relaxation conditions to obtain the optimal allocation of each type of resource. The optimal allocation of each type of resource is used as the initial MCP call planning scheme.

3. The anomaly handling method based on MCP according to claim 1, characterized in that, The specific process of S2 includes: S21, the resource allocation of each type in the initial MCP call planning scheme is used as the action selection benchmark of the initial policy of the reinforcement learning agent; S22, Define the state space of the Markov decision process model, the state space including: the used resource percentage vector, the task progress vector, and the microservice running state vector; Define the action space of the Markov decision process model, the action space including: resource allocation adjustment action, task execution order optimization action, and cross-node resource scheduling action. S23. Based on the historical operation data of the distributed microservice system, a Gaussian mixture model is used to fit the state transition probability, where the state transition probability represents the probability of transitioning to the next state under the current state and the current action. S24, Set a reward function, which includes an immediate reward item and a long-term reward item. The immediate reward item is calculated based on the change in system cost, efficiency, and resource utilization after the current action is executed. The long-term reward item is calculated based on the cumulative impact of the current action on the execution time of subsequent tasks. S25, initialize the value function of the Markov decision process model, and set the value of each state in the value function to a preset initial value; S26, at each decision time step, an ε-greedy strategy is adopted to select an action based on the current state. The ε-greedy strategy randomly selects an action with a probability of ε and selects the optimal action under the current value function with a probability of 1-ε. ε decays with each decision time step. S27, execute the selected action, observe the next state and calculate the immediate reward, calculate the temporal difference objective based on the immediate reward, the preset discount factor and the value function of the next state, and update the value function of the current state according to the temporal difference learning formula; S28, repeat S26 and S27 until the change in the value function is less than the preset convergence threshold or the preset maximum number of iterations is reached. S29, the optimal strategy corresponding to the converged value function is output as the dynamically adapted MCP call planning scheme.

4. The anomaly handling method based on MCP according to claim 1, characterized in that, The specific implementation process of S3 includes: According to the MCP call planning scheme, computing resources, interface call quotas, and task queue capacity are allocated to each microservice node. Within each sampling period, the current running status data of each microservice node is collected. The current running status data includes: response time, call frequency, and data transmission volume. Obtain historical operational status data for each microservice node under normal conditions. The historical operational status data includes: historical response time, historical call frequency, and historical data transmission volume. The historical operating status data is processed in batches using an iterative batch statistical method. For each batch, a local mean vector and a local covariance matrix are calculated, and the local mean vector and the local covariance matrix are merged and updated into a global mean vector and a global covariance matrix. The global mean vector and the global covariance matrix are used as parameters of the normal state benchmark model, which is a three-dimensional multivariate Gaussian distribution. The current running status data is used as input data and substituted into the probability density function of the three-dimensional multivariate Gaussian distribution to calculate the multidimensional probability density value of the current running status data of each microservice node relative to the normal state baseline model. Taking the negative natural logarithm of the multidimensional probability density value yields the anomaly score for each microservice node.

5. The anomaly handling method based on MCP according to claim 1, characterized in that, The specific process of S4 is as follows: Obtain the anomaly score for each microservice node, where the anomaly score is a multidimensional probability density value in negative logarithmic form; A preset dynamic threshold, determined in advance through receiver operating characteristic curve analysis, is obtained, which enables the true positive rate and false positive rate of anomaly detection to reach a preset balance condition. The anomaly score of each microservice node is compared with the preset dynamic threshold. When the anomaly score of at least one microservice node exceeds the preset dynamic threshold, the distributed microservice system is determined to have encountered an anomaly. After determining that an anomaly has occurred, select the microservice node with the highest anomaly score from all microservice nodes. The microservice node with the highest abnormal score is marked as a suspected abnormal source node.

6. The anomaly handling method based on MCP according to claim 1, characterized in that, The process of S5 is as follows: The initial value of the influence of the suspected abnormal source node is set to 1, the initial value of the influence of each other microservice node is set to 0, and the influence of the boundary nodes at both ends of the microservice call chain is fixed to 0. For each microservice node, a diffusion coefficient is set based on the call coupling between the node and its neighboring nodes, and a node vulnerability coefficient is set based on the node's ability to withstand exceptions. A two-dimensional partial differential equation is constructed as the anomaly propagation prediction model. The two-dimensional partial differential equation includes a time dimension and a microservice node spatial dimension. The two-dimensional partial differential equation is discretized using the finite difference method, the time dimension is discretized into the preset future time step, and the spatial dimension of the microservice nodes is discretized into the number sequence of each microservice node. Starting from the initial time step, based on the influence distribution of each microservice node in the current time step, the influence distribution of each microservice node in the next time step is iteratively calculated using the difference format of the finite difference method, until the preset future time step is reached; The impact distribution of each microservice node calculated at each time step is used as the diffusion trend of the anomaly along the microservice call chain.

7. The anomaly handling method based on MCP according to claim 1, characterized in that, The specific process of S6 includes: Obtain the frequency of anomalies for each microservice node in historical running data, and use the frequency of anomalies as the prior probability of each microservice node; For each microservice node, assuming that the node is the source of the anomaly, the likelihood probability of the running status data of each microservice node at the current moment is obtained by reverse deduction based on the anomaly propagation prediction model. Multiply the prior probability of each microservice node by its corresponding likelihood probability to obtain the joint probability of each microservice node. The marginal probability is obtained by summing the joint probabilities of all microservice nodes. Divide the joint probability of each microservice node by the marginal probability to obtain the posterior probability of each microservice node as an anomaly source. The posterior probabilities of each microservice node are compared, and the microservice node with the highest posterior probability is selected as the final anomaly source node.

8. The anomaly handling method based on MCP according to claim 1, characterized in that, The S7 process specifically includes: Define a repair resource allocation variable for each microservice node, whereby the repair resource allocation variable represents the proportion of repair resources allocated to the corresponding microservice node out of the total repair resources; Set a unit repair cost coefficient for each microservice node, and sum the products of the repair resource allocation variable for each microservice node and the corresponding unit repair cost coefficient to obtain the total repair cost item; Based on the influence distribution of each microservice node in the diffusion trend and the location of the final abnormal source node, a recovery contribution weight is assigned to each microservice node. The recovery contribution weight is determined based on the criticality of the microservice node in the call chain and the degree of influence of the diffusion. The system recovery function is obtained by summing the products of the repair resource allocation variable and the corresponding recovery contribution weight of each microservice node. The objective function of the fault-tolerant repair model is formed by subtracting the preset recovery coefficient from the total repair cost and multiplying it by the system recovery function. Set a value range constraint for the repair resource allocation variable for each microservice node. The lower bound of the value range constraint is 0, the upper bound is 1, and the sum of the repair resource allocation variables of all microservice nodes is equal to 1.

9. The MCP-based anomaly handling method according to claim 1, characterized in that, The process of S8 is as follows: S81, initialize the repair resource allocation variable for each microservice node, set the repair resource allocation variable of all microservice nodes to the same value and satisfy that the sum of all variables is equal to 1; S82, Substitute the repair resource allocation variables of each microservice node into the objective function of the fault tolerance repair model, and calculate the partial derivative of the objective function with respect to the repair resource allocation variables of each microservice node; S83, based on the product of the partial derivative and the preset learning rate, update the repair resource allocation variable of each microservice node along the negative gradient direction to obtain the updated repair resource allocation variable; S84, Perform a projection operation on the updated repair resource allocation variables, set variable values ​​less than 0 to 0, and normalize all variables so that their sum equals 1; S85, repeat S82 to S84 until the change in the objective function is less than the preset convergence threshold; S86, the repair resource allocation variable of each microservice node obtained after convergence is taken as the optimal repair resource allocation scheme; S87. Based on the value of the repair resource allocation variable of each microservice node in the optimal repair resource allocation scheme, repair resources are allocated to the corresponding microservice node, and an anomaly repair operation is performed. The anomaly repair operation includes at least one of task diversion, backup computing power activation, and node restart.

10. The anomaly handling method based on MCP according to claim 1, characterized in that, Also includes: Collect planning effect evaluation indicators and anomaly handling effect evaluation indicators of the distributed microservice system within a preset time window. The planning effect evaluation indicators include: task timeliness achievement rate, resource utilization rate and task completion rate. The anomaly handling effect evaluation indicators include: anomaly handling time consumption, system recovery rate and anomaly recurrence rate. The planning effect evaluation index and the anomaly handling effect evaluation index are normalized to the interval between zero and one, and the normalized indexes are weighted and summed to obtain a comprehensive feedback signal. The global mean vector, global covariance matrix, and preset dynamic threshold in the anomaly detection model are updated based on the comprehensive feedback signal, wherein the preset dynamic threshold is decreased when the comprehensive feedback signal is positive and increased when the comprehensive feedback signal is negative. The updated global mean vector, global covariance matrix, and adjusted preset dynamic threshold are fed back to the multi-objective constrained optimization model and the reinforcement learning agent to adjust the resource planning strategy and anomaly detection benchmark in subsequent cycles.