Transform-based gateway access threshold dynamic adjustment method and device

By applying the Transformer model in the service gateway for host load prediction and dynamic threshold adjustment, the problems of complex and inaccurate traditional fixed threshold settings are solved, and the utilization rate of host resource and service reliability are improved.

CN120050334AInactive Publication Date: 2025-05-27YUNNAN PROVINCIAL BIG DATA CO LTD

Patent Information

Application Number
CN202510520335.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2025-05-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Traditional service gateways use fixed thresholds for traffic control, resulting in complex pre-evaluation threshold setting, inaccurate setting of fixed thresholds, difficult to adapt to rapidly changing service scenarios, resulting in low host resource utilization.

Method used

The dynamic adjustment method of gateway access threshold based on Transformer is adopted. By obtaining the host's running status historical data, the impact of each data dimension on the host's load is analyzed. The input vector is self-masked training using the Transformer model to predict the load indicators of the next time period, and the traffic load threshold of the gateway host is dynamically adjusted according to the prediction results.

Benefits of technology

It improves the accuracy of host load threshold evaluation, enhances the system's adaptability, can better adapt to rapidly changing load scenarios, and improves host resource utilization and service reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120050334A_ABST
    Figure CN120050334A_ABST
Patent Text Reader

Abstract

The invention relates to a gateway access threshold dynamic adjustment method and device based on Transform, and belongs to the technical field of information. Comprising the following steps: analyzing the influence condition of each data dimension on a host load, and selecting the dimension with large influence as a host load index; carrying out discretization, vectorization and position coding on the load index value sequence of the continuous time slice to convert the load index value sequence into an input vector; performing self-mask training on the input vector by using a Transform model to obtain a prediction model; predicting according to the real-time index value of the host by using a prediction model to obtain a predicted load index of the next time period; and comparing the predicted load index result with a preset load target value, and adjusting a flow load threshold value of the gateway host according to a comparison result. The invention mainly solves the problems that the threshold setting is not accurate enough and the fixed threshold is difficult to adapt to a rapidly changing service scene because the traditional gateway load threshold is a fixed pre-estimated value, and improves the utilization rate of host resources.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method and device for dynamically adjusting the gateway access threshold based on Transformer, and belongs to the field of information technology. Background Art

[0002] With the rapid development and application promotion of information technology, the systems and services in an IT domain have become increasingly complex. The data interaction and access between various business systems have become more frequent and diverse, and microservice architectures are increasingly used in information systems for service interconnection. A service gateway is a key component in the microservice architecture. As the entry point of the system, it is responsible for managing and controlling access to backend microservices. Load balancing is an important function and role of the service gateway. The service gateway provides load balancing among multiple service instances to ensure that no single instance is overloaded, which is crucial for ensuring the health and performance of the system. The service gateway prevents service instance overload by rate-limiting service requests and distributing rule policies.

[0003] Traditional service gateways mainly use a fixed threshold setting method for rate-limiting and load control of service instances. For hosts with different resources, a fixed threshold is set. When the threshold is exceeded, the service gateway restricts or forwards new access requests. The problems of traditional traffic limiting are as follows: 1) Using the traditional load flow control method, it is necessary to comprehensively evaluate the performance of each host in advance and set a fixed threshold. To ensure that the host can continuously provide services, this threshold is often set too small, resulting in the underutilization of host performance; 2) Different services consume different amounts of host resources, and it is difficult to give full play to the overall performance of the system by setting a fixed threshold; 3) In the current microservice architecture, the number of service instances and service capabilities change relatively frequently, and it is difficult to quickly adapt to the current service rapid update and release application scenarios by setting a fixed threshold. Therefore, the method in the present invention innovatively introduces a Transformer data prediction model to predict and evaluate the host load, guiding the service gateway to adjust the real-time dynamic access volume according to the host load, thereby improving the accuracy of host load threshold evaluation and the utilization rate of host resources. Summary of the Invention

