Gateway traffic prediction method and device, electronic equipment and storage medium

By categorizing and predicting gateway traffic using machine learning models, the method addresses the lack of precision in existing traffic prediction methods, allowing for precise and efficient traffic management and rapid response to anomalies.

CN120321067APending Publication Date: 2025-07-15HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410021450.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-05
Publication Date
2025-07-15

AI Technical Summary

Technical Problem

In the prior art, the global traffic prediction method of the gateway cannot achieve refined and targeted control, especially in high concurrency scenarios, it is difficult to meet the user's traffic management needs.

Method used

By obtaining the historical traffic data of multiple APIs of the gateway, the traffic prediction strategy of each API is determined, and using machine learning models such as XgBoost and sliding averaging algorithm, traffic prediction for each API is separately obtained to obtain the traffic prediction results of the API and the gateway.

Benefits of technology

It realizes refined current limiting configurations for multiple APIs, which can quickly locate the source of abnormal traffic, avoid the impact on other API services, and improve the availability and stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120321067A_ABST
    Figure CN120321067A_ABST
Patent Text Reader

Abstract

The invention provides a gateway traffic prediction method and device, electronic equipment and a storage medium, and relates to the technical field of cloud computing, and the method comprises the steps: firstly, obtaining historical traffic data of a plurality of application programming interfaces (APIs) of a gateway; then, according to the historical traffic data of the plurality of APIs, determining traffic prediction strategies respectively corresponding to the plurality of APIs; and finally, performing traffic prediction on the plurality of APIs by using the traffic prediction strategies corresponding to the plurality of APIs to obtain traffic prediction results corresponding to the plurality of APIs and a traffic prediction result of the gateway. In the embodiment of the invention, the flow prediction is carried out on the plurality of APIs of the gateway respectively, so that the flow limiting configuration can be carried out on the plurality of APIs respectively. Moreover, when abnormal traffic occurs, refined and targeted traffic control can be realized, so that the availability and stability of the system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud computing technology, and particularly to a method, device, electronic device, and storage medium for gateway traffic prediction. Background Art

[0002] On a proprietary cloud operation and maintenance platform, the gateway adopts a global traffic upper limit restriction strategy. By predicting the global traffic of the gateway, the upper limit of the gateway's global traffic is set for traffic control. When the received traffic exceeds the set upper limit, subsequent requests will be rejected to control the Query Per Second (QPS) of the gateway. This solution can effectively avoid the situation where the server crashes due to excessive request volume at the gateway.

[0003] However, since the method of predicting the global traffic of the gateway cannot achieve fine-grained control, it cannot meet the refined and targeted control requirements of users when dealing with traffic management in high-concurrency scenarios. Summary of the Invention

[0004] Embodiments of this application provide a method, device, electronic device, and storage medium for gateway traffic prediction to solve the problem that the method of predicting the global traffic of the gateway cannot meet the refined and targeted control requirements.

[0005] In a first aspect, embodiments of this application provide a method for gateway traffic prediction. The method includes: obtaining historical traffic data of multiple Application Programming Interfaces (APIs) of the gateway; determining traffic prediction strategies respectively corresponding to the multiple APIs according to the historical traffic data of the multiple APIs; and using the traffic prediction strategies respectively corresponding to the multiple APIs to perform traffic prediction on the multiple APIs respectively, so as to obtain traffic prediction results respectively corresponding to the multiple APIs and a traffic prediction result of the gateway.

[0006] In a second aspect, embodiments of this application provide a device for gateway traffic prediction. The device includes: an obtaining module, configured to obtain historical traffic data of multiple Application Programming Interfaces (APIs) of the gateway; a determining module, configured to determine traffic prediction strategies respectively corresponding to the multiple APIs according to the historical traffic data of the multiple APIs; and a predicting module, configured to use the traffic prediction strategies respectively corresponding to the multiple APIs to perform traffic prediction on the multiple APIs respectively, so as to obtain traffic prediction results respectively corresponding to the multiple APIs and a traffic prediction result of the gateway.

[0007] In a third aspect, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored on the memory. The processor implements the method according to any one of the above when executing the computer program.

[0008] Fourthly, an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the method described in any one of the above is implemented.

[0009] Compared with the prior art, the present application has the following advantages:

[0010] The present application provides a gateway traffic prediction method, device, electronic device and storage medium. First, historical traffic data of multiple application programming interfaces (APIs) of a gateway is obtained; then, according to the historical traffic data of the multiple APIs, traffic prediction strategies respectively corresponding to the multiple APIs are determined; finally, using the traffic prediction strategies respectively corresponding to the multiple APIs, traffic prediction is performed on the multiple APIs respectively to obtain traffic prediction results respectively corresponding to the multiple APIs and a traffic prediction result of the gateway. In the embodiment of the present application, by performing traffic prediction on multiple APIs of the gateway respectively, flow rate limiting configuration can be implemented for the multiple APIs respectively. Moreover, when abnormal traffic occurs, by analyzing the traffic prediction results respectively corresponding to the multiple APIs, the API generating the abnormal traffic can be located, and targeted flow rate limiting operations can be performed, so as to avoid affecting the normal operation of the services of other APIs, and refined and targeted traffic control can be achieved, thereby improving the availability and stability of the system.

[0011] The above description is only an overview of the technical solution of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present application more obvious and understandable, the specific embodiments of the present application are specifically described below. Description of the Drawings

[0012] In the drawings, unless otherwise specified, the same reference numerals throughout the drawings denote the same or similar components or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments according to the present application and should not be regarded as limiting the scope of the present application.

[0013] Figure 1 It is a schematic diagram of an application scenario of the gateway traffic prediction method provided by the present application.

[0014] Figure 2 It is a schematic diagram of API traffic prediction according to different traffic levels in an embodiment of the present application.

