Self-adaptive drainage method and system based on micro-service architecture
By combining user behavior data and historical traffic data, using the time series prediction model to predict traffic peaks, and adaptively adjust service resource allocation, the resource scheduling problem of microservice architecture during traffic peaks is solved, and efficient and personalized traffic management is achieved. Reduced service latency and outages.
Patent Information
- Application Number
- CN202411209670.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-12-10
AI Technical Summary
During peak traffic, the existing microservice architecture is difficult to adjust the allocation of service resources in a timely manner, resulting in low traffic management efficiency and service delays or interruptions.
By obtaining user behavior data and historical traffic data, preprocessing and time series prediction, adaptively formulate traffic drainage strategies, including service instance expansion, routing rule optimization and request distribution strategy adjustment, and using prediction models to predict traffic peaks or troughs to achieve rapid resources Scheduling and request intelligent distribution.
It improves the efficiency of traffic management and system response speed, optimizes service resource allocation, reduces the risks of service delays and interruptions, and improves user experience.
Smart Images

Figure CN119109808A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer network security, and in particular to an adaptive traffic diversion method and system based on a microservice architecture. Background Art
[0002] Microservice architecture is widely used in modern software development due to its flexibility and scalability. Microservice architecture is a solution that splits large applications into multiple small, independent services. Each service is an independent application, and one service corresponds to multiple instances. It achieves decoupling and independent deployment of services, greatly improving the maintainability and scalability of the system. Microservice architecture makes services more stable and reliable, product iterations more convenient and faster, and greatly facilitates operation and maintenance. The deployment of each microservice does not affect other services, and they are all independent. Different from traditional applications, it is very conducive to continuous integration and continuous delivery.
[0003] At present, most microservice architectures support dynamic scaling, but they mainly focus on starting and stopping service instances based on resource usage (such as CPU, memory, etc.). This method is relatively effective when dealing with continuously and steadily growing traffic. For example, in scenarios such as promotional holidays and sudden hot events, traffic often increases sharply in a very short period of time. Faced with unpredictable traffic peaks, this scaling strategy often seems to be unable to cope with it. Since changes in resource usage take a certain amount of time to be significantly reflected, dynamic scaling based solely on resource usage cannot respond to rapid changes in traffic in a timely manner, and it is difficult to automatically adjust service resource allocation. The traffic management efficiency is low, resulting in service delays or interruptions. Summary of the invention
[0004] In order to solve the problem that the above-mentioned prior art cannot automatically adjust service resource allocation in time during traffic peaks, the traffic management efficiency is low, and service delays or interruptions are caused, the present invention proposes an adaptive traffic diversion method and system based on a microservice architecture, which can automatically adjust service resource allocation in time during traffic peaks, effectively improve traffic management efficiency, and reduce service delays or interruptions.
[0005] In order to achieve the above technical effects, the technical solution of the present invention is as follows:
[0006] An adaptive traffic diversion method based on a microservice architecture includes the following steps:
[0007] Obtain user behavior data and historical traffic data;
[0008] Preprocessing the historical traffic data to obtain a preprocessing result of the historical traffic data;
[0009] Input the user behavior data and preprocessing results into a preset time series prediction model, and output a traffic prediction result;
[0010] Based on the traffic prediction results, a traffic diversion strategy is adaptively formulated.
[0011] Preferably, the user behavior data includes user access frequency UAF, page dwell time DWT and user path depth UPD.
[0012] Preferably, the preprocessing of the historical traffic data to obtain the preprocessing result of the historical traffic data includes:
[0013] Using a clustering algorithm to group the historical traffic data to obtain several groups of traffic patterns;
[0014] Calculate the flow fluctuation coefficient under each set of flow patterns;
[0015] The flow pattern and the flow fluctuation coefficient are defined as the preprocessing result.
[0016] Preferably, the calculation of the flow fluctuation coefficient under each group of flow modes includes:
[0017] Collect the number of requests per hour with high traffic volume RHPS in the selected time window T, and store the number of requests per hour RHPS in the time series array traffic_data;
[0018] Based on the time series array traffic_data, the average value AT of the traffic is calculated as follows:
[0019]
[0020] Where m represents the number of hours in the time window T, traffic_data t It represents the number of requests per hour RHPS in the tth hour in the time window T;
[0021] Based on the average value AT, the standard deviation SD of the flow rate is calculated as follows:
[0022]
[0023] Based on the standard deviation SD and the average value AT, the flow fluctuation coefficient is calculated as follows:
[0024]
[0025] Wherein, FVC represents the flow fluctuation coefficient.
[0026] Preferably, the time series prediction model includes a prediction flow network, a long short-term memory network and a weighted hybrid network; the prediction flow network and the long short-term memory network are connected to the weighted hybrid network in parallel; the prediction flow network predicts the initial flow, the long short-term memory network captures nonlinearity and long-term dependencies, and the weighted hybrid network performs weighted averaging on the initial flow and the nonlinearity and long-term dependencies, and outputs the weighted result as the final flow prediction result.
[0027] Preferably, the traffic diversion strategy includes expansion of service instances, optimization of routing rules and adjustment of request distribution strategy.
[0028] Preferably, the adjustment of the request distribution strategy includes: if the traffic prediction result is greater than the high traffic threshold, the request distribution strategy is adjusted to a predicted traffic peak strategy; if the traffic prediction result is less than the low traffic threshold, the request distribution strategy is adjusted to a predicted traffic low peak strategy; if a special event that affects the traffic prediction result is predicted, the request distribution strategy is adjusted to a special event response strategy; if the deviation between the traffic prediction result and the real-time monitored traffic exceeds the traffic deviation threshold, the request distribution strategy is adjusted to a real-time traffic monitoring and adaptive adjustment strategy.
[0029] Preferably, the predicted traffic peak strategy is to automatically increase the number of service instances and adjust the load balance; the predicted traffic low peak strategy is to automatically reduce the number of service instances.
[0030] The present invention also proposes an adaptive traffic diversion system based on a microservice architecture, comprising:
[0031] User behavior analysis module, used to obtain user behavior data;
[0032] A traffic processing module, used to obtain historical traffic data, pre-process the historical traffic data, and obtain a pre-processing result of the historical traffic data;
[0033] A traffic prediction module, used to input the user behavior data and preprocessing results into a preset time series prediction model and output a traffic prediction result;
[0034] The adaptive traffic diversion decision module is used to adaptively formulate a traffic diversion strategy according to the traffic prediction result.
[0035] Preferably, it also includes a resource scheduling module, and the resource scheduling module is used to execute the diversion strategy.
[0036] Compared with the prior art, the technical solution of the present invention has the following beneficial effects:
[0037] The present invention proposes an adaptive traffic diversion method and system based on microservice architecture. Firstly, user behavior data is introduced, combined with the preprocessing results of historical traffic data, and accurate traffic prediction is achieved by using a time series prediction model, so as to identify and respond to traffic peaks in advance. Then, a traffic diversion strategy is adaptively formulated according to the traffic prediction results. The traffic diversion decision not only considers resource usage, but also user behavior and traffic trends. It can automatically adjust service resource allocation in time during traffic peaks, support fast resource scheduling and intelligent request distribution, improve system response speed and processing capabilities, optimize service resource allocation, improve resource utilization and system throughput, achieve more accurate, efficient and personalized traffic management, reduce the risk of service delays and interruptions, and improve user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A flowchart of an adaptive traffic diversion method based on a microservice architecture provided in an embodiment of the present invention is shown;
[0039] Figure 2 A flowchart showing the preprocessing process of historical traffic data provided in an embodiment of the present invention;
[0040] Figure 3 A diagram showing a time series prediction model structure provided in an embodiment of the present invention;
[0041] Figure 4 A structural block diagram of an adaptive traffic diversion system based on a microservice architecture provided in an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0042] The drawings are for illustrative purposes only and should not be construed as limiting the present patent;
[0043] It is understandable to those skilled in the art that some well-known contents may be omitted in the drawings;
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. It should be understood that the step numbers used in the text are only for the convenience of description and are not used as a limitation on the order of execution of the steps.
[0045] Example 1
[0046] like Figure 1 As shown, this embodiment proposes an adaptive traffic diversion method based on a microservice architecture, comprising the following steps:
[0047] S1. Obtain user behavior data and historical traffic data;
[0048] In S1, data on user interaction with services, namely user behavior data, is collected through technical means such as API call logs and user session tracking to analyze user behavior patterns. The user behavior data includes user access frequency UAF, page dwell time DWT, and user path depth UPD.
[0049] User access frequency (UAF): the number of times a user visits a specific service in a unit of time. By statistically analyzing the changing trend of UAF, traffic peaks can be predicted.
[0050] Page dwell time DWT: The average dwell time of users on a specific page; abnormal changes in DWT indicate high demand or problems with the service.
[0051] User Path Depth (UPD): the depth of pages visited by users in a service; an increase in UPD indicates that users are exploring the service more deeply and require more service resources.
[0052] S2. Preprocess the historical traffic data to obtain the preprocessing result of the historical traffic data;
[0053] In S2, see Figure 2 , the preprocessing of the historical traffic data to obtain the preprocessing result of the historical traffic data includes:
[0054] S21. Use a clustering algorithm to group historical traffic data within a certain period of time T, and obtain three groups of traffic patterns: high traffic period, low traffic period, and traffic surge caused by special events;
[0055] In S22, the flow fluctuation coefficient under each group of flow modes is calculated, including:
[0056] S221. Collect the number of requests per hour with high traffic volume RHPS within the selected time window T, and store the number of requests per hour RHPS in the time series array traffic_data;
[0057] S222. Based on the time series array traffic_data, the average value AT of the traffic is calculated as follows:
[0058]
[0059] Where m represents the number of hours in the time window T, traffic_data t It represents the number of requests per hour RHPS in the tth hour in the time window T;
[0060] S223. Based on the average value AT, the standard deviation SD of the flow is calculated as follows:
[0061]
[0062] The standard deviation is a measure of how far a data point deviates from the mean, reflecting the degree of fluctuation in traffic;
[0063] S224. Based on the standard deviation SD and the average value AT, the flow fluctuation coefficient is calculated as follows:
[0064]
[0065] Among them, FVC represents the flow fluctuation coefficient; FVC reflects the stability of the flow in different time periods, and a higher FVC value may indicate the instability of the flow.
[0066] If the FVC is lower than the coefficient threshold (eg, 5%), it indicates that the flow is relatively stable without significant fluctuations; if the FVC exceeds the coefficient threshold (eg, 50%), it indicates that the flow fluctuates greatly and there may be flow peaks or troughs.
[0067] S23. Define the flow pattern and the flow fluctuation coefficient as the preprocessing result.
[0068] S3. Input the user behavior data and preprocessing results into a preset time series prediction model, and output the traffic prediction results;
[0069] S4. Based on the traffic prediction results, adaptively formulate a traffic diversion strategy.
[0070] In this embodiment, the method not only takes into account the resource usage of the service instance, but also combines user behavior analysis, traffic pattern recognition and prediction algorithms to achieve more accurate and forward-looking traffic management; first, user behavior data is introduced, combined with the preprocessing results of historical traffic data, and a time series prediction model is used to achieve accurate traffic prediction, with the aim of identifying and responding to traffic peaks in advance; then, a diversion strategy is adaptively formulated based on the traffic prediction results. The diversion decision not only takes into account resource usage, but also user behavior and traffic trends. It can automatically and timely adjust service resource allocation during traffic peaks, support fast resource scheduling and intelligent request distribution, improve system response speed and processing capabilities, optimize service resource allocation, improve resource utilization and system throughput, achieve more accurate, efficient and personalized traffic management, reduce the risk of service delays and interruptions, and improve user experience.
[0071] Example 2
[0072] This embodiment further describes the step of inputting the user behavior data and the preprocessing result into a preset time series prediction model and outputting the traffic prediction result.
[0073] See also Figure 3 , S3 said time series prediction model comprises a prediction flow network, a long short-term memory network and a weighted hybrid network; said prediction flow network and said long short-term memory network are connected with said weighted hybrid network in parallel;
[0074] The data first input into the time series forecasting model includes:
[0075] Historical Traffic Data (HTD): refers to the traffic indicator records within the past period of time T, which can be the number of requests per hour RHPS. Historical traffic data HTD is expressed as:
[0076] HTD={rhps1,rhps2,...,rhps n}
[0077] Among them, rhps i is the number of requests in the i-th hour;
[0078] Time Features (TF): including hour, weekday, and whether it is a holiday. The time feature TF is expressed as: TF = {hour, weekday, holidayflag};
[0079] User Behavior Features (UBF): including user access frequency UAF, page dwell time DWT, and user path depth UPD. User behavior feature UBF is expressed as:
[0080] UBF={UAF,DWT,UPD}
[0081] Flow fluctuation coefficient FVC: An indicator reflecting flow stability. Flow fluctuation coefficient FVC is expressed as:
[0082] FVC=SD(HTD) / AT(HTD)×100%
[0083] Output traffic forecast results (Traffic Forecast, TFC): prediction of traffic indicators in the future, expressed as:
[0084]
[0085] in, is the number of prediction requests for the i-th hour in the future.
[0086] The prediction process of the time series prediction model includes:
[0087] The predicted traffic network predicts the initial traffic, and the calculation expression of the initial traffic is as follows:
[0088]
[0089] in, represents the initial flow, ARIMA(.) represents the autoregressive moving average model, p represents the autoregressive order, d represents the difference order, and q represents the moving average order;
[0090] The long short-term memory network captures nonlinearity and long-term dependencies. The calculation expression of nonlinearity and long-term dependencies is as follows:
[0091]
[0092] in, Represents nonlinearity and long-term dependencies;
[0093] The weighted hybrid network performs weighted averaging on the initial flow and the nonlinear and long-term dependencies, and outputs the weighted result as follows:
[0094]
[0095] in, represents the weighted result, α represents the weight between 0 and 1, which is adjusted according to the performance of the time series forecasting model on the validation set;
[0096] The weighted result is output as the final traffic prediction result TFC as follows:
[0097]
[0098] In this embodiment, the traffic pattern and FVC obtained in S2, as well as the user behavior data UAF, DWT, and UPD provided by the user behavior analysis module are integrated, and the selected time series prediction model is trained to output the traffic prediction results for a period of time in the future, identify future traffic patterns and possible traffic peaks and troughs, and adaptively formulate diversion strategies based on the traffic prediction results to provide a basis for intelligent diversion decisions.
[0099] Example 3
[0100] This embodiment further describes the adaptive formulation of a traffic diversion strategy based on the traffic prediction result described in S4;
[0101] The traffic diversion strategy includes expansion of service instances, optimization of routing rules and adjustment of request distribution strategy.
[0102] The expansion of service instances is to automatically increase the number of service instances based on the predicted traffic increase; when it is predicted that the traffic will increase significantly in the future, the service instance expansion mechanism is automatically triggered, and the number of service instances is dynamically increased according to the preset expansion rules or algorithms to ensure that the system can provide stable services during high traffic periods;
[0103] The optimization of routing rules is based on real-time analysis of user behavior and traffic patterns. It can adjust request routing rules and intelligently distribute user requests to service instances with lower loads to achieve load balancing and improve overall service efficiency and response speed.
[0104] The request distribution strategy is adjusted dynamically according to the performance and traffic forecast of the service instance.
[0105] The adjustment of the request distribution strategy includes:
[0106] If the traffic prediction result is greater than the high traffic threshold, the request distribution strategy is adjusted to the predicted traffic peak strategy, and the predicted traffic peak strategy is to automatically increase the number of service instances and adjust the load balancing to disperse the traffic; if the traffic prediction result is less than the low traffic threshold, the request distribution strategy is adjusted to the predicted traffic low peak strategy; the predicted traffic low peak strategy is to automatically reduce the number of service instances to save resources; if a special event that affects the traffic prediction result is predicted, the request distribution strategy is adjusted to a special event response strategy to cope with the traffic changes caused by the special event; if the deviation between the traffic prediction result and the real-time monitored traffic exceeds the traffic deviation threshold, the request distribution strategy is adjusted to a real-time traffic monitoring and adaptive adjustment strategy to quickly respond to traffic changes.
[0107] Example 4
[0108] See also Figure 3 This embodiment proposes an adaptive traffic diversion system based on a microservice architecture, including:
[0109] User behavior analysis module, used to obtain user behavior data;
[0110] A traffic processing module, used to obtain historical traffic data, pre-process the historical traffic data, and obtain a pre-processing result of the historical traffic data;
[0111] A traffic prediction module, used to input the user behavior data and preprocessing results into a preset time series prediction model and output a traffic prediction result;
[0112] The adaptive traffic diversion decision module is used to adaptively formulate a traffic diversion strategy according to the traffic prediction result.
[0113] It also includes a resource scheduling module, which is used to execute the diversion strategy, realize rapid expansion and contraction of service instances, and intelligently distribute request distribution strategies to achieve optimal allocation of resources.
[0114] In this embodiment, user behavior data is first introduced, combined with the preprocessing results of historical traffic data, and a time series prediction model is used to achieve accurate traffic prediction, with the aim of identifying and responding to traffic peaks in advance; then, a diversion strategy is adaptively formulated based on the traffic prediction results. The diversion decision not only considers resource usage, but also user behavior and traffic trends. It can automatically adjust service resource allocation in a timely manner during traffic peaks, support fast resource scheduling and intelligent request distribution, improve system response speed and processing capabilities, optimize service resource allocation, improve resource utilization and system throughput, achieve more accurate, efficient and personalized traffic management, reduce the risk of service delays and interruptions, and enhance user experience.
[0115] Obviously, the above embodiments of the present invention are only examples for clearly illustrating the present invention, and are not intended to limit the implementation methods of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all implementation methods here. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the claims of the present invention.
Claims
1. An adaptive traffic diversion method based on microservice architecture, characterized in that: The following steps are involved: Obtain user behavior data and historical traffic data; Preprocessing the historical traffic data to obtain a preprocessing result of the historical traffic data; Input the user behavior data and preprocessing results into a preset time series prediction model, and output a traffic prediction result; Based on the traffic prediction results, a traffic diversion strategy is adaptively formulated.
2. The adaptive traffic diversion method based on microservice architecture according to claim 1 is characterized in that: The user behavior data includes user access frequency UAF, page dwell time DWT and user path depth UPD.
3. The adaptive traffic diversion method based on microservice architecture according to claim 1 is characterized in that: The preprocessing of the historical traffic data to obtain the preprocessing result of the historical traffic data includes: Using a clustering algorithm to group the historical traffic data to obtain several groups of traffic patterns; Calculate the flow fluctuation coefficient under each set of flow patterns; The flow pattern and the flow fluctuation coefficient are defined as the preprocessing result.
4. The adaptive traffic diversion method based on microservice architecture according to claim 3 is characterized in that: The calculation of the flow fluctuation coefficient under each group of flow modes includes: Collect the number of requests per hour with high traffic volume RHPS in the selected time window T, and store the number of requests per hour RHPS in the time series array traffic_data; Based on the time series array traffic_data, the average value AT of the traffic is calculated as follows: Where m represents the number of hours in the time window T, traffic_data t It represents the number of requests per hour RHPS in the tth hour in the time window T; Based on the average value AT, the standard deviation SD of the flow rate is calculated as follows: Based on the standard deviation SD and the average value AT, the flow fluctuation coefficient is calculated as follows: Wherein, FVC represents the flow fluctuation coefficient.
5. The adaptive traffic diversion method based on microservice architecture according to claim 1 is characterized in that: The time series prediction model includes a prediction flow network, a long short-term memory network and a weighted hybrid network; the prediction flow network and the long short-term memory network are connected to the weighted hybrid network in parallel; the prediction flow network predicts the initial flow, the long short-term memory network captures nonlinearity and long-term dependencies, and the weighted hybrid network performs weighted averaging on the initial flow and the nonlinearity and long-term dependencies, and outputs the weighted result as the final flow prediction result.
6. The adaptive traffic diversion method based on microservice architecture according to claim 1 is characterized in that: The traffic diversion strategy includes expansion of service instances, optimization of routing rules and adjustment of request distribution strategy.
7. The adaptive traffic diversion method based on microservice architecture according to claim 6 is characterized in that: The adjustment of the request distribution strategy includes: if the traffic prediction result is greater than the high traffic threshold, the request distribution strategy is adjusted to the predicted traffic peak strategy; if the traffic prediction result is less than the low traffic threshold, the request distribution strategy is adjusted to the predicted traffic low peak strategy; if a special event that affects the traffic prediction result is predicted, the request distribution strategy is adjusted to a special event response strategy; if the deviation between the traffic prediction result and the real-time monitored traffic exceeds the traffic deviation threshold, the request distribution strategy is adjusted to the real-time traffic monitoring and adaptive adjustment strategy.
8. The adaptive traffic diversion method based on microservice architecture according to claim 7 is characterized in that: The predicted traffic peak strategy is to automatically increase the number of service instances and adjust the load balancing; the predicted traffic low peak strategy is to automatically reduce the number of service instances.
9. An adaptive traffic diversion system based on microservice architecture, characterized in that: include: User behavior analysis module, used to obtain user behavior data; A traffic processing module, used to obtain historical traffic data, pre-process the historical traffic data, and obtain a pre-processing result of the historical traffic data; A traffic prediction module, used to input the user behavior data and preprocessing results into a preset time series prediction model and output a traffic prediction result; The adaptive traffic diversion decision module is used to adaptively formulate a traffic diversion strategy according to the traffic prediction result.
10. The adaptive traffic diversion system based on microservice architecture according to claim 9, characterized in that: It also includes a resource scheduling module, which is used to execute the diversion strategy.
Citation Information
Cited By
Micro-service tail delay prediction method based on unified system representation
CN122261955A