[0004] The technical problem to be solved by the present invention is: The present invention provides a method and device for dynamically adjusting the gateway access threshold based on Transformer, which solves the problems that the traditional service gateway uses a fixed threshold to implement traffic control access, resulting in complex pre-evaluation threshold setting work, inaccurate fixed threshold setting, and difficult adaptation to rapidly changing service scenarios, causing low utilization rate of host resources.

[0005] The technical solution of the present invention is: A method for dynamically adjusting the gateway access threshold based on Transformer, the method comprising:

[0006] Step1. Obtain the historical data of the host running status, analyze the impact of each data dimension on the host load, and select the dimension with a large impact as the host load indicator;

[0007] Step2. Convert the sequence of load indicator values in continuous time segments into input vectors through discretization, vectorization, and positional encoding;

[0008] Step3. Use the Transformer model to perform self-masking training on the input vectors to obtain a prediction model;

[0009] Step4. Use the prediction model to make predictions based on the real-time indicator values of the host to obtain the predicted load indicator for the next time period;

[0010] Step5. Compare the predicted load indicator results with the preset load target value, and adjust the traffic load threshold of the gateway host according to the comparison results.

[0011] Furthermore, the Step1 includes:

[0012] Step1.1. Set a fixed sampling time interval , and regularly collect the characteristic numerical values of the host running status according to the sampling time interval;

[0013] Step1.2. Select the characteristics that are highly correlated with the host running load as the load indicators. The load indicators include CPU occupancy rate, memory usage rate, number of requests, number of database connections, number of threads, number of cache connections, and average number of bytes per request;

[0014] Step1.3. Set the maximum length of a single batch sequence , and extract consecutive load indicator data to form a sequence of load indicator values arranged in chronological order.

[0015] Furthermore, the Step2 includes:

[0016] Step2.1. Discretize the indicator values: Divide each indicator value into discrete data and continuous data; for discrete data, directly convert it into an enumeration value, where 0 is not used as an enumeration value; for continuous data, use different conversion methods to convert the continuous data into discrete data, and then convert the discrete data into an enumeration value, where each enumeration value represents a numerical interval, and each numerical interval is represented by an enumeration value;

[0017] Step2.2. Initialize the enumeration space of indicator values according to the numerical distribution interval of each dimension of the load indicator value sequence. The number of classification categories of the prediction model is expressed as:

[0018] ;

[0019] Among them, is the number of dimensions, is the number of discrete value enumerations of the -th dimension, is the number of classification categories of the prediction model;

[0020] Convert the load metric value sequence into an index value in the enumeration space , and the calculation formula for the index value in the enumeration space is:

[0021] );

[0022] Among them, is the number of dimensions, is the discrete value of the -th dimension, is the index value offset of the -th dimension. When , , when , ;

[0023] Step2.3. Use the Embedding layer to encode the index value into a one-dimensional vector, called the word vector , and the dimension of the word vector is ;

[0024] Step2.4. Use the position of the word vector in the sequence to encode, and the dimension of the word position vector is , obtaining the word position vector :

[0025] The word position vector consists of sine encoding and cosine encoding. Sine encoding is used for even positions, and cosine encoding is used for odd positions. For each position of the word vector in the sequence and each dimension , from 0 to , calculate the values of the sine and cosine functions. The calculation formulas for the values of the sine and cosine functions are:

[0026] ;

[0027] ;

[0028] Among them is the position index, is the feature dimension of the word vector;

[0029] Concatenate the sine encoding and cosine encoding by dimension to form a word position vector of length . The formula for calculating the word position vector is:

[0030] ;

[0031] Step2.5. Use the word vector and add it to the word position vector to obtain the input vector . Its calculation method is:

[0032] .

[0033] Further, in the Step2.1, the method for converting continuous data into discrete data includes:

[0034] One-hot encoding: applicable to categorical features, mapping each category to a one-hot vector, where only one element is 1 and the rest are 0;