[0015] Figure 3 It is a flowchart of the gateway traffic prediction method in an embodiment of the present application.

[0016] Figure 4 It is a flowchart of the gateway traffic prediction method in an embodiment of the present application.

[0017] Figure 5 The structural block diagram of the gateway traffic prediction device according to an embodiment of the present application.

[0018] Figure 6 It is a block diagram of an electronic device for implementing the embodiment of the present application. Specific embodiments

[0019] In the following, only some exemplary embodiments are briefly described. As those skilled in the art can recognize, the described embodiments can be modified in various different ways without departing from the concept or scope of the present application. Therefore, the drawings and descriptions are considered to be exemplary in nature and not restrictive.

[0020] To facilitate understanding of the technical solution of the embodiment of the present application, the related technologies of the embodiment of the present application are described below. The following related technologies can be combined with the technical solution of the embodiment of the present application as an optional solution in any way, and they all fall within the protection scope of the embodiment of the present application.

[0021] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of the relevant data need to comply with the relevant laws, regulations, and standards of the relevant countries and regions, and corresponding operation entrances are provided for the user to select authorization or rejection.

[0022] Embodiment 1

[0023] Figure 1 It is a schematic diagram of an application scenario of the gateway traffic prediction method provided by the present application. As Figure 1 shown, it specifically includes the following steps:

[0024] 1. Obtain the gateway original data traffic. Among them, the gateway original data traffic is the historical traffic data of multiple APIs of the gateway. Specifically, the historical traffic data of multiple APIs can be obtained in two ways: the first is to actively pull. If the program for implementing the gateway traffic prediction method provided by the present application and the gateway are in the same product, the historical traffic data of multiple APIs saved in the gateway database can be directly read; the second is that if the program for implementing the gateway traffic prediction method provided by the present application and the gateway are not in the same product, cross-product database calls are made to call the historical traffic data of multiple APIs in the gateway.

[0025] 2. Analyze gateway data traffic. Sample and analyze the traffic data of multiple APIs of the gateway, and different time granularities can be selected. By performing a moving average on the average traffic data of the gateway within a recently preset time period and the historical average traffic data, and performing a moving average on the peak traffic data of the gateway within a recently preset time period and the historical peak traffic data, the average traffic data and peak traffic data of the gateway on a longer time scale are obtained; similarly, the average traffic data and peak traffic data of each API on a longer time scale can be obtained and stored in the information database of the corresponding API, which can better monitor and manage the traffic data of the API.

[0026] 3. Calculate the API traffic level. Divide the APIs into multiple levels according to the traffic volume and update the traffic levels regularly. The process of updating the API level includes: analyzing the traffic data on a long time scale, using the API with the highest traffic in each sampling time as a benchmark to update the traffic level. The traffic level of the API that reaches the preset percentage of the highest traffic increases, and vice versa. Each traffic sampling updates the traffic levels of all APIs and stores them in the API information database as the basis for subsequent traffic prediction.

[0027] 4. Predict the API and gateway traffic. Extract the API traffic levels from the API information database, determine whether each API belongs to a high-traffic API or a low-traffic API according to the traffic levels, select different traffic prediction strategies according to the different levels for traffic prediction, obtain the traffic prediction results of each API, and statistically analyze the traffic prediction results of each API to obtain the traffic prediction result of the gateway.

[0028] 5. Save the prediction results. Save the traffic prediction results of each API and the traffic prediction result of the gateway.

[0029] Among them, different traffic prediction strategies are selected according to the different traffic levels for traffic prediction. The specific process is as Figure 2 shown and includes the following steps:

[0030] 1. Extract the API traffic levels. Extract the traffic levels of each API from the API information database and determine whether each API belongs to a high-traffic API or a low-traffic API according to the traffic levels. Select different traffic prediction strategies according to the different levels.

[0031] 2.1 High-traffic APIs

[0032] For high-traffic APIs, according to the historical average traffic data and peak traffic data, the average traffic data, and the difference between the peak traffic data and the average traffic data are used as two time series (a time series is a series composed of the traffic corresponding to multiple time periods) respectively for time series prediction.

[0033] 2.1.1 Select samples using a sliding window. For any API, pull the historical traffic data of the current API from the historical traffic database, and select a time series of a preset length as the training samples. Select the training samples closer to the current time in a sliding window manner. For the training samples with predicted values lower than the actual values, increase the weight of these training samples to achieve better learning effects. At the same time, set higher weights for the training samples closer to the current time to ensure that the features of the prediction model change with the traffic characteristics.

[0034] 2.1.2 Complete trend samples using the Autoregressive Integrated Moving Average Model (ARIMA). When using a sliding window to select training samples, the true values of the training samples closer to the current time have not yet been generated, only the predicted values. To ensure the trend characteristics of the samples, use ARIMA to learn the characteristics of the previous time series (the previous time series is the traffic data of the API for which the true values of the traffic data have been generated), and use iterative operations to calculate the approximate values of the traffic data of the API for which the true values of the traffic data have not yet been generated. Use the approximate values as training samples to complete the trend training samples.

[0035] 2.1.3 Increase periodic samples using the autocorrelation algorithm. Some APIs of the gateway also have periodic characteristics, called periodic samples, and intensive training can be carried out for the periodic samples. Based on the time series of the traffic data of the API, perform autocorrelation calculations on the time series using the autocorrelation function, select the autocorrelation peak points, and check whether the multiple periods of the peak points are peak points. If most of its multiple periods satisfy high autocorrelation, it can be determined that the traffic data of the current API has periodic characteristics. From the API time series, with the current time as the reference, select samples every other period forward as periodic samples and add them to the training sample set to train the periodic characteristics. If a training sample is already a periodic sample, increase the weight of this sample.

[0036] Through the above steps 2.1.1 - 2.1.3, obtain the training samples and sample weights of the prediction model. Next, use the training samples and sample weights to train the prediction model. The prediction model can be a machine learning model. For example, it can be an Extreme Gradient Boosting (XgBoost) model.

