A multi-dimensional API gateway traffic control method and system
By building an adaptive anomaly detection model and an impact range prediction model, the deficiencies in traffic anomaly detection and isolation in API gateway traffic control are resolved, intelligent traffic anomaly self-healing is achieved, and system stability and business continuity are improved.
Patent Information
- Application Number
- CN202410974822.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-19
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2044-07-19
AI Technical Summary
Existing API gateway traffic control methods lack effective detection and response measures when faced with traffic anomalies, resulting in service interruptions or cascading failures. They also lack effective traffic anomaly isolation and flow limiting measures, causing the impact of local traffic anomalies to spread rapidly.
Machine learning algorithms are used to automatically extract abnormal features from massive multi-dimensional data, build an adaptive anomaly detection model, predict the type of anomaly and the scope of impact through anomaly classification models and impact range prediction models, and design corresponding traffic control strategies to achieve intelligent anomaly detection and self-healing.
It realizes intelligent detection and self-healing of traffic anomalies, improves the accuracy and recall rate of anomaly detection, can quickly block the spread of anomalies, ensure business continuity and stability, and enhance the intelligent operation and maintenance level of the system.
Smart Images

Figure CN119011453B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of flow control technology, and in particular to a multi-dimensional combined API gateway flow control method and system. Background Art
[0002] API gateway traffic control is an important technical means for managing the request traffic passing through the API gateway and ensuring the stability and availability of backend services. It involves the following areas: First, by setting thresholds for indicators such as request rate and concurrency, requests that exceed the limit will be rejected or queued to avoid traffic surges that may cause system overload; second, system resources are isolated and divided according to different APIs, users, applications, and other dimensions to prevent individual APIs or users from occupying too many resources and affecting other requests; third, the gateway can dynamically select the optimal backend service node for request forwarding based on API characteristics, user attributes, and system status.
[0003] A Chinese patent with authorization announcement number CN111107012B discloses a multi-dimensional centralized traffic control method and system, including: receiving a request initiated by a service caller; obtaining tokens of the corresponding dimension from a token bucket according to the set traffic control dimension, and allocating them to the requests in sequence; forwarding the requests after being allocated tokens to the message queue of the service provider for queuing; when the request queuing ends, determining whether the request has a token to access the service provider; if there is a token, forwarding the request to the service provider, and releasing the token upon receiving the return information from the service provider.
[0004] Although the existing API gateway traffic control method based on dynamic routing and load balancing can optimize request forwarding and balance service node pressure to a certain extent, it still has some shortcomings and limitations. The specific problems are as follows: the existing methods lack effective detection and response measures for abnormal traffic fluctuations, bursts, and continuous overloads. Once a traffic anomaly occurs, it may lead to service interruption or cascading failure. The lack of effective traffic anomaly isolation and flow limiting measures may cause the impact of local traffic anomalies to spread rapidly, triggering a chain reaction. Summary of the Invention
[0005] This application aims to solve at least one of the technical problems in the related art to a certain extent. To this end, one purpose of this application is to propose a multi-dimensional API gateway flow control method and system to achieve control and self-healing of flow anomalies.
[0006] One aspect of the present application provides a multi-dimensional combined API gateway traffic control method, including:
[0007] Step S100: Divide the historical operation cycle into A time periods, collect monitoring data of the API gateway and resource utilization data of the node, collect context information when traffic anomalies occur, and generate a first feature set;
[0008] Step S200: Calculating the feature importance parameter of each feature in the first feature set, taking the features whose feature importance parameter is greater than the feature selection threshold as key features affecting traffic anomalies, and generating an abnormal feature matrix;
[0009] Step S300: using the abnormal feature matrix and context information to train an abnormality classification model and an abnormality impact range prediction model, using the abnormality classification model to predict the abnormality type of the current traffic abnormality, and using the abnormality impact range prediction model to predict the impact range of the current traffic abnormality;
[0010] Step S400: Design a traffic control strategy for each anomaly type, calculate the recovery time, recovery quality, and resource consumption of each traffic control strategy in handling different historical anomalies, calculate the strategy's historical performance score, and calculate the strategy fitness score of each traffic control strategy based on the anomaly type and impact range of the current traffic anomaly;
[0011] Step S500: Calculate the policy benefit based on the policy historical performance score and the policy applicability score, calculate the policy failure risk of each traffic control policy, calculate the policy score value of each traffic control policy for the current traffic anomaly based on the policy benefit and the policy failure risk, and take the traffic control policy with the highest policy score value as the optimal traffic control policy.
[0012] Preferably, the specific method of dividing the historical operation cycle into A time periods, collecting the monitoring data of the API gateway and the resource utilization data of the node, and collecting the context information when the traffic is abnormal, and generating the first feature set is:
[0013] Step S110: Collect monitoring data of the API gateway in A time periods during the historical operation cycle, including: number of requests, response time, error rate, and throughput;
[0014] Step S120: Collect resource utilization data of each node, including CPU utilization, memory utilization, network utilization, and disk utilization;
[0015] Step S130: Identify the time period in which the traffic anomaly occurs in the A time periods, and collect context information when the traffic anomaly occurs, including: anomaly time, anomaly type, affected nodes, and affected APIs;
[0016] Step S140: Anomaly labels are added to the periods of traffic anomalies within the historical operation cycle. The anomaly labels include the anomaly time, anomaly type, and impact range of the traffic anomaly. The anomaly type labels include traffic surge, denial of service, and resource exhaustion. The impact range of the traffic anomaly includes API impact and node impact.
[0017] Step S150: extract features from the monitoring data, resource utilization data and context information of A time periods to generate a first feature set. The features obtained after feature extraction of the monitoring data, resource utilization data and context information of each time period are samples in the first feature set.
[0018] Preferably, the feature importance parameter of each feature in the first feature set is calculated, and the features whose feature importance parameter is greater than the feature selection threshold are taken as key features affecting traffic anomalies. The specific method for generating the abnormal feature matrix is:
[0019] Step S210: Calculate the feature importance parameter of each feature in the first feature set. The calculation formula is: IG(TZ i ,GZ)=H(GZ)-H(GZ|TZ i ), among which IG(TZ i ,GZ) is the feature importance parameter of the i-th feature, H(GZ) represents the information entropy of the abnormal label, H(GZ|TZ i ) indicates that the feature is TZ i The conditional information entropy of abnormal labels under the condition of;
[0020] The calculation formula of the information entropy is: H(GZ)=-∑ j p(GZ j )×log2(p(GZ j )), where p(GZ j ) indicates that the exception type label is GZ j The probability of GZ j is the jth category of the abnormal type label;
[0021] The feature is TZ i The calculation formula of the conditional information entropy of the abnormal label in the case of is: H(GZ|TZ i )=∑p(TZ i =v k )×H(GZ|TZ i =v k ), where p(TZ i =v k ) represents feature TZ i The value is v k The probability of H(GZ|TZ i=v k ) indicates that in feature TZ i The value is v k The conditional information entropy of the abnormal label under the condition of;
[0022] Step S220: Preset a feature selection threshold, and select features whose feature importance parameters are greater than the feature selection threshold as key features affecting traffic anomalies, thereby obtaining n key features affecting traffic anomalies to form a key feature set;
[0023] Step S230: Encode the key features to obtain key feature codes and generate abnormal feature matrix X GZ =(X1,X2,...,X A ) T , X m =(x m1 ,x m2 ,...,x mn ), m∈{1,2,...,A}, the abnormal feature matrix contains A abnormal feature vectors, where X m is the abnormal feature vector of the mth period, x mn is the nth key feature code in the abnormal feature vector of the mth period, and T is the transpose of the matrix.
[0024] Preferably, the impact range of the traffic anomaly specifically includes: API impact probability and node impact probability, and the dimension of API impact probability is a API , a API Indicates the number of APIs, and the dimension of the node influence probability is a jd , a jd Indicates the number of nodes, and the API impact probability and node impact probability are probability values between 0 and 1.
[0025] Preferably, the specific method of using the abnormal feature matrix and context information to train the abnormality classification model and the abnormality impact range prediction model, using the abnormality classification model to predict the abnormality type of the current traffic abnormality, and using the abnormality impact range prediction model to predict the impact range of the current traffic abnormality is:
[0026] Step S310: Select the softmax regression model as the initial model for training the abnormal classification model. The input layer of the softmax regression model uses the abnormal feature vector as input data, and the output layer of the softmax regression model uses the one-hot encoding of the abnormal type label as output data. Add m between the input layer and the output layer. yc A fully connected hidden layer uses the ReLU function as the activation function and the softmax function to convert the output data into a probability distribution;
[0027] Step S320: using cross entropy loss as the loss function of the anomaly classification model;
[0028] The calculation formula of the loss function of the abnormal classification model is: Loss1 = -∑y true ×log(y pred ), where y true is the one-hot encoding of the true abnormal type label, y pred is the probability distribution of the predicted anomaly type, log(·) is the logarithmic function;
[0029] Step S330: Use the Adam optimization algorithm to update the parameters of the anomaly classification model. When the cross entropy loss value is minimized, the training is completed, and a trained anomaly classification model is obtained.
[0030] Step S340: Select a multi-label neural network model as the initial model for training the abnormal impact range prediction model. The input layer of the multi-label neural network model uses the abnormal feature vector as input data, and the output layer of the multi-label neural network model uses the impact range of the traffic abnormality as output data. Add n between the input layer and the output layer. yc A fully connected hidden layer with ReLU function as activation function;
[0031] Step S350: The abnormal feature vector is used as the input of the training data, and the API impact label and node impact label corresponding to the traffic anomaly are used as the output of the training data. The dimension of the API impact label is (A, a API ), the dimension of the node impact label is (A, a jd ), the value of each API impact label or node impact label is 0 or 1, 0 means that the traffic anomaly has no impact on the API or node, and 1 means that the traffic anomaly has an impact on the API or node;
[0032] Step S360: using binary cross entropy loss as the loss function of the abnormal impact range prediction model, wherein the loss function of the abnormal impact range prediction model includes API impact loss and node impact loss;
[0033] The calculation formula for the API impact loss is: in, For real API impact labels, is the predicted API impact probability;
[0034] The calculation formula of the node impact loss is: Among them, y′ true is the real node influence label, y′pred is the predicted node impact probability;
[0035] The calculation formula of the loss function of the abnormal impact range prediction model is: Among them, λ API ,λ jd are the weight coefficients of API impact loss and node impact loss respectively;
[0036] Step S370: Using the Adam optimization algorithm to minimize the loss function of the abnormality impact range prediction model, updating the parameters of the abnormality impact range prediction model, and completing the training when the loss function of the abnormality impact range prediction model is minimized to obtain the abnormality impact range prediction model;
[0037] Step S380: Use the trained anomaly classification model to predict the anomaly type of the current traffic anomaly, and use the trained anomaly impact range prediction model to predict the API impact probability and node impact probability.
[0038] Preferably, the method of designing a flow control strategy for each anomaly type, calculating the recovery time, recovery quality, and resource consumption of each flow control strategy in different historical anomaly processing, and calculating the strategy historical performance score, and calculating the strategy fitness score of each flow control strategy based on the anomaly type and impact range of the current flow anomaly, is as follows:
[0039] Step S410: According to the characteristics of each abnormality type, a set of flow control strategies is designed for it to obtain a strategy pool. The strategy pool of the jth abnormality type is CL j ={cl j1 ,cl j2 ,...,cl jC}, where cl jC represents the Cth flow control strategy in the strategy pool of the jth anomaly type, where C represents the total number of flow control strategies;
[0040] Step S420: Utilize historical exception handling logs to calculate the recovery time, recovery quality, and resource consumption of each flow control strategy in historical exception handling. Obtain the average recovery time, average recovery quality, and average resource consumption through weighted average calculation. Furthermore, obtain the maximum recovery time and maximum resource consumption of all flow control strategies in historical exception handling.
[0041] Step S430: Calculate the policy historical performance score of the traffic control policy based on the average recovery time, average recovery quality, average resource consumption, maximum recovery time, and maximum resource consumption;
[0042] The calculation method for the strategy's historical performance score is: Among them, HS jc The cth flow control strategy cl for the jth abnormal type jc The historical performance score of the strategy in historical anomaly handling, c∈{1,2,...,C},avg(T jc )、avg(Q jc )、avg(C jc ) are flow control strategies cl jc Average recovery time, average recovery quality, and average resource consumption in historical exception handling, T max 、C max are the maximum recovery time and maximum resource consumption of all flow control strategies in historical exception processing, α1, α2, and α3 are the weight coefficients of recovery time, recovery quality, and resource consumption, respectively, α1+α2+α3=1;
[0043] Step S440: Obtain the second characteristic vector based on the abnormal type and impact range of the current traffic abnormality, and obtain the traffic control strategy cl jc For all traffic anomalies processed in historical anomaly processing, the anomaly types and impact ranges are calculated, and the average values of all anomaly types and the average values of the impact ranges of all traffic anomalies are calculated. The average value of the anomaly types and the average value of the impact ranges are used to form an average feature vector.
[0044] Step S450: Calculate the feature similarity between the second feature vector and the average feature vector, and use the feature similarity as the flow control strategy cl jc The strategy suitability score for the current traffic anomaly;
[0045] The calculation formula for the strategy suitability score is: AS jc =sim(FV now ,FV jc,hst ), where FV now is the second eigenvector of the current traffic anomaly, FV jc,hst The flow control policy cl jc The average feature vector of all exceptions processed in historical exception processing, sim(·) is the similarity function, AS jc The flow control policy cl jc The policy suitability score for the current traffic anomaly.
[0046] Preferably, the specific method of calculating the policy benefit from the policy historical performance score and the policy applicability score, calculating the policy failure risk of each flow control policy, calculating the policy score value of each flow control policy for the current flow anomaly based on the policy benefit and the policy failure risk, and taking the flow control policy with the highest policy score as the optimal flow control policy is as follows:
[0047] Step S510: Calculate the strategy benefit by using the strategy historical performance score and the strategy applicability score. The calculation formula of the strategy benefit is: SY jc =β HS ×HS jc +β AS ×AS jc , where β HS , β AS are the weight coefficients of strategy historical performance score and strategy applicability score, β HS +β AS =1;
[0048] Step S520: Count the number of failures and total execution times of each flow control strategy in historical exception handling through historical exception handling logs, and calculate the strategy failure risk:
[0049] The calculation method of the strategy failure risk is: Among them, N fail,jc The flow control policy cl jc Number of failures in historical exception handling, N total,jc The flow control policy cl jc Total number of executions in historical exception handling;
[0050] Step S530: Calculate the flow control strategy cl by the strategy benefit and strategy failure risk jc The strategy score value of
[0051] The calculation formula of the strategy score value is: Score jc =SY jc -RP×FX jc , where RP is the risk penalty coefficient;
[0052] Step S540: Calculate the policy scores of all traffic control policies, select the traffic control policy with the highest policy score as the optimal traffic control policy, and execute the optimal traffic control policy to process and recover the current traffic anomaly.
[0053] One aspect of the present application provides a multi-dimensional API gateway traffic control system, including:
[0054] A first feature set generation module is used to divide the historical operation cycle into A time periods, collect monitoring data of the API gateway and resource utilization data of the node, collect context information when traffic anomalies occur, and generate a first feature set;
[0055] An abnormal feature matrix generation module is used to calculate the feature importance parameter of each feature in the first feature set, and take the features whose feature importance parameters are greater than the feature selection threshold as key features affecting traffic anomalies to generate an abnormal feature matrix;
[0056] The type and impact range prediction module is used to train the anomaly classification model and the anomaly impact range prediction model using the anomaly feature matrix and context information, and use the anomaly classification model to predict the anomaly type of the current traffic anomaly and use the anomaly impact range prediction model to predict the impact range of the current traffic anomaly;
[0057] The traffic control policy evaluation module is used to design a traffic control policy for each anomaly type, calculate the recovery time, recovery quality, and resource consumption of each traffic control policy in handling different historical anomalies, calculate the policy's historical performance score, and calculate the policy fitness score of each traffic control policy based on the anomaly type and impact range of the current traffic anomaly;
[0058] The optimal control strategy screening module is used to calculate the strategy benefit based on the strategy historical performance score and the strategy applicability score, calculate the strategy failure risk of each flow control strategy, and calculate the strategy score value of each flow control strategy for the current flow anomaly based on the strategy benefit and strategy failure risk. The flow control strategy with the highest strategy score value is selected as the optimal flow control strategy.
[0059] One aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps in a multi-dimensional combined API gateway traffic control method.
[0060] One aspect of the present application provides a readable storage medium, which stores a computer program, and the computer program is suitable for loading by a processor to execute the steps in a multi-dimensional combined API gateway traffic control method.
[0061] The multi-dimensional API gateway traffic control method and system proposed in this application have the following advantages over existing technologies:
[0062] This application uses machine learning algorithms to automatically extract anomaly features from massive multi-dimensional data and build an adaptive anomaly detection model. This overcomes the limitations of traditional threshold-based detection, enabling intelligent and real-time anomaly detection, and significantly improving the accuracy and recall of anomaly detection. Through continuous learning and optimization of the anomaly detection model, the effectiveness of anomaly detection can be continuously improved, enabling the system to continuously evolve.
[0063] This application trains an abnormal impact range prediction model to quantify the probability of impact on APIs and nodes, which can achieve more fine-grained impact range judgment and provide a reference for refined control.
[0064] This application designs corresponding exception handling strategies for different types of traffic anomalies. When an anomaly occurs, this application can automatically evaluate the impact scope of the traffic anomaly, comprehensively consider the historical performance of the strategy and the risk of strategy failure, intelligently select the optimal handling strategy, quickly block the spread of the anomaly, maximize the continuity and stability of the business, control risks while optimizing the recovery effect, realize the automatic discovery and self-healing of traffic anomalies in the microservice system, and improve the intelligent operation and maintenance level of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 A flowchart of a multi-dimensional API gateway flow control method provided by this application;
[0066] Figure 2 This is a functional module diagram of a multi-dimensional API gateway traffic control system provided by this application;
[0067] Figure 3 A schematic diagram of the structure of an electronic device provided in this application;
[0068] Figure 4 This is a schematic diagram of the structure of a readable storage medium provided by this application. DETAILED DESCRIPTION
[0069] To better understand the present application, various aspects of the present application will be described in more detail with reference to the accompanying drawings. It should be understood that these detailed descriptions are merely descriptions of exemplary embodiments of the present application and are not intended to limit the scope of the present application in any way. Throughout the specification, the same reference numerals refer to the same elements. The expression "and / or" includes any and all combinations of one or more of the associated listed items.
[0070] In the accompanying drawings, the size, dimensions, and shapes of the elements have been slightly adjusted for ease of illustration. The accompanying drawings are for illustration only and are not drawn strictly to scale. As used herein, the terms "substantially," "approximately," and similar terms are used to indicate approximate values, not degrees, and are intended to illustrate inherent deviations in measurements or calculations that would be recognized by a person of ordinary skill in the art. In addition, in this application, the order in which the steps are described does not necessarily represent the order in which these steps would occur in actual operation, unless otherwise specified or inferred from the context.
[0071] It should also be understood that expressions such as "including", "comprising", "having", "containing" and / or "comprising" are open rather than closed expressions in this specification, which indicate the presence of the stated features, elements and / or components, but do not exclude the presence of one or more other features, elements, components and / or combinations thereof. In addition, when expressions such as "at least one of..." appear after a list of listed features, they modify the entire list of features rather than just the individual elements in the list. In addition, when describing embodiments of the present application, "may" is used to mean "one or more embodiments of the present application". And, the term "exemplary" is intended to refer to an example or illustration.
[0072] Unless otherwise defined, all words used herein (including engineering terms and scientific and technological terms) have the same meaning as commonly understood by those skilled in the art to which this application belongs. It should also be understood that, unless otherwise specified in this application, words defined in commonly used dictionaries should be interpreted as having the same meaning as they do in the context of the relevant technology, and should not be interpreted in an idealized or overly formal sense.
[0073] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this 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.
[0074] Example 1
[0075] like Figure 1 As shown, this application provides a multi-dimensional API gateway flow control method, including:
[0076] Step S100: Divide the historical operation cycle into A time periods, collect monitoring data of the API gateway and resource utilization data of the node, collect context information when traffic anomalies occur, and generate a first feature set;
[0077] The specific method for dividing the historical operation cycle into A time periods, collecting API gateway monitoring data and node resource utilization data, and collecting context information when traffic anomalies occur to generate the first feature set is as follows:
[0078] Step S110: Collect monitoring data of the API gateway in A time periods during the historical operation cycle, including: number of requests, response time, error rate, and throughput;
[0079] The number of requests reflects the traffic and load of the API gateway;
[0080] The response time reflects the performance of the API. Abnormal response time indicates abnormal traffic.
[0081] The error rate reflects the health of the API. A high error rate indicates abnormal traffic.
[0082] The throughput reflects the processing capacity of the API. Abnormal changes in throughput indicate traffic anomalies.
[0083] Step S120: Collect resource utilization data of each node, including CPU utilization, memory utilization, network utilization, and disk utilization;
[0084] Step S130: Identify the time period in which the traffic anomaly occurs in the A time periods, and collect context information when the traffic anomaly occurs, including: anomaly time, anomaly type, affected nodes, and affected APIs;
[0085] Step S140: Anomaly labels are added to the periods of traffic anomalies within the historical operation cycle. The anomaly labels include the anomaly time, anomaly type, and impact range of the traffic anomaly. The anomaly type labels include traffic surge, denial of service, and resource exhaustion. The impact range of the traffic anomaly includes API impact and node impact.
[0086] Step S150: extract features from the monitoring data, resource utilization data and context information of A time periods to generate a first feature set. The features obtained after feature extraction of the monitoring data, resource utilization data and context information of each time period are samples in the first feature set.
[0087] Step S200: Calculating the feature importance parameter of each feature in the first feature set, taking the features whose feature importance parameter is greater than the feature selection threshold as key features affecting traffic anomalies, and generating an abnormal feature matrix;
[0088] The method of calculating the feature importance parameter of each feature in the first feature set and taking the features whose feature importance parameter is greater than the feature selection threshold as the key features affecting the traffic anomaly and generating the abnormal feature matrix is as follows:
[0089] Step S210: Calculate the feature importance parameter of each feature in the first feature set. The calculation formula is: IG(TZ i ,GZ)=H(GZ)-H(GZ|TZ i ), among which IG(TZ i ,GZ) is the feature importance parameter of the i-th feature, H(GZ) represents the information entropy of the abnormal label, H(GZ|TZ i ) indicates that the feature is TZ i The conditional information entropy of abnormal labels under the condition of;
[0090] The calculation formula of the information entropy is: H(GZ)=-∑ jp(GZ j )×log2(p(GZ j )), where p(GZ j ) indicates that the exception type label is GZ j The probability of GZ j is the jth category of the abnormal type label;
[0091] The feature is TZ i The calculation formula of the conditional information entropy of the abnormal label in the case of is: H(GZ|TZ i )=∑p(TZ i =v k )×H(GZ|TZ i =v k ), where p(TZ i =v k ) represents feature TZ i The value is v k The probability of H(GZ|TZ i =v k ) indicates that in feature TZ i The value is v k The conditional information entropy of the abnormal label under the condition of;
[0092] The H(GZ|TZ i =v k ) is calculated as follows:
[0093] Statistical characteristics TZ i The value is v k The number of samples N(TZ i =v k ), for each exception type GZ j , statistics in feature TZ i The value is v k Under the condition of j The number of samples N(GZ j |TZ i =v k );
[0094] Calculated in characteristic TZ i The value is v k The conditional probability distribution of abnormal labels under the condition of is calculated as follows:
[0095] Initialize the conditional information entropy of the abnormal label to 0, for each abnormal type GZ j , if p(GZ j |TZ i =v k )>0, then -p(GZj |TZ i =v k )*log2(p(GZ j |TZ i =v k )) is added to H(GZ|TZ i =v k )middle;
[0096] Get the final feature TZ i The value is v k The conditional information entropy H(GZ|TZ) of the abnormal label under the condition i =v k );
[0097] Step S220: Preset a feature selection threshold, and select features whose feature importance parameters are greater than the feature selection threshold as key features affecting traffic anomalies, thereby obtaining n key features affecting traffic anomalies to form a key feature set;
[0098] The feature selection threshold is set by those skilled in the art based on experience;
[0099] Step S230: Encode the key features to obtain key feature codes and generate abnormal feature matrix X GZ =(X1,X2,...,X A ) T , X m =(x m1 ,x m2 ,...,x mn ), m∈{1,2,...,A}, the abnormal feature matrix contains A abnormal feature vectors, where X m is the abnormal feature vector of the mth period, x mn is the nth key feature code in the abnormal feature vector of the mth period, and T is the transpose of the matrix.
[0100] Step S300: using the abnormal feature matrix and context information to train an abnormality classification model and an abnormality impact range prediction model, using the abnormality classification model to predict the abnormality type of the current traffic abnormality, and using the abnormality impact range prediction model to predict the impact range of the current traffic abnormality;
[0101] The impact range of the traffic anomaly specifically includes: API impact probability and node impact probability. The dimension of API impact probability is a API , a API Indicates the number of APIs, and the dimension of the node influence probability is a jd , a jd Indicates the number of nodes, the API impact probability and node impact probability are probability values between 0 and 1;
[0102] The specific method of using the abnormal feature matrix and context information to train the abnormality classification model and the abnormality impact range prediction model, using the abnormality classification model to predict the abnormality type of the current traffic abnormality, and using the abnormality impact range prediction model to predict the impact range of the current traffic abnormality is as follows:
[0103] Step S310: Select the softmax regression model as the initial model for training the abnormal classification model. The input layer of the softmax regression model uses the abnormal feature vector as input data, and the output layer of the softmax regression model uses the one-hot encoding of the abnormal type label as output data. Add m between the input layer and the output layer. yc A fully connected hidden layer uses the ReLU function as the activation function and the softmax function to convert the output data into a probability distribution;
[0104] Step S320: using cross entropy loss as the loss function of the anomaly classification model;
[0105] The calculation formula of the loss function of the abnormal classification model is: Loss1 = -∑y true ×log(y pred ), where y true is the one-hot encoding of the true abnormal type label, y pred is the probability distribution of the predicted anomaly type, log(·) is the logarithmic function;
[0106] Step S330: Use the Adam optimization algorithm to update the parameters of the anomaly classification model. When the cross entropy loss value is minimized, the training is completed, and a trained anomaly classification model is obtained.
[0107] Step S340: Select a multi-label neural network model as the initial model for training the abnormal impact range prediction model. The input layer of the multi-label neural network model uses the abnormal feature vector as input data, and the output layer of the multi-label neural network model uses the impact range of the traffic abnormality as output data. Add n between the input layer and the output layer. yc A fully connected hidden layer with ReLU function as activation function;
[0108] Step S350: The abnormal feature vector is used as the input of the training data, and the API impact label and node impact label corresponding to the traffic anomaly are used as the output of the training data. The dimension of the API impact label is (A, a API ), the dimension of the node impact label is (A, a jd ), the value of each API impact label or node impact label is 0 or 1, 0 means that the traffic anomaly has no impact on the API or node, and 1 means that the traffic anomaly has an impact on the API or node;
[0109] Step S360: using binary cross entropy loss as the loss function of the abnormal impact range prediction model, wherein the loss function of the abnormal impact range prediction model includes API impact loss and node impact loss;
[0110] The calculation formula for the API impact loss is: in, For real API impact labels, is the predicted API impact probability;
[0111] The calculation formula of the node impact loss is: Among them, y′ true is the real node influence label, y′ pred is the predicted node impact probability;
[0112] The calculation formula of the loss function of the abnormal impact range prediction model is: Among them, λ API ,λ jd are the weight coefficients of API impact loss and node impact loss respectively;
[0113] The weight coefficients of the API impact loss and node impact loss are set by those skilled in the art based on actual needs and experience;
[0114] Step S370: Using the Adam optimization algorithm to minimize the loss function of the abnormality impact range prediction model, updating the parameters of the abnormality impact range prediction model, and completing the training when the loss function of the abnormality impact range prediction model is minimized to obtain the abnormality impact range prediction model;
[0115] Step S380: Use the trained anomaly classification model to predict the anomaly type of the current traffic anomaly, and use the trained anomaly impact range prediction model to predict the API impact probability and node impact probability.
[0116] Step S400: Design a traffic control strategy for each anomaly type, calculate the recovery time, recovery quality, and resource consumption of each traffic control strategy in handling different historical anomalies, calculate the strategy's historical performance score, and calculate the strategy fitness score of each traffic control strategy based on the anomaly type and impact range of the current traffic anomaly;
[0117] The specific method for designing a flow control strategy for each anomaly type, calculating the recovery time, recovery quality, and resource consumption of each flow control strategy in handling different historical anomalies, and calculating the strategy historical performance score, and calculating the strategy fitness score of each flow control strategy based on the anomaly type and impact range of the current flow anomaly, is as follows:
[0118] Step S410: According to the characteristics of each abnormality type, a set of flow control strategies is designed for it to obtain a strategy pool. The strategy pool of the jth abnormality type is CL j ={cl j1 ,cl j2 ,...,cl jC}, where cl jC represents the Cth flow control strategy in the strategy pool of the jth anomaly type, where C represents the total number of flow control strategies;
[0119] The specific method of designing a set of flow control strategies is as follows: a person skilled in the art designs a set of flow control strategies for each type of anomaly based on the characteristics of each type of anomaly and based on experience;
[0120] The flow control strategies include but are not limited to: flow limiting, degradation, caching, retry, and circuit breaking;
[0121] Step S420: Utilize historical exception handling logs to calculate the recovery time, recovery quality, and resource consumption of each flow control strategy in historical exception handling. Obtain the average recovery time, average recovery quality, and average resource consumption through weighted average calculation. Furthermore, obtain the maximum recovery time and maximum resource consumption of all flow control strategies in historical exception handling.
[0122] Step S430: Calculate the policy historical performance score of the traffic control policy based on the average recovery time, average recovery quality, average resource consumption, maximum recovery time, and maximum resource consumption;
[0123] The calculation method for the strategy's historical performance score is: Among them, HS jc The cth flow control strategy cl for the jth abnormal type jc The historical performance score of the strategy in historical anomaly handling, c∈{1,2,...,C},avg(T jc )、avg(Q jc )、avg(C jc ) are flow control strategies cl jc Average recovery time, average recovery quality, and average resource consumption in historical exception handling, T max 、C maxare the maximum recovery time and maximum resource consumption of all flow control strategies in historical exception processing, α1, α2, and α3 are the weight coefficients of recovery time, recovery quality, and resource consumption, respectively, α1+α2+α3=1;
[0124] The weight coefficients of the recovery time, recovery quality and resource consumption are set by those skilled in the art according to actual needs;
[0125] Step S440: Obtain the second characteristic vector based on the abnormal type and impact range of the current traffic abnormality, and obtain the traffic control strategy cl jc For all traffic anomalies processed in historical anomaly processing, the anomaly types and impact ranges are calculated, and the average values of all anomaly types and the average values of the impact ranges of all traffic anomalies are calculated. The average value of the anomaly types and the average value of the impact ranges are used to form an average feature vector.
[0126] Step S450: Calculate the feature similarity between the second feature vector and the average feature vector, and use the feature similarity as the flow control strategy cl jc The strategy suitability score for the current traffic anomaly;
[0127] The calculation formula for the strategy suitability score is: AS jc =sim(FV now ,FV jc,hst ), where FV now is the second eigenvector of the current traffic anomaly, FV jc,hst The flow control policy cl jc The average feature vector of all exceptions processed in historical exception processing, sim(·) is the similarity function, AS jc The flow control policy cl jc The strategy suitability score for the current traffic anomaly;
[0128] The similarity function calculates the feature similarity between the second feature vector and the average feature vector by using a cosine similarity or Euclidean distance method.
[0129] Step S500: Calculate the policy benefit based on the policy historical performance score and the policy applicability score, calculate the policy failure risk of each flow control policy, and calculate the policy score of each flow control policy for the current flow anomaly based on the policy benefit and the policy failure risk. The flow control policy with the highest policy score is selected as the optimal flow control policy.
[0130] The specific method of calculating the policy benefit from the policy historical performance score and the policy applicability score, calculating the policy failure risk of each flow control policy, and calculating the policy score of each flow control policy for the current flow anomaly based on the policy benefit and the policy failure risk, and taking the flow control policy with the highest policy score as the optimal flow control policy is as follows:
[0131] Step S510: Calculate the strategy benefit by using the strategy historical performance score and the strategy applicability score. The calculation formula of the strategy benefit is: SY jc =β HS ×HS jc +β AS ×AS jc , where β HS , β AS are the weight coefficients of strategy historical performance score and strategy applicability score, β HS +β AS =1;
[0132] The weight coefficients of the strategy historical performance score and strategy suitability score reflect the importance of the strategy historical performance score and strategy suitability score to the strategy returns, and are set by those skilled in the art based on actual needs and experience;
[0133] Step S520: Count the number of failures and total execution times of each flow control strategy in historical exception handling through historical exception handling logs, and calculate the strategy failure risk:
[0134] The calculation method of the strategy failure risk is: Among them, N fail,jc The flow control policy cl jc Number of failures in historical exception handling, N total,jc The flow control policy cl jc Total number of executions in historical exception handling;
[0135] Step S530: Calculate the flow control strategy cl by the strategy benefit and strategy failure risk jc The strategy score value of
[0136] The calculation formula of the strategy score value is: Score jc =SY jc -RP×FX jc , where RP is the risk penalty coefficient;
[0137] The risk penalty coefficient is used to balance the strategy benefits and the risk of strategy failure. The larger the RP, the more severe the risk penalty and the more conservative the strategy selection. The value of the risk penalty coefficient is determined by those skilled in the art based on the system's risk tolerance and business needs.
[0138] Step S540: Calculate the policy scores of all traffic control policies, select the traffic control policy with the highest policy score as the optimal traffic control policy, and execute the optimal traffic control policy to process and recover the current traffic anomaly.
[0139] Example 2
[0140] like Figure 2 As shown, this application provides a multi-dimensional API gateway traffic control system, including:
[0141] A first feature set generation module is used to divide the historical operation cycle into A time periods, collect monitoring data of the API gateway and resource utilization data of the node, collect context information when traffic anomalies occur, and generate a first feature set;
[0142] An abnormal feature matrix generation module is used to calculate the feature importance parameter of each feature in the first feature set, and take the features whose feature importance parameters are greater than the feature selection threshold as key features affecting traffic anomalies to generate an abnormal feature matrix;
[0143] The type and impact range prediction module is used to train the anomaly classification model and the anomaly impact range prediction model using the anomaly feature matrix and context information, and use the anomaly classification model to predict the anomaly type of the current traffic anomaly and use the anomaly impact range prediction model to predict the impact range of the current traffic anomaly;
[0144] The traffic control policy evaluation module is used to design a traffic control policy for each anomaly type, calculate the recovery time, recovery quality, and resource consumption of each traffic control policy in handling different historical anomalies, calculate the policy's historical performance score, and calculate the policy fitness score of each traffic control policy based on the anomaly type and impact range of the current traffic anomaly;
[0145] The optimal control strategy screening module is used to calculate the strategy benefit based on the strategy historical performance score and the strategy applicability score, calculate the strategy failure risk of each flow control strategy, and calculate the strategy score value of each flow control strategy for the current flow anomaly based on the strategy benefit and strategy failure risk. The flow control strategy with the highest strategy score value is selected as the optimal flow control strategy.
[0146] Example 3
[0147] Figure 3 This is a schematic diagram of the electronic device structure provided by an embodiment of the present application. Figure 3As shown, according to another aspect of the present application, an electronic device is provided. The electronic device may include one or more processors and one or more memories. The memories store computer-readable code, which, when executed by one or more processors, may execute the multi-dimensional combined API gateway traffic control method described above.
[0148] The method or system according to the embodiment of the present application can also be used by Figure 3 The electronic device architecture shown in FIG. Figure 3 As shown, the electronic device may include a bus, one or more CPUs, a read-only memory (ROM), a random access memory (RAM), a communication port connected to a network, an input / output component, a hard disk, etc. A storage device in the electronic device, such as a ROM or a hard disk, may store a multi-dimensional combined API gateway flow control method provided in this application. A multi-dimensional combination API gateway traffic control method may, for example, include: dividing a historical operation cycle into A time periods, collecting monitoring data of the API gateway and resource utilization data of the node, collecting context information when traffic anomalies occur, and generating a first feature set; calculating a feature importance parameter for each feature in the first feature set, taking features whose feature importance parameters are greater than a feature selection threshold as key features affecting traffic anomalies, and generating an anomaly feature matrix; using the anomaly feature matrix and context information to train an anomaly classification model and an anomaly impact range prediction model, using the anomaly classification model to predict the anomaly type of the current traffic anomaly, and using the anomaly impact range prediction model to predict the impact range of the current traffic anomaly; designing a traffic control strategy for each anomaly type, statistically analyzing the recovery time, recovery quality, and resource consumption of each traffic control strategy in different historical anomaly processing, calculating a strategy historical performance score, and calculating a strategy fitness score for each traffic control strategy based on the anomaly type and impact range of the current traffic anomaly; calculating a strategy benefit based on the strategy historical performance score and the strategy fitness score, calculating a strategy failure risk for each traffic control strategy, and calculating a strategy score for each traffic control strategy for the current traffic anomaly based on the strategy benefit and strategy failure risk, and selecting the traffic control strategy with the highest strategy score as the optimal traffic control strategy. Furthermore, the electronic device may also include a user interface. Figure 3 The architecture shown is only exemplary and can be omitted according to actual needs when implementing different devices. Figure 3 One or more components of an electronic device are shown.
[0149] Example 4
[0150] Figure 4 This is a schematic diagram of the structure of a readable storage medium provided by an embodiment of the present application. Figure 4As shown, it is a readable storage medium according to an embodiment of the present application. Computer-readable instructions are stored on the computer-readable storage medium. When the computer-readable instructions are executed by the processor, a multi-dimensional API gateway flow control method according to an embodiment of the present application described with reference to the above figures can be executed. The storage medium includes, but is not limited to, for example, volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and cache memory (cache). Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc.
[0151] In addition, according to the implementation mode of the present application, the process described in the above reference flowchart can be implemented as a computer software program. For example, the present application provides a non-transitory machine-readable storage medium, the non-transitory machine-readable storage medium stores machine-readable instructions, the machine-readable instructions can be run by a processor to execute instructions corresponding to the method steps provided by the present application, for example: dividing the historical operation cycle into A time periods, collecting the monitoring data of the API gateway and the resource utilization data of the node, collecting the context information when the traffic is abnormal, and generating a first feature set; calculating the feature importance parameter of each feature in the first feature set, taking the features whose feature importance parameter is greater than the feature selection threshold as the key features affecting the traffic anomaly, and generating an abnormal feature matrix; using the abnormal feature matrix and context information to train an abnormal classification model and an abnormal impact range prediction model, and using the abnormal The classification model predicts the anomaly type of the current traffic anomaly, and the anomaly impact range prediction model is used to predict the impact range of the current traffic anomaly; a traffic control strategy is designed for each anomaly type, and the recovery time, recovery quality, and resource consumption of each traffic control strategy in different historical anomaly processing are counted, and the strategy historical performance score is calculated. The strategy fitness score of each traffic control strategy is calculated based on the anomaly type and impact range of the current traffic anomaly; the strategy benefit is calculated based on the strategy historical performance score and the strategy fitness score, and the strategy failure risk of each traffic control strategy is calculated. The strategy score value of each traffic control strategy for the current traffic anomaly is calculated based on the strategy benefit and the strategy failure risk, and the traffic control strategy with the highest strategy score value is used as the optimal traffic control strategy. When the computer program is executed by the central processing unit (CPU), the above functions defined in the method of the present application are executed.
[0152] The methods, apparatus, and devices of the present application may be implemented in many ways. For example, the methods, apparatus, and devices of the present application may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present application are not limited to the order specifically described above unless otherwise specified. In addition, in some embodiments, the present application may also be implemented as programs recorded in a recording medium, which include machine-readable instructions for implementing the methods according to the present application. Therefore, the present application also covers recording media that store programs for executing the methods according to the present application.
[0153] In addition, the parts of the above technical solutions provided in the embodiments of the present application that are consistent with the implementation principles of the corresponding technical solutions in the prior art are not described in detail to avoid excessive redundancy.
[0154] The above-described specific embodiments further illustrate the objectives, technical solutions, and beneficial effects of the present invention. It should be understood that the above description is merely a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A multi-dimensional API gateway traffic control method, characterized in that: include: Divide the historical operation cycle into A time periods, collect monitoring data of the API gateway and resource utilization data of the nodes, collect context information when traffic anomalies occur, and generate a first feature set; Calculate the feature importance parameter of each feature in the first feature set, take the features whose feature importance parameter is greater than the feature selection threshold as the key features affecting the traffic anomaly, and generate an anomaly feature matrix; The anomaly feature matrix and context information are used to train the anomaly classification model and the anomaly impact range prediction model. The anomaly classification model is used to predict the anomaly type of the current traffic anomaly, and the anomaly impact range prediction model is used to predict the impact range of the current traffic anomaly. Design a traffic control strategy for each anomaly type, calculate the recovery time, recovery quality, and resource consumption of each traffic control strategy in handling different historical anomalies, calculate the strategy's historical performance score, and calculate the strategy fitness score of each traffic control strategy based on the anomaly type and impact range of the current traffic anomaly; The strategy benefit is calculated from the strategy historical performance score and the strategy applicability score. The strategy failure risk of each traffic control strategy is calculated. The strategy score of each traffic control strategy for the current traffic anomaly is calculated based on the strategy benefit and strategy failure risk. The traffic control strategy with the highest strategy score is selected as the optimal traffic control strategy. The historical operation cycle is divided into A periods, and the monitoring data of the API gateway and the resource utilization data of the nodes are collected. The context information of traffic anomalies is collected. The specific method for generating the first feature set is as follows: Collect monitoring data of the API gateway during period A during the historical operation cycle, including: number of requests, response time, error rate, and throughput; Collect resource utilization data for each node, including CPU utilization, memory utilization, network utilization, and disk utilization; Identify the time periods with traffic anomalies in A time periods and collect contextual information when the traffic anomalies occur, including: anomaly time, anomaly type, affected nodes, and affected APIs; Anomaly labels are added to periods of traffic anomalies within the historical operation cycle. The anomaly labels include the anomaly time, anomaly type, and impact range of the traffic anomaly. The anomaly type labels include traffic surge, denial of service, and resource exhaustion. The impact range of the traffic anomaly includes API impact and node impact. Feature extraction is performed on the monitoring data, resource utilization data and context information of A time periods to generate a first feature set. The features obtained after feature extraction of the monitoring data, resource utilization data and context information of each time period are samples in the first feature set.
2. A multi-dimensional combined API gateway flow control method as described in claim 1, characterized in that: The method of calculating the feature importance parameter of each feature in the first feature set and taking the features whose feature importance parameter is greater than the feature selection threshold as the key features affecting the traffic anomaly and generating the abnormal feature matrix is as follows: Calculate the feature importance parameter of each feature in the first feature set. The calculation formula is: IG(TZ i ,GZ)=H(GZ)-H(GZ|TZ i ), among which IG(TZ i ,GZ) is the feature importance parameter of the i-th feature, H(GZ) represents the information entropy of the abnormal label, H(GZ|TZ i ) indicates that the feature is TZ i The conditional information entropy of abnormal labels under the condition of; The calculation formula of the information entropy is: H(GZ)=-∑ j p(GZ j )×log2(p(GZ j )), where p(GZ j ) indicates that the exception type label is GZ j The probability of GZ j is the jth category of the abnormal type label; The feature is TZ i The calculation formula of the conditional information entropy of the abnormal label in the case of is: H(GZ|TZ i )=∑p(TZ i =v k )×H(GZ|TZ i =v k ), where p(TZ i =v k ) represents feature TZ i The value is v k The probability of H(GZ|TZ i =v k ) indicates that in feature TZ i The value is v k The conditional information entropy of the abnormal label under the condition of; A feature selection threshold is preset, and features whose feature importance parameters are greater than the feature selection threshold are taken as key features affecting traffic anomalies. N key features affecting traffic anomalies are obtained to form a key feature set; Encode the key features to obtain the key feature code and generate the abnormal feature matrix X GZ =(X1,X2,...,X A ) T , X m =(x m1 ,x m2 ,...,x mn ), m∈{1,2,...,A}, the abnormal feature matrix contains A abnormal feature vectors, where X m is the abnormal feature vector of the mth period, x mn is the nth key feature code in the abnormal feature vector of the mth period, and T is the transpose of the matrix.
3. A multi-dimensional combined API gateway flow control method as described in claim 2, characterized in that: The impact range of the traffic anomaly specifically includes: API impact probability and node impact probability. The dimension of API impact probability is a API , a API Indicates the number of APIs, and the dimension of the node influence probability is a jd , a jd Indicates the number of nodes, and the API impact probability and node impact probability are probability values between 0 and 1.
4. A multi-dimensional combined API gateway flow control method as described in claim 3, characterized in that: The specific method of using the abnormal feature matrix and context information to train the abnormality classification model and the abnormality impact range prediction model, using the abnormality classification model to predict the abnormality type of the current traffic abnormality, and using the abnormality impact range prediction model to predict the impact range of the current traffic abnormality is as follows: The softmax regression model is selected as the initial model for training the abnormal classification model. The input layer of the softmax regression model uses the abnormal feature vector as input data, and the output layer of the softmax regression model uses the one-hot encoding of the abnormal type label as output data. m is added between the input layer and the output layer. yc A fully connected hidden layer uses the ReLU function as the activation function and the softmax function to convert the output data into a probability distribution; Use cross entropy loss as the loss function for the anomaly classification model; Use the Adam optimization algorithm to update the parameters of the anomaly classification model. When the cross entropy loss value is minimized, the training is completed and the trained anomaly classification model is obtained. The multi-label neural network model is selected as the initial model for training the abnormal impact range prediction model. The input layer of the multi-label neural network model uses the abnormal feature vector as input data, and the output layer of the multi-label neural network model uses the impact range of traffic anomalies as output data. n is added between the input layer and the output layer. yc A fully connected hidden layer with ReLU function as activation function; The abnormal feature vector is used as the input of the training data, and the API impact label and node impact label corresponding to the traffic anomaly are used as the output of the training data. The dimension of the API impact label is (A, a API ), the dimension of the node impact label is (A, a jd ), the value of each API impact label or node impact label is 0 or 1, 0 means that the traffic anomaly has no impact on the API or node, and 1 means that the traffic anomaly has an impact on the API or node; Using binary cross entropy loss as the loss function of the abnormal impact range prediction model, the loss function of the abnormal impact range prediction model includes API impact loss and node impact loss; The Adam optimization algorithm is used to minimize the loss function of the abnormal impact range prediction model, and the parameters of the abnormal impact range prediction model are updated. When the loss function of the abnormal impact range prediction model is minimized, the training is completed, and the abnormal impact range prediction model is obtained; Use the trained anomaly classification model to predict the anomaly type of the current traffic anomaly, and use the trained anomaly impact range prediction model to predict the API impact probability and node impact probability.
5. A multi-dimensional combined API gateway flow control method as described in claim 4, characterized in that: The specific method for designing a flow control strategy for each anomaly type, calculating the recovery time, recovery quality, and resource consumption of each flow control strategy in handling different historical anomalies, and calculating the strategy historical performance score, and calculating the strategy fitness score of each flow control strategy based on the anomaly type and impact range of the current flow anomaly, is as follows: According to the characteristics of each abnormal type, a set of flow control strategies are designed for it to obtain a strategy pool. The strategy pool of the jth abnormal type is CL j ={cl j1 ,cl j2 ,...,cl jC }, where cl jC represents the Cth flow control strategy in the strategy pool of the jth anomaly type, where C represents the total number of flow control strategies; The historical exception handling logs are used to collect statistics on the recovery time, recovery quality, and resource consumption of each flow control strategy in historical exception handling. The average recovery time, average recovery quality, and average resource consumption are calculated through weighted average calculation. The maximum recovery time and maximum resource consumption of all flow control strategies in historical exception handling are also obtained. The historical performance score of the traffic control policy is calculated based on the average recovery time, average recovery quality, average resource consumption, maximum recovery time and maximum resource consumption; The calculation method for the strategy's historical performance score is: Among them, HS jc The cth flow control strategy cl for the jth abnormal type jc The historical performance score of the strategy in historical anomaly handling, c∈{1,2,...,C},avg(T jc )、avg(Q jc )、avg(C jc ) are flow control strategies cl jc Average recovery time, average recovery quality, and average resource consumption in historical exception handling, T max 、C max are the maximum recovery time and maximum resource consumption of all flow control strategies in historical exception processing, α1, α2, and α3 are the weight coefficients of recovery time, recovery quality, and resource consumption, respectively, α1+α2+α3=1; The second eigenvector is obtained from the abnormal type and impact range of the current traffic anomaly, and the traffic control strategy cl is obtained. jc For all traffic anomalies processed in historical anomaly processing, the anomaly types and impact ranges are calculated, and the average values of all anomaly types and the average values of the impact ranges of all traffic anomalies are calculated. The average value of the anomaly types and the average value of the impact ranges are used to form an average feature vector. Calculate the feature similarity between the second feature vector and the average feature vector, and use the feature similarity as the flow control strategy cl jc The strategy suitability score for the current traffic anomaly; The calculation formula for the strategy suitability score is: AS jc =sim(FV now ,FV jc,hst ), where FV now is the second eigenvector of the current traffic anomaly, FV jc,hst The flow control policy cl jc The average feature vector of all exceptions processed in historical exception processing, sim(·) is the similarity function, AS jc The flow control policy cl jc The policy suitability score for the current traffic anomaly.
6. A multi-dimensional combined API gateway flow control method as described in claim 5, characterized in that: The specific method of calculating the policy benefit from the policy historical performance score and the policy applicability score, calculating the policy failure risk of each flow control policy, and calculating the policy score of each flow control policy for the current flow anomaly based on the policy benefit and the policy failure risk, and taking the flow control policy with the highest policy score as the optimal flow control policy is as follows: The strategy return is calculated based on the strategy historical performance score and the strategy suitability score. The calculation formula for the strategy return is: SY jc =β HS ×HS jc +β AS ×AS jc , where β HS , β AS are the weight coefficients of strategy historical performance score and strategy applicability score, β HS +β AS =1; By using historical exception handling logs, we can count the number of failures and total execution times of each traffic control policy in historical exception handling, and calculate the policy failure risk: The calculation method of the strategy failure risk is: Among them, N fail,jc The flow control policy cl jc Number of failures in historical exception handling, N total,jc The flow control policy cl jc Total number of executions in historical exception handling; The flow control strategy cl is calculated by the strategy benefit and strategy failure risk jc The strategy score value of The calculation formula of the strategy score value is: Score jc =SY jc -RP×FX jc , where RP is the risk penalty coefficient; Calculate the policy scores of all traffic control policies, select the traffic control policy with the highest policy score as the optimal traffic control policy, and execute the optimal traffic control policy to process and recover the current traffic anomaly.
7. A multi-dimensional API gateway traffic control system, which is used to implement a multi-dimensional API gateway traffic control method based on any one of claims 1-6, characterized in that: include: A first feature set generation module is used to divide the historical operation cycle into A time periods, collect monitoring data of the API gateway and resource utilization data of the node, collect context information when traffic anomalies occur, and generate a first feature set; An abnormal feature matrix generation module is used to calculate the feature importance parameter of each feature in the first feature set, and take the features whose feature importance parameters are greater than the feature selection threshold as key features affecting traffic anomalies to generate an abnormal feature matrix; The type and impact range prediction module is used to train the anomaly classification model and the anomaly impact range prediction model using the anomaly feature matrix and context information, and use the anomaly classification model to predict the anomaly type of the current traffic anomaly and use the anomaly impact range prediction model to predict the impact range of the current traffic anomaly; The traffic control policy evaluation module is used to design a traffic control policy for each anomaly type, calculate the recovery time, recovery quality, and resource consumption of each traffic control policy in handling different historical anomalies, calculate the policy's historical performance score, and calculate the policy fitness score of each traffic control policy based on the anomaly type and impact range of the current traffic anomaly; The optimal control strategy screening module is used to calculate the strategy benefit based on the strategy historical performance score and the strategy applicability score, calculate the strategy failure risk of each flow control strategy, and calculate the strategy score value of each flow control strategy for the current flow anomaly based on the strategy benefit and strategy failure risk. The flow control strategy with the highest strategy score value is selected as the optimal flow control strategy.
8. An electronic device, characterized in that: It includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps in the multi-dimensional combined API gateway traffic control method as described in any one of claims 1 to 6.
9. A readable storage medium, characterized in that: The readable storage medium stores a computer program, which is suitable for loading by a processor to execute the steps in a multi-dimensional combined API gateway traffic control method as described in any one of claims 1-6.
Citation Information
Patent Citations
A multi-dimensional centralized flow control method and system
CN111107012B
Network traffic processing method and device, storage medium and electronic equipment
CN117424737A
Abnormal network traffic monitoring method, device and equipment based on deep learning and readable storage medium
CN118041661A