[0035] K-means clustering encoding: using the K-means clustering algorithm to cluster continuous data into K clusters, and then encoding each data point as its cluster number;

[0036] Equal-frequency binning encoding: dividing continuous data into several bins or categories according to frequency;

[0037] Equal-width binning encoding: dividing continuous data into several bins or categories according to the numerical range.

[0038] Further, the Step3 includes:

[0039] Step3.1. Generate a two-dimensional vector according to the input vector with a sequence length of . For each row in the vector, when the row number is , set the elements at positions 0 to of this row to 1, and set the elements at positions to to invalid values to generate the training position mask vector;

[0040] Step3.2. Use the cross-entropy loss as the Transformer model optimizer during the training process of the Transformer model. The output result of the prediction model Transformer model is a vector of length , and the actual value is an Ont-hot encoding vector of length ​ , where there is only one element , and the remaining values , then is the model output vector in the one corresponding to the actual value , and the cross-entropy loss is calculated as follows:

[0041] ;

[0042] Step3.3. Set the maximum number of training iterations , and randomly select consecutive sampling data from a random position in the historical data for each iteration of training, process it into an input vector, and use the input vector and the position mask vector to train the Transformer model until the number of iterations reaches , end the training process, and obtain the prediction model

[0043] Furthermore, the said Step4 includes:

[0044] Step4.1. Take the sampling values of consecutive time segments from the current moment onwards and process them into an input vector

[0045] Step4.2. Use the prediction model to predict the input vector to obtain an output vector, use the layer to map the output vector to the vocabulary dimension, and then use the layer to convert the output vector into the probability of each index in the vocabulary, and select the position with the maximum probability as the prediction result

[0046] Step4.3. The prediction result is the search space index value, query the vocabulary, and obtain the range of each predicted load index

[0047] Furthermore, the said Step5 includes:

[0048] Step5.1. Set the target values of each index and compare the difference between the predicted load index result and the target value

[0049] Step5.2. If the predicted load index result is less than the target value, adjust the gateway to increase the host load threshold; if the predicted load index result is greater than the target value, adjust the gateway to decrease the host load threshold; in other cases, keep the gateway load threshold unchanged

[0050] The present invention also provides a dynamic adjustment device for the gateway access threshold based on Transformer, and the device includes: a module for executing the above-mentioned dynamic adjustment method for the gateway access threshold based on Transformer

[0051] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the above-mentioned method for dynamically adjusting the gateway access threshold based on Transformer is implemented.

[0052] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned method for dynamically adjusting the gateway access threshold based on Transformer is implemented.

[0053] The beneficial effects of the present invention are as follows:

[0054] Based on the Transformer model, the present invention predicts the operating state of the host and dynamically adjusts the service gateway load threshold according to the real-time operating state of the host. On the one hand, it reduces the complexity of the load threshold evaluation work, enabling the system to adapt to rapidly changing load scenarios. On the other hand, the dynamically adjusted load threshold can improve the utilization rate of host resources and service reliability. Description of the Drawings

[0055] Figure 1 It is a schematic diagram of the overall process of the method for dynamically adjusting the gateway access threshold based on Transformer provided by an embodiment of the present invention;

[0056] Figure 2 It is a data processing flow chart of the method for dynamically adjusting the gateway access threshold based on Transformer provided by an embodiment of the present invention;

[0057] Figure 3 It is a model structure diagram of the method for dynamically adjusting the gateway access threshold based on Transformer provided by an embodiment of the present invention;

[0058] Figure 4 It is a structural block diagram of the method for dynamically adjusting the gateway access threshold based on Transformer provided by an embodiment of the present invention;

[0059] Figure 5 It is a distribution diagram of sampled data sample data provided by an embodiment of the present invention. Detailed Embodiments

[0060] To better understand the above technical solution, the exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a clearer and more thorough understanding of the present invention and to fully convey the scope of the present invention to those skilled in the art.