[0037] 2.1.4 XgBoost Model Training. The training samples in the training sample set are divided into training samples and test samples according to a preset ratio to train the XgBoost model. As time changes, the training sample set is updated, and the XgBoost model is retrained using the new training sample set to obtain a model applicable to traffic prediction at the latest moment and save it.

[0038] 2.1.5 XgBoost Model Prediction. Use the most recent time series traffic data as the input of the XgBoost model, and use the trained XgBoost model to make predictions to obtain traffic prediction results.

[0039] 2.2 Low-Traffic APIs

[0040] For low-traffic APIs, using the XgBoost model to perform time series prediction not only takes time and consumes system resources, but also the predicted results are too low to help the operation and maintenance personnel configure traffic control. The predicted value of the traffic can be directly calculated using the moving average algorithm. Among them, the moving average algorithm is based on the simple average method, calculates the moving average by sequentially increasing and decreasing the old and new data period by period, and makes predictions based on this. The moving average method is to perform curve fitting on the data sequence with an obvious load change trend, and then use the new curve to predict the value at a certain point in the future.

[0041] 3. Calculate the prediction results. Add the average traffic corresponding to each of the multiple predicted APIs and the difference between the predicted average traffic and the peak traffic to obtain the predicted peak traffic.

[0042] In this embodiment, a time series traffic prediction model based on XgBoost is provided, which can predict the traffic trend of APIs through the historical average traffic and peak traffic of the APIs and perform multi-step predictions. Moreover, by constructing the training sample set of XgBoost, selecting trend samples through a sliding window and complementing them through the ARIMA model, judging the periodicity of the time series through the autocorrelation algorithm, and extracting periodic samples, XgBoost can be made more accurate and reasonable in time series prediction. In addition, the traffic trend of APIs on a longer time scale is obtained through the moving average method, and multiple traffic levels are set. By distinguishing high-traffic and low-traffic APIs, the algorithm complexity is reduced while the prediction function is achieved.

[0043] Through the traffic prediction function, the traffic of each API can be predicted. When the traffic trend changes due to service changes, it can quickly perceive through historical data and make corresponding predictions, assisting the operation and maintenance personnel to modify the flow limit value, greatly reducing the difficulty and complexity of the operation and maintenance personnel to adjust the flow limit value of the API. By predicting the total traffic of the entire gateway, when the gateway traffic rises to a certain level, a capacity warning can be issued when the overall gateway flow limit value is known in advance, informing the operation and maintenance personnel to make capacity expansion preparations in advance to prevent the gateway traffic from reaching the flow limit value and affecting the service. Moreover, since the traffic data of each API is predicted, when abnormal traffic occurs at the gateway, the API with abnormal traffic can be quickly located, and it can help the operation and maintenance personnel to make targeted flow limiting, and quickly respond without affecting other services.

[0044] Embodiment 2

[0045] The embodiment of the present application provides a gateway traffic prediction method. The method in this embodiment can be applied to a computing device, and the computing device may include: a server, a user terminal, etc. As Figure 3 shown is a flowchart of the gateway traffic prediction method according to an embodiment of the present application, including:

[0046] Step S301, obtain historical traffic data of multiple APIs of the gateway.

[0047] Step S302, determine traffic prediction strategies respectively corresponding to the multiple APIs according to the historical traffic data of the multiple APIs.

[0048] Step S303, use the traffic prediction strategies respectively corresponding to the multiple APIs to perform traffic prediction on the multiple APIs respectively, and obtain traffic prediction results respectively corresponding to the multiple APIs and a traffic prediction result of the gateway.

[0049] Among them, the multiple APIs of the gateway include the APIs of application programs accessing the network through the gateway. The historical traffic data of the multiple APIs can be obtained by at least one of the following two methods: The first is to actively pull. If the program implementing the gateway traffic prediction method provided by the present application and the gateway are in the same product, the historical traffic data of the multiple APIs saved in the database of the gateway can be directly read; The second is that if the program implementing the gateway traffic prediction method provided by the present application and the gateway are not in the same product, cross-product database calls are made to call the historical traffic data of multiple APIs in the gateway.

[0050] Among them, the multiple APIs of the gateway include the APIs of application programs accessing the network through the gateway.

[0051] For step S301, the historical traffic data of multiple APIs can be obtained through at least one of the following two methods: the first is to actively pull, and obtain the saved historical traffic data of multiple APIs by reading the database of the gateway; the second is to perform cross-product database calls to call the historical traffic data of multiple APIs within the gateway.

[0052] For step S302, the traffic prediction strategies corresponding to multiple APIs can be determined according to the magnitudes of the traffic values of the historical traffic data of multiple APIs. Different prediction strategies can be adopted for APIs with larger traffic values and APIs with smaller traffic values.

[0053] For step S303, the traffic prediction strategies corresponding to multiple APIs can be used to perform traffic prediction on multiple APIs respectively to obtain the traffic prediction results corresponding to multiple APIs; then, according to the traffic prediction results corresponding to multiple APIs, the traffic prediction result of the gateway can be calculated.

[0054] The gateway traffic prediction method provided by the embodiments of the present application first obtains the historical traffic data of multiple application programming interfaces (APIs) of the gateway; then, according to the historical traffic data of multiple APIs, determines the traffic prediction strategies corresponding to multiple APIs respectively; finally, uses the traffic prediction strategies corresponding to multiple APIs respectively to perform traffic prediction on multiple APIs respectively to obtain the traffic prediction results corresponding to multiple APIs respectively and the traffic prediction result of the gateway. In the embodiments of the present application, by performing traffic prediction on multiple APIs of the gateway respectively, it is possible to implement rate limiting configurations for multiple APIs respectively. Moreover, when abnormal traffic occurs, by analyzing the traffic prediction results corresponding to multiple APIs respectively, the API that generates the abnormal traffic can be located and targeted rate limiting operations can be performed, thereby avoiding affecting the normal operation of the services of other APIs, and enabling refined and targeted traffic control, thereby improving the availability and stability of the system.

[0055] The following introduces the specific implementation processes of the above steps through multiple implementation manners:

[0056] In one implementation manner, for step S302, determining the traffic prediction strategies corresponding to multiple APIs according to the historical traffic data of multiple APIs includes: determining the traffic levels corresponding to multiple APIs according to the historical traffic data of multiple APIs; and determining the traffic prediction strategies corresponding to multiple APIs respectively based on the traffic levels corresponding to multiple APIs respectively.

[0057] In practical applications, the traffic levels corresponding to APIs can be determined according to the magnitudes of the traffic values in the historical traffic data of multiple APIs. For APIs with different traffic levels, different traffic prediction strategies can be adopted.

[0058] Optionally, sort the APIs according to the magnitudes of the traffic values in the historical traffic data of multiple APIs, and determine the traffic levels corresponding to the multiple APIs according to the sorting results.

[0059] Optionally, compare the traffic values in the historical traffic data of multiple APIs with a preset traffic value, determine the APIs with traffic values higher than the preset traffic value as high-traffic-level APIs, and determine the APIs with traffic values lower than the preset traffic value as low-traffic-level APIs.

[0060] In one implementation, determining the traffic levels corresponding to multiple APIs according to the historical traffic data of multiple APIs includes: determining the average traffic data corresponding to multiple APIs respectively within a preset time period according to the historical traffic data of multiple APIs; and determining the traffic levels corresponding to multiple APIs respectively based on the average traffic data corresponding to multiple APIs within a preset time period.

[0061] In practical applications, the average traffic is the average of the traffic of an API within a preset time period and is a relatively stable attribute of the API. Therefore, the traffic level of the API can be determined according to the average traffic. Compare the average traffic data in the historical traffic data of multiple APIs with a preset traffic value, determine the APIs with average traffic data higher than the preset traffic value as high-traffic-level APIs, and determine the APIs with average traffic data lower than the preset traffic value as low-traffic-level APIs.

[0062] In one implementation, the traffic levels include a first level and a second level, and the average traffic of the APIs at the first level within a preset time period is greater than that of the APIs at the second level; determining the traffic prediction strategies corresponding to multiple APIs respectively based on the traffic levels corresponding to multiple APIs includes: determining the machine learning model as the traffic prediction strategy corresponding to the APIs at the first level; and determining the moving average algorithm as the traffic prediction strategy corresponding to the APIs at the second level.

[0063] Divide multiple APIs into a high-traffic level (i.e., the first level) and a low-traffic level (i.e., the second level) according to the average traffic. For the APIs at the high-traffic level, use a machine learning algorithm for traffic prediction, and for the APIs at the low-traffic level, use a moving average algorithm for traffic prediction.

[0064] Among them, machine learning models can include multiple ones, which can be selected according to specific needs, for example, the Extreme Gradient Boosting (XgBoost) model. For APIs with low traffic levels, using the XgBoost model to take time series predictions is not only time-consuming and consumes system resources, but also the predicted results are too low, which does not help operation and maintenance personnel to configure flow control. In turn, the sliding average algorithm can be directly used to calculate the predicted value of the flow.

[0065] In this embodiment, multiple traffic levels are set, and different prediction strategies are adopted by distinguishing APIs of high traffic level and low traffic level, thereby reducing the complexity of the algorithm while realizing the prediction function.

[0066] In one implementation, the method further includes: obtaining training samples and sample weights of the machine learning model; training the machine learning model using the training samples and sample weights; wherein the training samples include the true values of the API traffic data.

[0067] Among them, the machine learning model can be selected according to specific needs, for example, the Extreme Gradient Boosting (XgBoost) model, etc.

[0068] In one implementation, the sample weights are set in a manner that includes at least one of the following: the weight of the first training sample is greater than the weight of the second training sample; the predicted value of the API traffic data included in the first training sample is lower than the true value, and the predicted value of the API traffic data included in the second training sample is higher than the true value; the weight of the third training sample is greater than the weight of the fourth training sample; the time when the true value of the API traffic data included in the third training sample was generated is closer to the current time; the time when the true value of the API traffic data included in the fourth training sample was generated is far from the current time; the weight of the fifth training sample is greater than the weight of the sixth training sample; the fifth training sample has periodic characteristics; and the sixth training sample does not have periodic characteristics.

[0069] When constructing a training sample set for a machine model, weights of different sizes are set for training samples with different features.

[0070] For any API, pull the historical traffic data of the current API from the historical traffic database, select the training samples closer to the current moment, and set higher weights for the training samples closer to the current moment to ensure that the features of the prediction model change with the traffic characteristics. For the training samples with predicted values lower than the actual values, increase the weights of these training samples to enable them to achieve better learning effects. Based on the obtained traffic data of the API, perform autocorrelation calculations using the autocorrelation function to determine the training samples with periodic characteristics, and increase the weights of the training samples with periodic characteristics. Judging periodicity through the autocorrelation algorithm and extracting periodic samples can make the machine learning model more accurate and reasonable during prediction.

[0071] In one implementation, the method further includes: obtaining a first API whose true value of traffic data has not been generated, and a second API whose true value of traffic data has been generated; based on the true value of the traffic data of the second API, using the autoregressive integrated moving average model to determine the approximate value of the traffic data of the first API; using the approximate value as the training sample of the machine learning model.