[0061] Embodiment 1: As Figures 1 - 5 shown, a method for dynamically adjusting the gateway access threshold based on Transformer, the method comprising:

[0062] Step1. Obtain the historical data of the host operation status, analyze the influence of each data dimension on the host load, and select the dimension with a large influence as the host load indicator;

[0063] Further, the Step1 includes:

[0064] Step1.1. Set a fixed sampling time interval , and the sampling time interval is 5 minutes, and regularly collect the characteristic numerical values of the host operation status according to the sampling time interval;

[0065] Step1.2. Select the characteristics that are highly correlated with the host operation load as the load indicators, and the load indicators include CPU occupancy rate, memory usage rate, number of requests, number of database connections, number of threads, number of cache connections, average number of bytes per request, etc.;

[0066] Specifically, according to the sampling data, identify and sort out the existing operation and maintenance monitoring indicators in the current system, and a total of the following 20 indicators are selected as the analysis samples. All indicators are continuous data, and the specific performance indicators and sample statistical data are shown in the following table:

[0067] Table 1 shows the performance indicators and sample statistical data

[0068]

[0069] Step1.3. Set the maximum length of a single batch sequence to 1000, and extract 1000 consecutive load indicator data to form a sequence of load indicator values arranged in chronological order.

[0070] Step2. Convert the sequence of load indicator values of consecutive time segments into an input vector through discretization, vectorization, and positional encoding;

[0071] Further, the Step2 includes:

[0072] Step 2.1. Discretize the metric values: Divide each metric value into discrete and continuous data; for discrete data, directly convert it into an enumerated value, where 0 is not used as an enumerated value; for continuous data, use different conversion methods to convert the continuous data into discrete data and then convert the discrete data into an enumerated value, where each enumerated value represents a numerical range and each numerical range is represented by an enumerated value.

[0073] Further, in the Step 2.1, the methods for converting continuous data into discrete data include:

[0074] One-hot encoding: Applicable to categorical features, map each category to a one-hot vector, where only one element is 1 and the rest are 0.

[0075] K-means clustering encoding: Use the K-means clustering algorithm to cluster continuous data into K clusters, and then encode each data point as its cluster number; this method is applicable when the data has a certain clustering structure and can convert continuous variables into discrete variables.

[0076] Equal Frequency Binning: Divide continuous data into several bins or categories according to frequency; each bin contains approximately the same number of data points, which can reduce the impact of outliers, but may result in a small number of data points in some bins.

[0077] Equal Width Binning: Divide continuous data into several bins or categories according to the numerical range, and each bin has an equal numerical range, which is applicable to the case where the data distribution is relatively uniform.

[0078] Computers use binary for data processing. To improve data encoding and decoding efficiency, continuous data is generally divided into categories for easy conversion and calculation.

[0079] Plot the data distribution diagrams of each metric, select a suitable algorithm for converting continuous data into discrete data according to the data distribution law. The sampled data sample data distribution diagram is as Figure 5 shown:

[0080] According to the data distribution of each feature and the importance of the data values, select a suitable data discretization encoding method. The conversion methods selected for each feature in this embodiment are shown in Table 2:

[0081] Table 2 is the description of the conversion method for features

[0082]

[0083] Using each feature data encoding method, convert each monitoring metric from continuous data to discrete data. For example, when the disk read / write rate is 236 MB / S, it is classified as busy according to cluster analysis and encoded as 15. When the CPU utilization rate is 75%, it is classified according to equal-width binning and encoded as 13. For a single piece of data as shown in the following table:

[0084] Table 3 shows a single piece of data for each feature

[0085]

[0086] After conversion to discrete data according to the data conversion rules:

[0087]

[0088] Step2.2. Initialize the metric value enumeration space and the number of classification categories of the prediction model according to the numerical distribution interval of each dimension of the load metric value sequence Expressed as:

[0089] ;