[0072] In practical applications, when using a sliding window to select training samples, the true values of the training samples closer to the current time have not been generated, and only predicted values are available. To ensure the trend characteristics of the samples, use the ARIMA to learn the characteristics of the time series before (the time series before refers to the traffic data of the API whose true value of traffic data has been generated), and adopt an iterative operation method to calculate the approximate value of the traffic data of the API whose true value of traffic data has not been generated, and use the approximate value as the training sample to complete the trend training sample.

[0073] In one implementation, using the traffic prediction strategies corresponding to multiple APIs respectively, perform traffic prediction on multiple APIs respectively to obtain the traffic prediction results corresponding to multiple APIs respectively and the traffic prediction result of the gateway, including: using the traffic prediction strategies corresponding to the multiple APIs respectively, the average traffic data and peak traffic data corresponding to the multiple APIs respectively within a preset time period, perform traffic prediction on the multiple APIs respectively to obtain the traffic prediction results corresponding to the multiple APIs respectively, including predicted average traffic data, predicted peak traffic data, and the traffic prediction result of the gateway; the traffic prediction results corresponding to the multiple APIs respectively include the predicted average traffic data and predicted peak traffic data corresponding to the multiple APIs respectively; the traffic prediction result of the gateway includes the predicted results of the average traffic and peak traffic of the gateway.

[0074] In practical applications, in addition to calculating the average traffic data of each API, the peak traffic data of each API can also be calculated. Based on the average traffic data and the difference between the average traffic data and the peak traffic data, using the traffic prediction algorithm corresponding to the traffic level of each API, the predicted average traffic data corresponding to each API, the predicted value of the difference between the average traffic data and the peak traffic data are calculated. The predicted average traffic data and the predicted value of the difference are summed to obtain the predicted peak traffic data. Then, according to the predicted average traffic data and the predicted peak traffic data corresponding to each API, the predicted results of the average traffic and the peak traffic of the gateway are calculated.

[0075] In one implementation, the method further includes: determining the peak traffic data corresponding to each of the multiple APIs within a preset time period according to the historical traffic data of the multiple APIs.

[0076] In practical applications, by statistically analyzing the historical traffic data of the APIs in multiple time periods, the peak traffic data corresponding to each of the multiple APIs within a preset time period can be obtained for subsequent traffic prediction.

[0077] In one implementation, after determining the traffic levels corresponding to the multiple APIs according to the historical traffic data of the multiple APIs, the method further includes: updating the historical traffic data of the multiple APIs according to a preset time period; and updating the traffic levels corresponding to the multiple APIs by using the updated data.

[0078] In practical applications, by updating the historical traffic data of the APIs, the traffic levels of the APIs are synchronously updated, so that the traffic prediction results can change with the change of the traffic data. When the traffic trend changes due to the change of the service, it can be quickly sensed through the historical data and corresponding predictions can be made to assist the operation and maintenance personnel in modifying the flow limiting value, greatly reducing the difficulty and complexity of the operation and maintenance personnel in adjusting the flow limiting value of the API.

[0079] In one implementation, updating the traffic levels corresponding to the multiple APIs by using the updated data includes: determining the traffic data of the API with the highest traffic within the sampling time period in the updated data; and determining the updated traffic levels corresponding to the multiple APIs according to the percentage of the traffic data corresponding to the multiple APIs in the traffic data of the API with the highest traffic.

[0080] Specifically, analyze the traffic data corresponding to each of the multiple APIs. Taking the API with the highest traffic in each sampling time as a benchmark, update the traffic level. The traffic level of the API that reaches the preset percentage of the highest traffic increases, otherwise it decreases. Each traffic sampling updates the traffic levels of all APIs and stores them in the API information database as the basis for subsequent traffic prediction.

[0081] In one implementation, step S303, using the traffic prediction strategies corresponding to the multiple APIs, respectively, performs traffic prediction on the multiple APIs, and obtains the traffic prediction results corresponding to the multiple APIs and the traffic prediction results of the gateway, including: using the traffic prediction strategies corresponding to the multiple APIs, respectively, performs traffic prediction on the multiple APIs, and obtains the traffic prediction results corresponding to the multiple APIs; and performs statistics on the traffic prediction results corresponding to the multiple APIs to obtain the traffic prediction results of the gateway.

[0082] Optionally, based on the average traffic data, the difference between the average traffic data and the peak traffic data, the traffic prediction algorithm corresponding to each API traffic level is used to calculate the predicted average traffic data corresponding to each API, the predicted value of the difference between the average traffic data and the peak traffic data, and the predicted average traffic data and the predicted value of the difference are summed to obtain the predicted peak traffic data. The predicted average traffic data corresponding to each API is then summed to obtain the predicted result of the average traffic of the gateway; the predicted peak traffic data corresponding to each API is summed to obtain the predicted result of the peak traffic of the gateway.

[0083] In this embodiment, since the traffic data of each API is predicted, when abnormal traffic occurs in the gateway, the API with abnormal traffic can be quickly located, and the operation and maintenance personnel can be helped to make targeted flow limits and respond quickly without affecting other services. By predicting the total traffic of the entire gateway, when the gateway traffic increases to a certain level, a capacity alarm can be issued if the global flow limit value of the gateway is known in advance, informing the operation and maintenance personnel to prepare for capacity expansion in advance to prevent the gateway traffic from reaching the flow limit value and affecting the service.

[0084] Embodiment 3

[0085] The present application embodiment provides a gateway traffic prediction method. The method in this embodiment can be applied to a computing device, which may include a server, a user terminal, etc. Figure 4 The flowchart of the gateway traffic prediction method according to an embodiment of the present application is shown, including:

[0086] Step S401, obtaining historical traffic data of multiple APIs of the gateway.

[0087] Step S402: determining average flow data corresponding to the multiple APIs in a preset time period according to the historical flow data of the multiple APIs.

[0088] Step S403: determining the flow levels respectively corresponding to the multiple APIs based on the average flow data respectively corresponding to the multiple APIs within a preset time period.

[0089] Step S404: Determine the peak traffic data corresponding to multiple APIs respectively within a preset time period according to the historical traffic data of the multiple APIs.

[0090] Step S405: Determine the traffic prediction algorithm corresponding to the APIs of the first level as the machine learning model; determine the moving average algorithm as the traffic prediction algorithm corresponding to the APIs of the second level. Wherein, the traffic levels include the first level and the second level, and the average traffic of the APIs of the first level within a preset time period is greater than that of the APIs of the second level.

[0091] Step S406: Obtain the training samples and sample weights of the machine learning model; use the training samples and sample weights to train the machine learning model; wherein, the training samples include the true values of the API traffic data; the setting methods of the sample weights include at least one of the following: the weight of the first training sample is greater than the weight of the second training sample; the predicted value of the API traffic data included in the first training sample is lower than the true value, and the predicted value of the API traffic data included in the second training sample is higher than the true value; the weight of the third training sample is greater than the weight of the fourth training sample; the time when the true value of the API traffic data included in the third training sample is generated is closer to the current time; the time when the true value of the API traffic data included in the fourth training sample is generated is farther from the current time; the weight of the fifth training sample is greater than the weight of the sixth training sample; the fifth training sample has periodic characteristics; the sixth training sample does not have periodic characteristics.

[0092] Step S407: Use the traffic prediction algorithms corresponding to the multiple APIs respectively, the average traffic data and peak traffic data corresponding to the multiple APIs respectively within a preset time period, to perform traffic prediction on the multiple APIs respectively, and obtain the predicted average traffic data, predicted peak traffic data corresponding to the multiple APIs respectively, and the predicted results of the average traffic and peak traffic of the gateway.

[0093] For the specific implementation processes of the above steps, please refer to the specific implementation manners in Embodiment 1 and Embodiment 2 above, and details are not described herein again.

[0094] Embodiment 4

[0095] Corresponding to the application scenario and method of the method provided in the embodiments of the present application, the embodiments of the present application also provide a gateway traffic prediction device. As Figure 5 shown in the structural block diagram of the gateway traffic prediction device according to an embodiment of the present application, the device includes:

[0096] An acquisition module 501, configured to acquire the historical traffic data of multiple application programming interfaces (APIs) of the gateway.

[0097] A determination module 502, configured to determine traffic prediction strategies respectively corresponding to multiple APIs according to historical traffic data of the multiple APIs.

[0098] A prediction module 503, configured to perform traffic prediction on the multiple APIs respectively by using the traffic prediction strategies respectively corresponding to the multiple APIs, so as to obtain traffic prediction results respectively corresponding to the multiple APIs and a traffic prediction result of the gateway.

[0099] The gateway traffic prediction device provided by the embodiment of the present application first obtains historical traffic data of multiple application programming interfaces (APIs) of the gateway; then determines traffic prediction strategies respectively corresponding to the multiple APIs according to the historical traffic data of the multiple APIs; and finally performs traffic prediction on the multiple APIs respectively by using the traffic prediction strategies respectively corresponding to the multiple APIs, so as to obtain traffic prediction results respectively corresponding to the multiple APIs and a traffic prediction result of the gateway. In the embodiment of the present application, by performing traffic prediction on multiple APIs of the gateway respectively, it is possible to perform rate limiting configuration on the multiple APIs respectively. Moreover, when abnormal traffic occurs, it is possible to locate the API generating the abnormal traffic by analyzing the traffic prediction results respectively corresponding to the multiple APIs, and perform targeted rate limiting operations, thereby avoiding affecting the normal operation of the services of other APIs, and being able to achieve refined and targeted traffic control, thereby improving the availability and stability of the system.

[0100] In one implementation, the determination module 502 is configured to: determine traffic levels respectively corresponding to the multiple APIs according to the historical traffic data of the multiple APIs; and determine traffic prediction strategies respectively corresponding to the multiple APIs based on the traffic levels respectively corresponding to the multiple APIs.

[0101] In one implementation, the traffic levels include a first level and a second level, and the average traffic of the APIs at the first level within a preset time period is greater than that of the APIs at the second level; the determination module 502 is configured to: when determining traffic prediction strategies respectively corresponding to the multiple APIs based on the traffic levels respectively corresponding to the multiple APIs, determine the machine learning model as the traffic prediction strategy corresponding to the APIs at the first level; and determine the moving average algorithm as the traffic prediction strategy corresponding to the APIs at the second level.

[0102] In one implementation, the device is further configured to: obtain training samples and sample weights of the machine learning model; and train the machine learning model by using the training samples and the sample weights; wherein the training samples include true values of API traffic data.

[0103] In one implementation, the method for setting sample weights includes at least one of the following: the weight of the first training sample is greater than the weight of the second training sample; the predicted value of the API traffic data included in the first training sample is lower than the true value, and the predicted value of the API traffic data included in the second training sample is higher than the true value; the weight of the third training sample is greater than the weight of the fourth training sample; the time when the true value of the API traffic data included in the third training sample is generated is closer to the current time; the time when the true value of the API traffic data included in the fourth training sample is generated is farther from the current time; the weight of the fifth training sample is greater than the weight of the sixth training sample; the fifth training sample has periodic characteristics; the sixth training sample does not have periodic characteristics.

[0104] In one implementation, the apparatus is further configured to: obtain a first API for which the true value of the traffic data has not been generated, and a second API for which the true value of the traffic data has been generated; determine an approximate value of the traffic data of the first API by using an autoregressive integrated moving average model based on the true value of the traffic data of the second API; and use the approximate value as a training sample of the machine learning model.

[0105] In one implementation, the determining module 502 is configured to: when determining the traffic levels corresponding to multiple APIs according to the historical traffic data of the multiple APIs, determine the average traffic data corresponding to the multiple APIs respectively within a preset time period according to the historical traffic data of the multiple APIs; and determine the traffic levels corresponding to the multiple APIs respectively based on the average traffic data corresponding to the multiple APIs respectively within the preset time period.