[0090] Among them, is the number of dimensions, is the th discrete value enumeration quantity of the th dimension, and

[0091] is the number of classification categories of the prediction model; Convert the load metric value sequence to an index value within the enumeration space

[0092] );

[0093] Among them, is the number of dimensions, is the th discrete value of the th dimension, is the index value offset of the th dimension. When ;

[0094]

[0094] Specifically, convert the discrete value sequence to a vocabulary index. Since each metric is split into 16 discrete values, the index value of the sequence conversion is:

[0095]

[0096] Step2.3. Use the Embedding layer to convert the index value Encoded as a one-dimensional vector, called a word vector , the dimension of the word vector is ;

[0097] Use word embedding to encode the sequence of index values, converting discrete symbols (such as words or characters in a vocabulary) into continuous vector representations, denoted as , such as:

[0098]

[0099] Step2.4. Use the position of the word vector in the sequence for encoding, the dimension of the word position vector is , to obtain the word position vector :

[0100] According to the maximum length of the sequence , generate a sequence composed of positions in order, such as When, initialize the position vector as:

[0101]

[0102] For each position , generate a word position vector of length , the word position vector consists of sine encoding and cosine encoding. Sine encoding is used for even positions and cosine encoding is used for odd positions. For each position of the word vector in the sequence and each dimension , from 0 to , calculate the values of the sine and cosine functions. The calculation formulas for the values of the sine and cosine functions are:

[0103] ;

[0104] ;

[0105] where is the position index, is the feature dimension of the word vector;

[0106] Concatenate the sine encoding and cosine encoding by dimension to form a word position vector of length . The calculation formula for the word position vector is:

[0107] ;

[0108] Such as the above position vector after encoding is:

[0109] [[0.0000e+00,1.0000e+00,0.0000e+00,1.0000e+00,0.0000e+00,1.0000e+00,0.0000e+00,1.0000e+00],[8.4147e-01,5.4030e-01,9.9833e-02,9.9500e-01,9.9998e-03,9.9995e-01,1.0000e-03,1.0000e+00],[9.0930e-01,-4.1615e-01,1.9867e-01,9.8007e-01,1.9999e-02,9.9980e-01,2.0000e-03,1.0000e+00],[1.4112e-01,-9.8999e-01,2.9552e-01,9.5534e-01,2.9995e-02,9.9955e-01,3.0000e-03,1.0000e+00],[-7.5680e-01,-6.5364e-01,3.8942e-01,9.2106e-01,3.9989e-02,9.9920e-01,4.0000e-03,9.9999e-01]]

[0110] Step2.5: Use the word vector and the word position vector to add up to obtain the input vector , and its calculation method is:

[0111] .

[0112] Step3: Use the Transformer model to perform self-masking training on the input vector to obtain the prediction model;

[0113] Furthermore, the said Step3 includes:

[0114] Step3.1: Generate a two-dimensional vector according to the input vector with a sequence length of . For each row in the vector, when the row number is , set the elements at positions 0 to in this row to 1, and set the elements at positions to to invalid values to generate the training position mask vector;

[0115] When the input sequence length is less than the maximum sequence length , use the null value 0 to pad the sequence length to , for example, when Pad to , for the padded data, a mask needs to be set. The mask rule is to initialize a vector of length , and each value is set according to the sequence validity. When the sequence position data is valid, use the value 0. When the sequence position data is invalid, use value. For example the mask vector is ;

[0116] During model training, the training set and the validation set are the same data. To ensure the effectiveness of model training, the validation set needs to be masked. When predicting the th value, mask all the data after . The mask generation method is to create a two-dimensional vector of size , where each position in the vector represents the visibility of the th position to other positions. For example when the mask matrix is:

[0117] [[0., -inf, -inf, -inf, -inf],

[0118] [0., 0., -inf, -inf, -inf],

[0119] [0., 0., 0., -inf, -inf],

[0120] [0., 0., 0., 0., -inf],

[0121] [0., 0., 0., 0., 0.]]