[0106] In one implementation, the prediction module 503 is configured to: perform traffic prediction on multiple APIs respectively by using the traffic prediction strategies corresponding to the multiple APIs, the average traffic data and peak traffic data corresponding to the multiple APIs respectively within a preset time period, so as to obtain the traffic prediction results corresponding to the multiple APIs (predicted average traffic data, predicted peak traffic data), and the traffic prediction result of the gateway; the traffic prediction results corresponding to the multiple APIs respectively include the predicted average traffic data and predicted peak traffic data corresponding to the multiple APIs respectively; the traffic prediction result of the gateway includes the predicted results of the average traffic and peak traffic of the gateway.

[0107] In one implementation, the determining module 502 is further configured to: determine the peak traffic data corresponding to the multiple APIs respectively within a preset time period according to the historical traffic data of the multiple APIs.

[0108] In one implementation, the determining module 502 is further configured to: after determining the traffic levels corresponding to the multiple APIs according to the historical traffic data of the multiple APIs, update the historical traffic data of the multiple APIs according to a preset time period; and update the traffic levels corresponding to the multiple APIs by using the updated data.

[0109] In one implementation, when the determining module 502 updates the traffic levels corresponding to the multiple APIs by using the updated data, the determining module 502 is configured to: determine the traffic data of the API with the highest traffic within the sampling time period in the updated data; and determine the updated traffic levels corresponding to the multiple APIs according to the percentages of the traffic data corresponding to the multiple APIs in the traffic data of the API with the highest traffic.

[0110] In one implementation, the predicting module 503 is configured to: perform traffic prediction on the multiple APIs respectively by using the traffic prediction strategies corresponding to the multiple APIs to obtain traffic prediction results corresponding to the multiple APIs respectively; and perform statistics on the traffic prediction results corresponding to the multiple APIs respectively to obtain the traffic prediction result of the gateway.

[0111] For the functions of the modules in the embodiments of the present application, reference may be made to the corresponding descriptions in the above methods, and they have the corresponding beneficial effects, which will not be elaborated here.

[0112] Figure 6 The block diagram of the electronic device for implementing the embodiments of the present application is as follows. As Figure 6 shown, the electronic device includes: a memory 610 and a processor 620. The memory 610 stores a computer program that can run on the processor 620. When the processor 620 executes the computer program, the method in the above embodiments is implemented. The number of the memory 610 and the processor 620 may be one or more.

[0113] The electronic device further includes:

[0114] a communication interface 630, configured to communicate with external devices and perform data interaction and transmission.

[0115] If the memory 610, the processor 620, and the communication interface 630 are implemented independently, the memory 610, the processor 620, and the communication interface 630 can be interconnected through a bus to complete communication with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 only a thick line is used to represent it in Figure 6 , but it does not mean that there is only one bus or one type of bus.

[0116] Optionally, in a specific implementation, if the memory 610, the processor 620, and the communication interface 630 are integrated on a single chip, the memory 610, the processor 620, and the communication interface 630 can complete communication with each other through an internal interface.

[0117] The embodiment of the present application provides a computer-readable storage medium that stores a computer program, and when the program is executed by a processor, the method provided in the embodiment of the present application is implemented.

[0118] The embodiment of the present application also provides a chip, which includes a processor for calling and running instructions stored in a memory, so that a communication device installed with the chip executes the method provided in the embodiment of the present application.

[0119] The embodiment of the present application also provides a chip, including: an input interface, an output interface, a processor, and a memory. The input interface, the output interface, the processor, and the memory are connected through an internal connection path. The processor is used to execute the code in the memory, and when the code is executed, the processor is used to execute the method provided in the embodiment of the application.

[0120] It should be understood that the above-mentioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc. It is worth noting that the processor can be a processor that supports the Advanced RISC Machines (ARM) architecture.

[0121] Furthermore, optionally, the above-mentioned memory can include a read-only memory and a random access memory. The memory can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can include a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically EPROM (EEPROM), or a flash memory. The volatile memory can include a Random Access Memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, Static RAM (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced SDRAM (ESDRAM), Sync link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).

[0122] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions according to the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium.

[0123] In the description of this specification, the descriptions referring to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc. 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 application. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. 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.

[0124] In addition, the terms "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first" and "second" can explicitly or implicitly include at least one of the features. In the description of the present application, "a plurality of" means two or more unless otherwise specifically defined.

[0125] Any process or method described in the flowchart or otherwise described herein can be understood to represent a module, segment, or portion of code including one or more executable instructions for implementing a specific logical function or process. And the scope of the preferred embodiments of the present application includes additional implementations, where the functions can be executed in a substantially simultaneous manner or in a reverse order according to the involved functions, rather than in the order shown or discussed.

[0126] The logic and / or steps described in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing a logical function, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in combination with these instruction execution systems, apparatuses, or devices.

[0127] It should be understood that each part of the present application can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the method in the above embodiments can be completed by a program instructing relevant hardware. The program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.

[0128] In addition, each functional unit in various embodiments of the present application can be integrated into a processing module, or each unit can exist physically alone, or two or more units can be integrated into one module. The above integrated module can be implemented in the form of hardware or in the form of a software functional module. If the above integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. The storage medium can be a read-only memory, a disk, an optical disc, etc.

[0129] As mentioned above, only the exemplary embodiments of the present application are described, but the protection scope of the present application is not limited thereto. Any person skilled in the art in the technical scope recorded in the present application can easily think of various changes or substitutions, and these should all be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A gateway traffic prediction method, characterized in that, The method includes: Obtaining historical traffic data of multiple application programming interfaces (APIs) of a gateway; Determining traffic prediction strategies respectively corresponding to the multiple APIs according to the historical traffic data of the multiple APIs; Using the traffic prediction strategies respectively corresponding to the multiple APIs to perform traffic prediction on the multiple APIs respectively, and obtaining traffic prediction results respectively corresponding to the multiple APIs and a traffic prediction result of the gateway.

2. The method according to claim 1, wherein The determining the traffic prediction strategies respectively corresponding to the multiple APIs according to the historical traffic data of the multiple APIs includes: Determining traffic levels respectively corresponding to the multiple APIs according to the historical traffic data of the multiple APIs; Determining traffic prediction strategies respectively corresponding to the multiple APIs based on the traffic levels respectively corresponding to the multiple APIs.

3. The method according to claim 2, characterized in that, The traffic levels include a first level and a second level, and the average traffic of the APIs at the first level within a preset time period is greater than that of the APIs at the second level; the determining the traffic prediction strategies respectively corresponding to the multiple APIs based on the traffic levels respectively corresponding to the multiple APIs includes: Determining a machine learning model as the traffic prediction strategy corresponding to the APIs at the first level; Determining a moving average algorithm as the traffic prediction strategy corresponding to the APIs at the second level.

4. The method according to claim 3, wherein The method further includes: Obtaining training samples and sample weights of the machine learning model; Training the machine learning model by using the training samples and the sample weights; Wherein, the training samples include true values of API traffic data.

5. The method according to claim 4, wherein The setting manners of the sample weights include at least one of the following: The weight of a first training sample is greater than the weight of a second training sample; the predicted value of the API traffic data included in the first training sample is lower than the true value, and the predicted value of the API traffic data included in the second training sample is higher than the true value; The weight of a third training sample is greater than the weight of a fourth training sample; the time when the true value of the API traffic data included in the third training sample is generated is closer to the current time; The time when the true value of the API traffic data included in the fourth training sample is generated is farther from the current time; The weight of a fifth training sample is greater than the weight of a sixth training sample; the fifth training sample has periodic characteristics; The sixth training sample does not have periodic characteristics.

6. The method according to claim 3, wherein The method further includes: Obtaining a first API for which the true value of traffic data has not been generated, and a second API for which the true value of traffic data has been generated; Based on the true value of the traffic data of the second API, using an autoregressive integrated moving average model to determine an approximate value of the traffic data of the first API; Taking the approximate value as a training sample of the machine learning model.

7. The method according to claim 2, wherein The determining the traffic levels respectively corresponding to the multiple APIs according to the historical traffic data of the multiple APIs includes: Determining average traffic data respectively corresponding to the multiple APIs within a preset time period according to the historical traffic data of the multiple APIs; Determining traffic levels respectively corresponding to the multiple APIs based on the average traffic data respectively corresponding to the multiple APIs within a preset time period.

8. The method according to claim 7, wherein Performing traffic prediction on the multiple APIs respectively by using the traffic prediction strategies corresponding to the multiple APIs respectively to obtain the traffic prediction results corresponding to the multiple APIs respectively and the traffic prediction result of the gateway includes: Performing traffic prediction on the multiple APIs respectively by using the traffic prediction strategies corresponding to the multiple APIs respectively, the average traffic data and peak traffic data corresponding to the multiple APIs respectively within a preset time period, to obtain the predicted average traffic data, predicted peak traffic data of the traffic prediction results corresponding to the multiple APIs respectively, and the traffic prediction result of the gateway; the traffic prediction results corresponding to the multiple APIs respectively include the predicted average traffic data and predicted peak traffic data corresponding to the multiple APIs respectively; the traffic prediction result of the gateway includes the predicted results of the average traffic and peak traffic of the gateway.

9. The method according to claim 7, wherein The method further includes: Determining the peak traffic data corresponding to the multiple APIs respectively within a preset time period according to the historical traffic data of the multiple APIs.

10. The method according to claim 2, wherein After determining the traffic levels corresponding to the multiple APIs respectively according to the historical traffic data of the multiple APIs, the method further includes: Updating the historical traffic data of the multiple APIs according to a preset time period; Updating the traffic levels corresponding to the multiple APIs respectively by using the updated data.

11. The method according to claim 10, wherein The updating the traffic levels corresponding to the multiple APIs respectively by using the updated data includes: Determining the traffic data of the API with the highest traffic within the sampling time period in the updated data; Determining the updated traffic levels corresponding to the multiple APIs respectively according to the percentages of the traffic data corresponding to the multiple APIs respectively in the traffic data of the API with the highest traffic.

12. The method according to any one of claims 1-11, characterized in that, Performing traffic prediction on the multiple APIs respectively by using the traffic prediction strategies corresponding to the multiple APIs respectively to obtain the traffic prediction results corresponding to the multiple APIs respectively and the traffic prediction result of the gateway includes: Performing traffic prediction on the multiple APIs respectively by using the traffic prediction strategies corresponding to the multiple APIs respectively to obtain the traffic prediction results corresponding to the multiple APIs respectively; Statistically analyzing the traffic prediction results corresponding to the multiple APIs respectively to obtain the traffic prediction result of the gateway.

13. A gateway traffic prediction device, characterized in that, The apparatus includes: An obtaining module, configured to obtain the historical traffic data of multiple application programming interfaces (APIs) of a gateway; A determining module, configured to determine the traffic prediction strategies corresponding to the multiple APIs respectively according to the historical traffic data of the multiple APIs; A predicting module, configured to perform traffic prediction on the multiple APIs respectively by using the traffic prediction strategies corresponding to the multiple APIs respectively to obtain the traffic prediction results corresponding to the multiple APIs respectively and the traffic prediction result of the gateway.

14. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored on the memory, and the processor implements the method according to any one of claims 1-12 when executing the computer program.

15. A computer-readable storage medium storing a computer program therein, and when the computer program is executed by a processor, the method according to any one of claims 1-12 is implemented.