[0122] Step3.2. The cross-entropy loss is used during the training process of the Transformer model as the optimizer of the Transformer model. The output result of the prediction model Transformer model is a vector of length , and the actual value is a one-hot encoded vector of length , where only one element is 1, and the rest of the values are 0. Then is the element in the model output vector corresponding to the actual value . The calculation formula of the cross-entropy loss is: ; ;

[0123] ;

[0124] Step 3.3. Set the maximum number of training iterations , and for each iteration of training, randomly select consecutive sampling data from a random position in the historical data and process it into an input vector. Use the input vector and the position mask vector to train the Transformer model until the number of iterations reaches , end the training process, and obtain the prediction model.

[0125] Step 4. Use the prediction model to make predictions based on the real-time metric values of the host to obtain the predicted load metrics for the next time period;

[0126] Furthermore, Step 4 includes:

[0127] Step 4.1. Take the sampling values of consecutive time segments starting from the current moment and process them into an input vector;

[0128] Step 4.2. Use the prediction model to make predictions on the input vector to obtain an output vector. Use the layer to map the output vector to the vocabulary dimension, and then use the layer to convert the output vector into the probability of each index in the vocabulary. Select the position with the highest probability as the prediction result;

[0129] The prediction result vector is a second-order tensor. Each row in the tensor represents the prediction classification of a single sequence. Use the layer to map the prediction classification to the vocabulary dimension, and then use the layer to convert the correlation degree values of each dimension into classification probabilities; each column in the processed vector represents a classification result, and the values in each row represent the probability of that classification. Take the column number where the value is the largest as the index value of the category to which this indicator belongs;

[0130] Step 4.3. The prediction result is the search space index value. Query the vocabulary to obtain the range of each predicted load metric.

[0131] For example, if the index value 466389 is converted to the sequence value , query the vocabulary to learn that the data prediction result is:

[0132] Table 4 shows the data prediction results

[0133]

[0134] Step 5. Compare the predicted load metric results with the preset load target values, and adjust the traffic load threshold of the gateway host according to the comparison results.

[0135] Further, the Step5 includes:

[0136] Step5.1. Set the target values of each index, and compare the difference between the predicted load index result and the target value. Set the target value of CPU utilization rate to 70%, and the memory utilization rate to 50%. In this embodiment, the CPU utilization rate meets the target requirement.

[0137] Step5.2. If the predicted load index result is less than the target value, adjust the gateway to increase the host load threshold; if the predicted load index result is greater than the target value, adjust the gateway to decrease the host load threshold; in other cases, keep the gateway load threshold unchanged.

[0138] The host load has reached the requirement, and the gateway load threshold remains unchanged.

[0139] The implementation effect is:

[0140] Table 5 shows the average accuracy rate for predicting the Nth time period.

[0141]

[0142] Through the statistical analysis of the prediction results of the host status using the above method, the average accuracy rate of predicting the next time period is 75.36% after using the Transformer model, which meets the daily dynamic threshold adjustment requirements.

[0143] The present invention also provides a dynamic adjustment device for the gateway access threshold based on Transformer. The device includes:

[0144] A host load index selection module, which is used to obtain the historical data of the host operation status, analyze the influence of each data dimension on the host load, and select the dimension with a large influence as the host load index.

[0145] An input vector conversion module, which is used to convert the load index value sequence of continuous time segments into an input vector through discretization, vectorization, and position encoding.

[0146] A prediction model training module, which is used to perform self-masking training on the input vector using the Transformer model to obtain a prediction model.

[0147] A load index prediction module, which is used to use the prediction model to predict according to the real-time index value of the host to obtain the predicted load index for the next time period.

[0148] A load threshold adjustment module, which is used to compare the predicted load index result with the preset load target value, and adjust the traffic load threshold of the gateway host according to the comparison result.

[0149] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the above-mentioned method for dynamically adjusting the gateway access threshold based on Transformer is implemented.

[0150] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned method for dynamically adjusting the gateway access threshold based on Transformer is implemented.

[0151] Since the system / device described in the above embodiments of the present invention is the system / device adopted for implementing the method in the above embodiments of the present invention, based on the method described in the above embodiments of the present invention, those skilled in the art can understand the specific structure and variations of the system / device, and thus will not be elaborated herein. Any system / device adopted for the method in the above embodiments of the present invention falls within the scope of protection of the present invention.

[0152] Those skilled in the art should understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program codes.

[0153] The present invention is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be realized by computer program instructions.

[0154] It should be noted that in the claims, any reference signs placed between parentheses shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The present invention can be implemented by means of hardware including several different components and by means of a suitably programmed computer. In the claims listing several devices, several of these devices can be embodied by the same piece of hardware. The use of the words first, second, third, etc. is only for convenience of expression and does not denote any order. These words can be understood as part of the component name.

[0155] In addition, it should be noted that in the description of this specification, the descriptions of terms such as "one embodiment", "some embodiments", "embodiment", "example", "specific example" or "some examples" mean that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic descriptions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.

[0156] Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications to these embodiments after learning the basic creative concepts. Therefore, the claims should be construed to include the preferred embodiments as well as all changes and modifications falling within the scope of the present invention.

Claims

1. A gateway access threshold dynamic adjustment method based on Transformer, characterized in that: The method comprises: Step 1: Obtain historical data on the host's operating status, analyze the impact of each data dimension on the host load, and select the dimension with the greatest impact as the host load indicator; Step 2: The load index value sequence of the continuous time segment is converted into an input vector through discretization, vectorization, and position encoding; Step 3: Use the Transformer model to perform self-masking training on the input vector to obtain a prediction model; Step 4: Use the prediction model to predict the real-time index value of the host and obtain the predicted load index for the next time period; Step 5. Compare the predicted load index results with the preset load target value, and adjust the traffic load threshold of the gateway host according to the comparison results.

2. The method for dynamically adjusting gateway access threshold based on Transformer according to claim 1, characterized in that: The Step 1 includes: Step 1.1, set a fixed sampling time interval , regularly collect host operation status characteristic values ​​according to sampling time intervals; Step 1.2, select the features that are most closely related to the host operation load as load indicators, which include CPU usage, memory usage, number of requests, number of database connections, number of threads, number of cache connections, and average number of bytes requested; Step 1.

3. Set the maximum length of a single batch sequence , extract continuous The load index data are combined into a load index value sequence arranged in chronological order.

3. The method for dynamically adjusting gateway access threshold based on Transformer according to claim 1, characterized in that: The Step 2 includes: Step 2.

1. Discretize the indicator value: divide each indicator value into discrete data and continuous data; for discrete data, directly convert it into enumeration value, where 0 is not used as the enumeration value; for continuous data, use different conversion methods to convert continuous data into discrete data, and then convert discrete data into enumeration value, where each enumeration value represents a numerical interval, and each numerical interval is represented by an enumeration value; Step 2.2: Initialize the index value enumeration space according to the numerical distribution interval of each dimension of the load index value sequence, and predict the number of classification categories of the model It is expressed as: ; in, is the number of dimensions, For the The number of discrete value enumerations for each dimension, The number of classification categories for the prediction model; Converts a sequence of load indicator values ​​to index values ​​in the enumeration space , the index value calculation formula in the enumeration space is: ); in, is the number of dimensions, For the Discrete values ​​of dimensions, For the The index value offset of the dimension. hour, ,when hour, ; Step 2.3, use the Embedding layer to index the value Encoded into a one-dimensional vector, called a word vector , the word vector dimension is ; Step 2.4: Use the position of the word vector in the sequence Encode, the word position vector dimension is , get the word position vector : The word position vector is composed of sine coding and cosine coding. Sine coding is used for even positions and cosine coding is used for odd positions. For each word vector position in the sequence and each dimension , From 0 to , calculate the values ​​of sine and cosine functions. The calculation formula for the values ​​of sine and cosine functions is: ; ; in is the position index, is the word vector feature dimension; The sine code and cosine code are concatenated by dimension to form a length of The word position vector of , the word position vector calculation formula is: ; Step 2.5: Use word vectors With word position vector Add the input vector , which is calculated as: 。 4. The method for dynamically adjusting gateway access threshold based on Transformer according to claim 1, characterized in that: In the Step 2.1, the method of converting continuous data into discrete data includes: One-hot encoding: Applicable to categorical features, mapping each category into a one-hot vector, where only one element is 1 and the rest are 0; K-means clustering encoding: Use the K-means clustering algorithm to cluster continuous data into K clusters, and then encode each data point as the cluster number to which it belongs; Equal frequency bucket coding: divide continuous data into several buckets or categories according to frequency; Equal-width bucket encoding: Divide continuous data into several buckets or categories according to the numerical range.

5. The method for dynamically adjusting gateway access threshold based on Transformer according to claim 1, characterized in that: The Step 3 includes: Step 3.1, according to the sequence length The input vector is generated A two-dimensional vector. For each row in the vector, when the row number is When the row from 0 to The element at position is set to 1, To The elements of the position are set to invalid values ​​to generate a training position mask vector; Step 3.2: Transformer model training process uses cross entropy loss As a Transformer model optimizer, the prediction model Transformer model output is a length of Vector The actual value is length The Ont-hot encoding vector , which has only one element , the remaining values ,but Output vector for the model Average and actual value Corresponding elements, cross entropy loss The calculation formula is: ; Step 3.

3. Set the maximum number of training iterations , each iteration of the training process starts from a random position in the historical data and extracts continuous The sample data is processed into an input vector, using the input vector and the position mask The vector trains the Transformer model until the number of iterations reaches , the training process ends and the prediction model is obtained.

6. The method for dynamically adjusting gateway access threshold based on Transformer according to claim 1, characterized in that: The Step 4 includes: Step 4.

1. Take continuous The sampled values ​​of time segments are processed as input vectors; Step 4.2, use the prediction model to predict the input vector and get the output vector. The layer maps the output vector to the vocabulary dimension and then uses The layer converts the output vector into the probability of each index in the vocabulary, and selects the position with the largest probability as the prediction result; Step 4.3: The prediction result is the search space index value. The vocabulary is queried to obtain the range of each predicted load indicator.

7. The method for dynamically adjusting gateway access threshold based on Transformer according to claim 1, characterized in that: The Step 5 includes: Step 5.

1. Set the target value of each indicator and compare the difference between the predicted load indicator result and the target value; Step 5.2: If the predicted load index result is less than the target value, adjust the gateway to increase the host load threshold; if the predicted load index result is greater than the target value, adjust the gateway to reduce the host load threshold; in other cases, keep the gateway load threshold unchanged.

8. A gateway access threshold dynamic adjustment device based on Transformer, characterized in that: The device comprises: a module for executing the Transformer-based gateway access threshold dynamic adjustment method according to any one of claims 1 to 7.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the gateway access threshold dynamic adjustment method based on Transformer is implemented as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for dynamically adjusting a gateway access threshold based on Transformer as claimed in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Distributed system service scheduling optimization method and device, equipment and medium

    CN118590549A

  • Systems and Methods for Real-Time Forecasting and Predicting of Electrical Peaks and Managing the Energy, Health, Reliability, and Performance of Electrical Power Systems Based on an Artificial Adaptive Neural Network

    US20160247065A1

  • Method and apparatus for text sentiment recognition, computer storage medium, and electronic device

    WO2025077885A1

Cited By

  • Qos regulation and control method, device and equipment for log input size threshold

    CN121277439A