Micro-service capacity expansion and contraction method and device, computer equipment, storage medium and computer program product

By preprocessing and feature extraction of the historical load data of microservices, predicting the load data using the load prediction model, and determining the scaling command based on the prediction threshold, the problem of low scaling accuracy of microservices is solved, achieving higher accuracy and less manual intervention.

CN119938478APending Publication Date: 2025-05-06SHENZHEN COMTOP INFORMATION TECH
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510060422.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-15
Publication Date
2025-05-06

AI Technical Summary

Technical Problem

When performing microservice expansion and expansion, the prior art is susceptible to subjective factors, resulting in low accuracy.

Method used

By obtaining the historical load data of the microservice, preprocessing and feature extraction, inputting it into the completed load prediction model for training, predicting the load data, and determining the scaling instruction based on the prediction threshold.

Benefits of technology

It improves the accuracy of microservice expansion and scaling, reduces manual intervention, and avoids the influence of subjective factors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938478A_ABST
    Figure CN119938478A_ABST
Patent Text Reader

Abstract

The invention relates to a micro-service capacity expansion and contraction method and device, computer equipment, a storage medium and a computer program product. The method comprises the steps of obtaining historical load data of a micro-service in a to-be-analyzed micro-service architecture under a preset load performance index; preprocessing the historical load data to obtain preprocessed historical load data; performing feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data; inputting the target feature vector into a trained load prediction model to obtain predicted load data of the micro-service; according to the preprocessed historical load data, determining a prediction threshold value of the micro-service, and according to the difference between the prediction load data and the prediction threshold value, determining a micro-service capacity expansion and contraction instruction of the micro-service architecture to be analyzed; and according to the micro-service capacity expansion and shrinkage instruction, performing corresponding micro-service capacity expansion and shrinkage processing on the to-be-analyzed micro-service architecture. By adopting the method, the micro-service capacity expansion and contraction accuracy can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a microservice scaling method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] At present, in order to optimize resource utilization and system performance, it is crucial to effectively scale microservices.

[0003] In traditional technology, in the process of scaling microservices, manual decision-making is generally adopted; however, this method is easily affected by subjective factors, resulting in low accuracy in scaling microservices. Summary of the invention

[0004] Based on this, it is necessary to provide a microservice scaling method, apparatus, computer device, computer-readable storage medium and computer program product that can improve the accuracy of microservice scaling in order to address the above technical problems.

[0005] In a first aspect, the present application provides a microservice scaling method, including:

[0006] Obtaining historical load data of microservices in a microservice architecture to be analyzed under preset load performance indicators; the microservice architecture to be analyzed is deployed in a target container orchestration platform;

[0007] Preprocessing the historical load data to obtain preprocessed historical load data;

[0008] Performing feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data;

[0009] Inputting the target feature vector into the trained load prediction model to obtain predicted load data of the microservice;

[0010] Determine a prediction threshold of the microservice according to the preprocessed historical load data, and determine a microservice scaling instruction of the microservice architecture to be analyzed according to a difference between the predicted load data and the predicted threshold; the predicted threshold is used to represent a predicted load data threshold;

[0011] According to the microservice scaling instruction, corresponding microservice scaling processing is performed on the microservice architecture to be analyzed.

[0012] In one embodiment, before obtaining the historical load data of the microservices in the microservice architecture to be analyzed under the preset load performance index, the method further includes:

[0013] Acquire business scenario information and user behavior pattern information of the microservice, and candidate load performance indicators associated with the microservice;

[0014] From each of the candidate load performance indicators, select a candidate load performance indicator that satisfies both the business scenario information and the user behavior pattern information as the current load performance indicator corresponding to the microservice;

[0015] Determining the importance of each of the current load performance indicators;

[0016] From the current load performance indicators, a current load performance indicator whose importance is greater than a preset importance is selected as the preset load performance indicator.

[0017] In one embodiment, determining the prediction threshold of the microservice according to the preprocessed historical load data includes:

[0018] Obtaining the average value and standard deviation corresponding to the preprocessed historical load data;

[0019] Determine a first weight corresponding to the average value and a second weight corresponding to the standard deviation;

[0020] The average value and the standard deviation are summed according to the first weight and the second weight to obtain the prediction threshold.

[0021] In one embodiment, determining the microservice scaling instruction of the microservice architecture to be analyzed according to the difference between the predicted load data and the predicted threshold value includes:

[0022] When the predicted load data is greater than the predicted threshold, determining that the microservice scaling instruction of the microservice architecture to be analyzed is a scaling instruction;

[0023] or,

[0024] When the predicted load data is less than the predicted threshold, determining that the microservice scaling instruction of the microservice architecture to be analyzed is a scaling instruction;

[0025] or,

[0026] When the predicted load data is equal to the predicted threshold, it is determined that the microservice scaling instruction of the microservice architecture to be analyzed is a maintenance instruction.

[0027] In one embodiment, the performing feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data includes:

[0028] Obtaining a timestamp corresponding to the preprocessed historical load data;

[0029] Determine a first data type corresponding to the preprocessed historical load data and a second data type corresponding to the timestamp;

[0030] According to the first data type and the second data type, respectively, the corresponding relationship between the data type and the feature extraction model is queried to determine the first feature extraction model corresponding to the preprocessed historical load data and the second feature extraction model corresponding to the timestamp;

[0031] Inputting the preprocessed historical load data into the first feature extraction model for feature extraction processing to obtain a first feature vector corresponding to the preprocessed historical load data, and inputting the timestamp into the second feature extraction model for feature extraction processing to obtain a second feature vector corresponding to the timestamp;

[0032] The first feature vector and the second feature vector are concatenated to obtain the target feature vector.

[0033] In one embodiment, the trained load prediction model is trained in the following manner:

[0034] Obtaining multiple candidate load prediction models and the prediction efficiency of each candidate load prediction model;

[0035] Selecting the candidate load prediction model with the highest prediction efficiency from each of the candidate load prediction models as the load prediction model to be trained;

[0036] Get sample historical load data of sample microservices;

[0037] Preprocessing the sample historical load data to obtain preprocessed sample historical load data;

[0038] Performing feature extraction processing on the preprocessed sample historical load data to obtain a sample target feature vector corresponding to the preprocessed sample historical load data;

[0039] Inputting the sample target feature vector into the load prediction model to be trained to obtain predicted load data of the sample microservice;

[0040] Acquire actual load data of the sample microservice, and obtain a mean square error loss value according to a difference between the actual load data and the predicted load data of the sample microservice;

[0041] According to the mean square error loss value, the load prediction model to be trained is iteratively trained to obtain the trained load prediction model.

[0042] In a second aspect, the present application also provides a microservice scaling device, including:

[0043] A data acquisition module, used to acquire historical load data of microservices in a microservice architecture to be analyzed under a preset load performance indicator; the microservice architecture to be analyzed is deployed in a target container orchestration platform;

[0044] A data processing module, used for preprocessing the historical load data to obtain preprocessed historical load data;

[0045] A feature extraction module, used to perform feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data;

[0046] A load prediction module, used to input the target feature vector into the trained load prediction model to obtain predicted load data of the microservice;

[0047] An instruction determination module is used to determine a prediction threshold of the microservice according to the preprocessed historical load data, and to determine a microservice scaling instruction of the microservice architecture to be analyzed according to a difference between the predicted load data and the predicted threshold; the predicted threshold is used to represent a predicted load data threshold;

[0048] The architecture processing module is used to perform corresponding microservice expansion and contraction processing on the microservice architecture to be analyzed according to the microservice expansion and contraction instruction.

[0049] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0050] Obtaining historical load data of microservices in a microservice architecture to be analyzed under preset load performance indicators; the microservice architecture to be analyzed is deployed in a target container orchestration platform;

[0051] Preprocessing the historical load data to obtain preprocessed historical load data;

[0052] Performing feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data;

[0053] Inputting the target feature vector into the trained load prediction model to obtain predicted load data of the microservice;

[0054] Determine a prediction threshold of the microservice according to the preprocessed historical load data, and determine a microservice scaling instruction of the microservice architecture to be analyzed according to a difference between the predicted load data and the predicted threshold; the predicted threshold is used to represent a predicted load data threshold;

[0055] According to the microservice scaling instruction, corresponding microservice scaling processing is performed on the microservice architecture to be analyzed.

[0056] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0057] Obtaining historical load data of microservices in a microservice architecture to be analyzed under preset load performance indicators; the microservice architecture to be analyzed is deployed in a target container orchestration platform;

[0058] Preprocessing the historical load data to obtain preprocessed historical load data;

[0059] Performing feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data;

[0060] Inputting the target feature vector into the trained load prediction model to obtain predicted load data of the microservice;

[0061] Determine a prediction threshold of the microservice according to the preprocessed historical load data, and determine a microservice scaling instruction of the microservice architecture to be analyzed according to a difference between the predicted load data and the predicted threshold; the predicted threshold is used to represent a predicted load data threshold;

[0062] According to the microservice scaling instruction, corresponding microservice scaling processing is performed on the microservice architecture to be analyzed.

[0063] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0064] Obtaining historical load data of microservices in a microservice architecture to be analyzed under preset load performance indicators; the microservice architecture to be analyzed is deployed in a target container orchestration platform;

[0065] Preprocessing the historical load data to obtain preprocessed historical load data;

[0066] Performing feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data;

[0067] Inputting the target feature vector into the trained load prediction model to obtain predicted load data of the microservice;

[0068] Determine a prediction threshold of the microservice according to the preprocessed historical load data, and determine a microservice scaling instruction of the microservice architecture to be analyzed according to a difference between the predicted load data and the predicted threshold; the predicted threshold is used to represent a predicted load data threshold;

[0069] According to the microservice scaling instruction, corresponding microservice scaling processing is performed on the microservice architecture to be analyzed.

[0070] The above-mentioned microservice scaling method, device, computer equipment, storage medium and computer program product first obtain the historical load data of the microservice of the microservice architecture to be analyzed deployed in the target container orchestration platform under the preset load performance indicator, and preprocess the historical load data to obtain the preprocessed historical load data, and then perform feature extraction processing on the preprocessed historical load data to obtain the target feature vector corresponding to the preprocessed historical load data, and then input the target feature vector into the trained load prediction model to obtain the predicted load data of the microservice, and then determine the prediction threshold of the microservice based on the preprocessed historical load data, and determine the microservice scaling instruction of the microservice architecture to be analyzed based on the difference between the predicted load data and the prediction threshold; the prediction threshold is used to represent the predicted load data threshold, and finally, according to the microservice scaling instruction, the corresponding microservice scaling processing is performed on the microservice architecture to be analyzed. In this way, in the process of scaling microservices, the historical load data of the microservices in the microservice architecture to be analyzed is preprocessed, feature extracted and modeled, so that the predicted load data of the microservices in the microservice architecture to be analyzed can be accurately obtained, and combined with the prediction threshold of the microservices, the microservice scaling instructions of the microservice architecture to be analyzed can be accurately determined, which is conducive to improving the processing accuracy of microservice scaling of the microservice architecture to be analyzed, thereby improving the accuracy of microservice scaling; moreover, the entire process does not require human intervention, avoiding the defect that the method of manual participation in decision-making is easily affected by subjective factors, resulting in low accuracy of microservice scaling, and further improving the accuracy of microservice scaling. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0072] Figure 1 A schematic diagram of a process of a microservice scaling method in one embodiment;

[0073] Figure 2 A schematic diagram of a process of a microservice scaling method in another embodiment;

[0074] Figure 3 The figure is a flow chart of a method for dynamic expansion and contraction of microservices based on containers in one embodiment;

[0075] Figure 4 This is a structural block diagram of a microservice expansion and contraction device in an embodiment;

[0076] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0077] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0078] 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 used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0079] In an exemplary embodiment, Figure 1 As shown, a microservice scaling method is provided. This embodiment uses the method applied to a server as an example for illustration; it is understandable that the method can also be applied to a terminal, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. Among them, the terminal can be but is not limited to various personal computers, laptops, smart phones and tablets; the server can be implemented with an independent server or a server cluster composed of multiple servers. In this embodiment, the method includes the following steps:

[0080] Step S101, obtaining historical load data of microservices in the microservice architecture to be analyzed under preset load performance indicators; the microservice architecture to be analyzed is deployed in a target container orchestration platform.

[0081] The microservice architecture to be analyzed refers to the microservice architecture that needs to be analyzed, including multiple microservices.

[0082] The preset load performance indicators refer to pre-set load performance indicators, such as CPU (Central Processing Unit) usage, memory usage, QPS (Queries Per Second), response time, and throughput.

[0083] The historical load data refers to the load data over a period of time in the past (such as the past week, the past month, etc.).

[0084] Among them, the target container orchestration platform refers to the container orchestration Kubernetes (K8s, an open source container orchestration platform) platform.

[0085] Exemplarily, the server obtains candidate load performance indicators associated with microservices in the microservice architecture to be analyzed that is deployed in the target container orchestration platform; then, the server selects preset load performance indicators from each candidate load performance indicator; then, the server obtains the load data of the microservice under the preset load performance indicator for a period of time in the past as historical load data.

[0086] Step S102, preprocessing the historical load data to obtain preprocessed historical load data.

[0087] Among them, preprocessing includes removing null values, removing outliers, Min-Max (Minimum-Maximum) standardization, etc.

[0088] The preprocessed historical load data refers to the preprocessed historical load data.

[0089] Exemplarily, the server performs null value removal processing, outlier removal processing and standardization processing on the historical load data to obtain pre-processed historical load data.

[0090] Step S103, performing feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data.

[0091] The target feature vector is used to represent the feature vector corresponding to the preprocessed historical load data.

[0092] Exemplarily, the server determines a feature extraction model corresponding to the preprocessed historical load data based on the data type corresponding to the preprocessed historical load data; then, the server inputs the preprocessed historical load data into the feature extraction model corresponding to the preprocessed historical load data, performs feature extraction processing on the preprocessed historical load data through the feature extraction model, and obtains a target feature vector corresponding to the preprocessed historical load data.

[0093] Step S104: input the target feature vector into the trained load prediction model to obtain the predicted load data of the microservice.

[0094] The load prediction model refers to a network model that can predict the predicted load data of microservices, such as the LSTM (Long Short-Term Memory) model.

[0095] Among them, the predicted load data of the microservice refers to the load data of the microservice in the future (such as the next week, the next month, etc.).

[0096] Exemplarily, the server determines the historical load prediction model corresponding to the trained load prediction model; then, the server inputs the target feature vector into the trained load prediction model to obtain the predicted load data output by the trained load prediction model, and inputs the target feature vector into the historical load prediction model to obtain the predicted load data output by the historical load prediction model; then, the server determines the first model weight corresponding to the trained load prediction model, and the second model weight corresponding to the historical load prediction model; then, the server sums the predicted load data output by the trained load prediction model and the predicted load data output by the historical load prediction model according to the first model weight and the second model weight to obtain the predicted load data of the microservice.

[0097] Step S105, determining a predicted threshold of the microservice based on the preprocessed historical load data, and determining microservice scaling instructions for the microservice architecture to be analyzed based on the difference between the predicted load data and the predicted threshold; the predicted threshold is used to represent the predicted load data threshold.

[0098] The prediction threshold is used to represent the predicted load data threshold, and is used to judge the predicted load data.

[0099] Among them, the microservice expansion and contraction instructions refer to the instruction information for adjusting the number of microservices in the microservice architecture to be analyzed, including expansion instructions, contraction instructions and maintenance instructions.

[0100] Exemplarily, the server queries the correspondence between the load data and the load data threshold based on the preprocessed historical load data, and obtains the load data threshold corresponding to the preprocessed historical load data as the predicted threshold of the microservice; then, the server determines the instruction information for adjusting the number of microservices in the microservice architecture to be analyzed based on the difference between the predicted load data and the predicted threshold, as the microservice scaling instruction of the microservice architecture to be analyzed.

[0101] Step S106: According to the microservice scaling instruction, corresponding microservice scaling processing is performed on the microservice architecture to be analyzed.

[0102] Exemplarily, the server performs an integrity check on the microservice scaling instructions to obtain an integrity check result corresponding to the microservice scaling instructions; when the integrity check result indicates that the microservice scaling instructions are complete, the server performs corresponding microservice scaling processing on the microservice architecture to be analyzed according to the microservice scaling instructions.

[0103] In the above-mentioned microservice scaling method, the historical load data of the microservice of the microservice architecture to be analyzed deployed in the target container orchestration platform under the preset load performance indicator is first obtained, and the historical load data is preprocessed to obtain the preprocessed historical load data, and then the preprocessed historical load data is subjected to feature extraction processing to obtain the target feature vector corresponding to the preprocessed historical load data. Next, the target feature vector is input into the trained load prediction model to obtain the predicted load data of the microservice, and then, based on the preprocessed historical load data, the prediction threshold of the microservice is determined, and based on the difference between the predicted load data and the prediction threshold, the microservice scaling instruction of the microservice architecture to be analyzed is determined; the prediction threshold is used to represent the predicted load data threshold, and finally, according to the microservice scaling instruction, the corresponding microservice scaling processing is performed on the microservice architecture to be analyzed. In this way, in the process of scaling microservices, the historical load data of the microservices in the microservice architecture to be analyzed is preprocessed, feature extracted and modeled, so that the predicted load data of the microservices in the microservice architecture to be analyzed can be accurately obtained, and combined with the prediction threshold of the microservices, the microservice scaling instructions of the microservice architecture to be analyzed can be accurately determined, which is conducive to improving the processing accuracy of microservice scaling of the microservice architecture to be analyzed, thereby improving the accuracy of microservice scaling; moreover, the entire process does not require human intervention, avoiding the defect that the method of manual participation in decision-making is easily affected by subjective factors, resulting in low accuracy of microservice scaling, and further improving the accuracy of microservice scaling.

[0104] In an exemplary embodiment, the above-mentioned step S101, before obtaining the historical load data of the microservice in the microservice architecture to be analyzed under the preset load performance indicator, specifically includes the following contents: obtaining the business scenario information and user behavior pattern information of the microservice, and the candidate load performance indicators associated with the microservice; from each candidate load performance indicator, screening out the candidate load performance indicators that meet both the business scenario information and the user behavior pattern information as the current load performance indicators corresponding to the microservice; determining the importance of each current load performance indicator; from each current load performance indicator, screening out the current load performance indicator whose importance is greater than the preset importance as the preset load performance indicator.

[0105] Among them, the business scenario information is used to represent the business activity information involved in the microservice (such as business functions, business rules, etc.).

[0106] Among them, user behavior pattern information is used to represent the interaction information between users and microservices, such as user usage frequency, user operation sequence, etc.

[0107] The candidate load performance indicator is used to represent the load performance indicator to be selected.

[0108] The current load performance indicator refers to a candidate load performance indicator that satisfies both business scenario information and user behavior pattern information.

[0109] The importance is used to indicate the importance of the current load performance indicator.

[0110] The preset importance refers to a preset importance threshold. It should be noted that the preset importance depends on the situation.

[0111] Exemplarily, the server obtains business scenario information and user behavior pattern information of the microservice, as well as candidate load performance indicators associated with the microservice from a database; then, the server selects candidate load performance indicators that meet both the business scenario information and the user behavior pattern information from each candidate load performance indicator, and uses these candidate load performance indicators as current load performance indicators corresponding to the microservice; then, the server inputs each current load performance indicator into the trained importance prediction model, and obtains the importance of each current load performance indicator through the trained importance prediction model; then, the server selects current load performance indicators whose importance is greater than a preset importance from each current load performance indicator, and uses these current load performance indicators as preset load performance indicators.

[0112] In this embodiment, by using the business scenario information and user behavior pattern information of the microservice, as well as indicators such as importance, more accurate preset load performance indicators can be screened out from the candidate load performance indicators associated with the microservice, and then more accurate load performance indicators can be matched for the microservice, which is beneficial to improving the accuracy of determining the preset load performance indicators.

[0113] In an exemplary embodiment, the above step S105 determines the prediction threshold of the microservice based on the preprocessed historical load data, and specifically includes the following contents: obtaining the average value and standard deviation corresponding to the preprocessed historical load data; determining a first weight corresponding to the average value, and a second weight corresponding to the standard deviation; and summing the average value and the standard deviation according to the first weight and the second weight to obtain the prediction threshold.

[0114] The first weight is used to represent the weight value corresponding to the average value. In an actual scenario, the first weight is 1.

[0115] The second weight is used to represent the weight value corresponding to the standard deviation. In actual scenarios, the second weight is the confidence coefficient k, and the value depends on the situation.

[0116] Exemplarily, the server determines the average value and standard deviation corresponding to the preprocessed historical load data based on the value of each sub-preprocessed historical load data in the preprocessed historical load data; then, the server determines the weight value corresponding to the average value as the first weight, and determines the weight value corresponding to the standard deviation as the second weight; then, the server sums the average value and the standard deviation based on the first weight and the second weight to obtain the prediction threshold.

[0117] For example, when the pre-processed historical load data is CPU usage, the prediction threshold of CPU usage can be determined by the following formula:

[0118] T_cpu=μ_cpu+k*σ_cpu, formula (1)

[0119] Among them, T_cpu refers to the prediction threshold, μ_cpu refers to the average value of historical CPU usage, k refers to the confidence coefficient, and σ_cpu refers to the standard deviation of historical CPU usage.

[0120] In this embodiment, by combining the mean value, standard deviation and their weights, the corresponding prediction threshold can be determined more accurately. Compared with using a fixed value, such a determination process can more accurately reflect the actual load situation, which is conducive to improving the reliability of the prediction threshold and providing a reliable data basis for subsequent analysis.

[0121] In an exemplary embodiment, the above-mentioned step S105 determines the microservice scaling instructions of the microservice architecture to be analyzed based on the difference between the predicted load data and the predicted threshold, and specifically includes the following contents: when the predicted load data is greater than the predicted threshold, the microservice scaling instructions of the microservice architecture to be analyzed are determined to be expansion instructions; or, when the predicted load data is less than the predicted threshold, the microservice scaling instructions of the microservice architecture to be analyzed are determined to be shrinking instructions; or, when the predicted load data is equal to the predicted threshold, the microservice scaling instructions of the microservice architecture to be analyzed are determined to be maintenance instructions.

[0122] The expansion instruction refers to instruction information for increasing the number of microservices in the microservice architecture to be analyzed.

[0123] The scaling-down instruction refers to instruction information for reducing the number of microservices in the microservice architecture to be analyzed.

[0124] The maintenance instruction refers to instruction information that keeps the number of microservices in the microservice architecture to be analyzed unchanged.

[0125] Exemplarily, the server compares the predicted load data and the predicted threshold to obtain a comparison result; when the comparison result indicates that the predicted load data is greater than the predicted threshold, the server determines that the microservice scaling instructions of the microservice architecture to be analyzed are expansion instructions; when the comparison result indicates that the predicted load data is less than the predicted threshold, the server determines that the microservice scaling instructions of the microservice architecture to be analyzed are scaling instructions; when the comparison result indicates that the predicted load data is equal to the predicted threshold, the server determines that the microservice scaling instructions of the microservice architecture to be analyzed are maintenance instructions.

[0126] In this embodiment, by determining the size relationship between the predicted load data and the predicted threshold, the microservice scaling instructions of the microservice architecture to be analyzed can be accurately determined, thereby improving the accuracy of determining the microservice scaling instructions, which is beneficial to improving the operating stability of the microservice architecture to be analyzed.

[0127] In an exemplary embodiment, the above step S103 performs feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data, which specifically includes the following contents: obtaining a timestamp corresponding to the preprocessed historical load data; determining a first data type corresponding to the preprocessed historical load data, and a second data type corresponding to the timestamp; querying the correspondence between the data type and the feature extraction model according to the first data type and the second data type, respectively, to determine a first feature extraction model corresponding to the preprocessed historical load data, and a second feature extraction model corresponding to the timestamp; inputting the preprocessed historical load data into the first feature extraction model for feature extraction processing to obtain a first feature vector corresponding to the preprocessed historical load data, and inputting the timestamp into the second feature extraction model for feature extraction processing to obtain a second feature vector corresponding to the timestamp; concatenating the first feature vector and the second feature vector to obtain a target feature vector.

[0128] The timestamp is used to record the specific time when the historical load data is generated after preprocessing.

[0129] The first data type refers to the data type corresponding to the pre-processed historical load data.

[0130] The second data type refers to the data type corresponding to the timestamp.

[0131] The correspondence between the data type and the feature extraction model is used to represent the association information between the data type and the feature extraction model. For example, data type A corresponds to feature extraction model a, data type B corresponds to feature extraction model b, and data type C corresponds to feature extraction model c.

[0132] The first feature extraction model refers to the feature extraction model corresponding to the preprocessed historical load data.

[0133] The second feature extraction model refers to the feature extraction model corresponding to the timestamp.

[0134] The first eigenvector refers to the eigenvector corresponding to the preprocessed historical load data.

[0135] The second feature vector refers to the feature vector corresponding to the timestamp.

[0136] Exemplarily, the server obtains the timestamp corresponding to the preprocessed historical load data from the database; then, the server determines the first data type corresponding to the preprocessed historical load data according to the data features corresponding to the preprocessed historical load data, and determines the second data type corresponding to the timestamp according to the data features corresponding to the timestamp; then, the server queries the correspondence between the data type and the feature extraction model according to the first data type, and determines the feature extraction model corresponding to the first data type as the first feature extraction model corresponding to the preprocessed historical load data, and queries the correspondence between the data type and the feature extraction model according to the second data type, and determines the feature extraction model corresponding to the second data type as the second feature extraction model corresponding to the timestamp; then, the server inputs the preprocessed historical load data into the first feature extraction model for feature extraction processing, and obtains the feature vector corresponding to the preprocessed historical load data as the first feature vector, and inputs the timestamp into the second feature extraction model for feature extraction processing, and obtains the feature vector corresponding to the timestamp as the second feature vector; then, the server determines the splicing order corresponding to the first feature vector and the second feature vector, and splices the first feature vector and the second feature vector according to the splicing order to obtain the target feature vector.

[0137] In this embodiment, by combining the timestamp corresponding to the preprocessed historical load data and determining the first data type of the preprocessed historical load data and the second feature extraction model corresponding to the timestamp, the characteristics contained in the data itself can be deeply mined, and then the target feature vector can be determined more accurately, providing a reference for subsequent data analysis.

[0138] In an exemplary embodiment, the microservice scaling method provided in the present application also includes a training step for a trained load prediction model, which specifically includes the following contents: obtaining multiple candidate load prediction models and the prediction efficiency of each candidate load prediction model; screening out the candidate load prediction model with the highest prediction efficiency from each candidate load prediction model as the load prediction model to be trained; obtaining sample historical load data of a sample microservice; preprocessing the sample historical load data to obtain preprocessed sample historical load data; performing feature extraction processing on the preprocessed sample historical load data to obtain a sample target feature vector corresponding to the preprocessed sample historical load data; inputting the sample target feature vector into the load prediction model to be trained to obtain the predicted load data of the sample microservice; obtaining the actual load data of the sample microservice, and obtaining a mean square error loss value based on the difference between the actual load data and the predicted load data of the sample microservice; iteratively training the load prediction model to be trained based on the mean square error loss value to obtain a trained load prediction model.

[0139] The candidate load prediction model refers to the load prediction model to be selected.

[0140] The prediction efficiency is used to indicate the prediction speed of the candidate load prediction model.

[0141] The sample microservice refers to a microservice used to train the load prediction model to be trained.

[0142] The sample historical load data refers to the historical load data of the sample microservice.

[0143] The preprocessed sample historical load data refers to the sample historical load data after preprocessing.

[0144] The sample target feature vector is used to represent the feature vector corresponding to the sample historical load data after preprocessing.

[0145] The predicted load data of the sample microservice refers to the predicted value corresponding to the future load data of the sample microservice.

[0146] The actual load data of the sample microservice refers to the actual value corresponding to the future load data of the sample microservice.

[0147] Among them, the mean square error loss value is an indicator used to measure the difference between the predicted value and the true value.

[0148] Exemplarily, the server obtains multiple candidate load prediction models and the prediction efficiency of each candidate load prediction model from the database; then, the server selects the candidate load prediction model with the highest prediction efficiency from each candidate load prediction model, and uses the candidate load prediction model as the load prediction model to be trained; then, the server obtains sample historical load data of the sample microservice from the database; then, the server preprocesses the sample historical load data to obtain preprocessed sample historical load data; then, the server performs feature extraction processing on the preprocessed sample historical load data to obtain a sample target feature vector corresponding to the preprocessed sample historical load data; then, the server The server inputs the sample target feature vector into the load prediction model to be trained to obtain the predicted load data of the sample microservice; then, the server obtains the actual load data of the sample microservice, and obtains the mean square error loss value based on the difference between the actual load data and the predicted load data of the sample microservice; then, the server adjusts the model parameters of the load prediction model to be trained according to the mean square error loss value; then, the server re-trains the load prediction model after the model parameters are adjusted until the mean square error loss value obtained by the trained load prediction model is less than the loss value threshold, then stops training, and uses the trained load prediction model as the trained load prediction model.

[0149] In this embodiment, by pre-training the load prediction model, it is convenient to predict the predicted load data of the microservice after obtaining the historical load data of the microservice in actual application; moreover, the load prediction model receives new data in each round of iteration, and performs internal improvements and optimizations on the model, so that predictions can be made more effectively, which is beneficial to improving the prediction accuracy of the load prediction model.

[0150] In an exemplary embodiment, Figure 2 As shown, another microservice scaling method is provided, which is described by taking the application of this method to a server as an example, and includes the following steps:

[0151] Step S201, obtain business scenario information and user behavior pattern information of the microservice, as well as candidate load performance indicators associated with the microservice; from each candidate load performance indicator, select a candidate load performance indicator that satisfies both the business scenario information and the user behavior pattern information as the current load performance indicator corresponding to the microservice.

[0152] Step S202, determining the importance of each current load performance indicator; and selecting from the current load performance indicators the current load performance indicators whose importance is greater than a preset importance as the preset load performance indicator.

[0153] Step S203, obtaining historical load data of microservices in the microservice architecture to be analyzed under preset load performance indicators; the microservice architecture to be analyzed is deployed in the target container orchestration platform.

[0154] Step S204, preprocessing the historical load data to obtain preprocessed historical load data.

[0155] Step S205, obtaining a timestamp corresponding to the preprocessed historical load data; determining a first data type corresponding to the preprocessed historical load data, and a second data type corresponding to the timestamp.

[0156] Step S206, querying the correspondence between the data type and the feature extraction model according to the first data type and the second data type, respectively, to determine the first feature extraction model corresponding to the preprocessed historical load data and the second feature extraction model corresponding to the timestamp.

[0157] Step S207, input the preprocessed historical load data into the first feature extraction model for feature extraction processing to obtain a first feature vector corresponding to the preprocessed historical load data, and input the timestamp into the second feature extraction model for feature extraction processing to obtain a second feature vector corresponding to the timestamp.

[0158] Step S208: concatenate the first feature vector and the second feature vector to obtain a target feature vector.

[0159] Step S209: input the target feature vector into the trained load prediction model to obtain the predicted load data of the microservice.

[0160] Step S210, obtaining the average value and standard deviation corresponding to the preprocessed historical load data; determining a first weight corresponding to the average value and a second weight corresponding to the standard deviation.

[0161] Step S211, according to the first weight and the second weight, the average value and the standard deviation are summed to obtain a prediction threshold; the prediction threshold is used to represent the predicted load data threshold.

[0162] Step S212, when the predicted load data is greater than the predicted threshold, determine that the microservice scaling instructions of the microservice architecture to be analyzed are expansion instructions; or, when the predicted load data is less than the predicted threshold, determine that the microservice scaling instructions of the microservice architecture to be analyzed are shrinking instructions; or, when the predicted load data is equal to the predicted threshold, determine that the microservice scaling instructions of the microservice architecture to be analyzed are maintenance instructions.

[0163] Step S213: According to the microservice scaling instruction, corresponding microservice scaling processing is performed on the microservice architecture to be analyzed.

[0164] In the above-mentioned microservice scaling method, during the process of microservice scaling, the historical load data of the microservices in the microservice architecture to be analyzed is preprocessed, feature extracted and modeled, so that the predicted load data of the microservices in the microservice architecture to be analyzed can be accurately obtained, and combined with the prediction threshold of the microservice, the microservice scaling instructions of the microservice architecture to be analyzed can be accurately determined, which is conducive to improving the processing accuracy of microservice scaling of the microservice architecture to be analyzed, thereby improving the accuracy of microservice scaling; moreover, the entire process does not require human intervention, avoiding the defect that the method of human participation in decision-making is easily affected by subjective factors, resulting in low accuracy of microservice scaling, and further improving the accuracy of microservice scaling.

[0165] In an exemplary embodiment, in order to more clearly illustrate the microservice scaling method provided in the embodiment of the present application, the microservice scaling method is specifically described below with a specific embodiment. Figure 3 As shown, the present application also provides a method for dynamic scaling of microservices based on containers. In the process of scaling microservices, the historical load data of the microservices of the microservice architecture to be analyzed deployed in the target container orchestration platform under the preset load performance indicators is first obtained, and the historical load data is preprocessed to obtain the preprocessed historical load data, and then the preprocessed historical load data is subjected to feature extraction processing to obtain the target feature vector corresponding to the preprocessed historical load data. Then, the target feature vector is input into the trained load prediction model to obtain the predicted load data of the microservice. Then, according to the preprocessed historical load data, the prediction threshold of the microservice is determined, and according to the difference between the predicted load data and the prediction threshold, the microservice scaling instruction of the microservice architecture to be analyzed is determined; the prediction threshold is used to represent the predicted load data threshold. Finally, according to the microservice scaling instruction, the corresponding microservice scaling processing is performed on the microservice architecture to be analyzed. Specifically, it includes the following contents:

[0166] Step 1: Analyze business needs and determine the performance indicators of microservices, including response time, throughput, etc. Determine the trigger conditions for scaling, including CPU usage, memory usage, and QPS.

[0167] Step 2: Build a container orchestration Kubernetes platform and deploy microservices to the container orchestration platform to ensure that microservices have the conditions for containerized operation.

[0168] Step 3: Deploy monitoring tools, such as Prometheus, to collect performance metrics of microservices. Set monitoring alarm rules, such as triggering an alarm when CPU usage exceeds 80%.

[0169] Step 4: Define scaling thresholds based on business needs, adopt predictive scaling strategies, analyze historical performance data through machine learning models, predict future loads and set dynamic thresholds to achieve intelligent scaling of microservices, and combine time series analysis and business characteristics to provide forward-looking resource management for microservices.

[0170] Step 5: Write a scaling script based on monitoring data, such as using Kubernetes' Horizontal PodAutoscaler. The script contains scaling logic, such as adjusting the number of replicas based on monitoring indicators.

[0171] Step 6: Deploy the scaling script to the container orchestration platform to ensure that the script can run normally. Test the functionality of the scaling script to ensure that the scaling operation can be performed correctly under the triggering conditions.

[0172] Step 7: Start the monitoring and alarm system to monitor the microservice performance indicators in real time. When the performance indicators reach the scaling threshold, the scaling script is triggered.

[0173] Step 8: Observe the microservice performance indicators after the scaling operation, such as response time, throughput, etc. Analyze whether the scaling operation achieves the expected effect, and adjust the scaling strategy if necessary.

[0174] Step 9: Continuously optimize the scaling strategy based on business development and actual operation. Regularly review and adjust monitoring indicators and alarm rules to ensure that the scaling method always meets business needs.

[0175] In step 1, the business scenarios and user behavior patterns of microservices are determined; key performance indicators are determined, including: average response time less than 200 milliseconds, QPS must reach more than 1000; historical logs and user access data are analyzed to identify peak traffic periods, such as 2 pm every day and during promotional activities; this information is organized into documents as a basis for subsequent strategy formulation.

[0176] In step 2, install Kubernetes on a cloud platform or physical server, configure Master and Worker nodes; set network policies to ensure communication between microservices; deploy monitoring tools such as Prometheus and Grafana to collect performance data; package microservices into Docker images and deploy them through Kubernetes' Deployment resources, and configure HorizontalPodAutoscaler to achieve basic elasticity.

[0177] In step 3, configure Prometheus to capture microservice metrics such as CPU and memory usage; set up a Grafana (an analysis and visualization platform) dashboard to visualize these metrics; and regularly export and store monitoring data in a time series database such as InfluxDB (Influx DataBase, a time series database) for historical data analysis.

[0178] In step 4, predictive scaling is performed using the long short-term memory network algorithm in time series prediction. The specific steps include:

[0179] (1) Data collection:

[0180] Collect the historical performance data set D={d1,d2,…,dn} of the microservice, where each data point di contains timestamp, CPU usage, memory usage, network I / O (input / output), disk I / O, QPS, etc.

[0181] (2) Feature Engineering:

[0182] Extract the feature set F={f1,f2,…,fm}, which may include:

[0183] f1=timestamp t.

[0184] f2=is_weekday.

[0185] f3=specific event flag event_flag.

[0186] The feature engineering formula can be expressed as: X=φ(D), where φ is the feature extraction function.

[0187] (3) Model training:

[0188] Use LSTM model for training. The model parameters include:

[0189] The number of input layer nodes is equal to the dimension m of the feature set F.

[0190] Number of hidden layer nodes: h.

[0191] Number of output layer nodes: equal to the predicted target dimension. If the CPU usage is predicted, the number of output layer nodes is 1.

[0192] Learning rate: α.

[0193] Loss function: L(θ)=Σ(yi-ŷi)², where θ is the model parameter, yi is the true value, and ŷi is the predicted value.

[0194] The LSTM training process can be expressed as: θ* = argmin_θ L(θ), where θ* are the optimal model parameters obtained through training.

[0195] (4)Predict future load:

[0196] Use the trained LSTM model for prediction. The calculation formula is: ŷ(t + 1) = LSTM(X(t), θ*), where ŷ(t + 1) is the predicted load at time t + 1.

[0197] (5)Define the prediction threshold:

[0198] Set the prediction threshold T. Based on historical performance data and prediction results,

[0199] CPU prediction threshold: T_cpu = μ_cpu + k * σ_cpu, where μ_cpu is the average of historical CPU utilization rates, σ_cpu is the standard deviation, and k is the confidence coefficient.

[0200] (6)Formulate the scaling policy:

[0201] The scaling policy S is defined as:

[0202] If ŷ(t + 1) > T, trigger capacity expansion;

[0203] If ŷ(t + 1) < T, trigger capacity reduction.

[0204] Among them, the specific operations for capacity expansion and reduction can be further defined as the number of containers or the amount of resources to be increased or decreased.

[0205] Among them, preprocess the data, including removing null values and outliers; use the Min - Max normalization method to scale the data to the [0, 1] interval; extract time window features, using the data points of the past 24 hours as the input features of LSTM; encode external events as binary features to indicate whether the event occurs or not.

[0206] Among them, use the LSTM algorithm to learn time - series data. After constructing the LSTM model, the training steps include:

[0207] (1)Initialize the weight matrices Wf, Wi, Wg, Wo and the bias vectors bf, bi, bg, bo.

[0208] (2)Calculate the hidden state h(t) and output y(t) at each time step through forward propagation.

[0209] (3)Calculate the loss function, mean squared error: Loss = 1 / N * Σ(y(t) - y_true(t))^2, where N is the number of time steps and y_true(t) is the actual value.

[0210] (4) Update the weights and biases through back-propagation and gradient descent algorithms to minimize the loss function.

[0211] (5) Repeat the above steps until the model converges or reaches the preset number of iterations.

[0212] The calculation formula of the forget gate of the LSTM algorithm model is:

[0213] f(t)=σ(Wf*[h(t-1),x(t)]+bf), formula (2)

[0214] Among them, Wf represents the weight matrix of the forget gate, bf represents the bias vector of the forget gate, σ represents the sigmoid activation function, h(t-1) represents the hidden state of the previous time step, and x(t) represents the input of the current time step.

[0215] The calculation formula of the input gate of the LSTM algorithm model is:

[0216] i(t)=σ(Wi*[h(t-1),x(t)]+bi), formula (3)

[0217] Among them, Wi represents the weight matrix of the input gate, and bi represents the bias vector of the input gate.

[0218] The calculation formula for the candidate value of the input gate is:

[0219] g(t)=tanh(Wg*[h(t-1),x(t)]+bg), formula (4)

[0220] Among them, Wg represents the weight matrix of the input gate candidate value, bg represents the bias vector of the input gate candidate value, and tanh represents the hyperbolic tangent activation function.

[0221] The calculation formula for unit status update is:

[0222] C(t)=f(t)⊙C(t-1)+i(t)⊙g(t), formula (5)

[0223] Among them, ⊙ represents the element-by-element multiplication operation, and C(t-1) represents the cell state at the previous time step.

[0224] The calculation formula of the output gate is:

[0225] o(t)=σ(Wo*[h(t-1),x(t)]+bo), formula (6)

[0226] Among them, Wo represents the weight matrix of the output gate, bo represents the bias vector of the output gate, and the calculation formula of the hidden state is:

[0227] h(t)=o(t)⊙tanh(C(t)), Formula (7)

[0228] Among them, tanh represents the hyperbolic tangent activation function.

[0229] The output is calculated as:

[0230] y(t)=Wh*h(t)+bh, formula (8)

[0231] Among them, Wh represents the weight matrix of the output layer, bh represents the bias vector of the output layer, and y(t) represents the output of the model at time step t.

[0232] The trained LSTM model is used for prediction. The specific process includes: inputting the latest feature data sequence into the LSTM model; the model gradually predicts the load for a period of time in the future through time steps; collecting the output of the model to obtain the prediction sequence of future load.

[0233] Among them, after the scaling operation, the actual performance indicators of the microservices are monitored; the actual QPS is compared with the predicted value of the LSTM model, and the prediction error is calculated; if the error exceeds the preset threshold, the abnormal situation is recorded and the cause is analyzed, which may be due to inaccurate model prediction or inappropriate scaling strategy.

[0234] Among them, the LSTM model is retrained regularly and the model parameters are updated using the latest data; the prediction threshold and scaling trigger conditions are adjusted according to the actual monitoring results; more advanced machine learning technologies are explored, such as the attention mechanism in deep learning or the Transformer model to improve prediction accuracy; and business changes are continuously monitored to ensure that the scaling strategy is always consistent with business needs.

[0235] The above embodiments can achieve the following technical effects:

[0236] (1) In the process of scaling microservices, the historical load data of the microservices in the microservice architecture to be analyzed is preprocessed, feature extracted and modeled, so that the predicted load data of the microservices in the microservice architecture to be analyzed can be accurately obtained. Combined with the prediction threshold of the microservices, the microservice scaling instructions of the microservice architecture to be analyzed can be accurately determined, which is conducive to improving the accuracy of the microservice scaling processing of the microservice architecture to be analyzed, thereby improving the accuracy of microservice scaling; moreover, the entire process does not require human intervention, avoiding the defect that the method of human participation in decision-making is easily affected by subjective factors, resulting in low accuracy of microservice scaling, and further improving the accuracy of microservice scaling.

[0237] (2) By introducing the LSTM algorithm and collecting and feature engineering historical performance data, the LSTM model can learn the time dependency and periodicity of the service load, thereby capturing key performance indicators in the data point di. During the model training phase, the parameterized design of LSTM enables the model to be optimized for specific prediction targets, thereby improving the accuracy of the prediction. Predicting future loads enables the system to respond in advance based on the upcoming load conditions, rather than responding passively when resource bottlenecks have already occurred. Defining prediction thresholds combined with confidence coefficients provides a quantitative basis for scaling decisions and reduces the uncertainty of human judgment. It ensures the flexibility and efficiency of resource allocation, avoids resource waste and service performance degradation. This solution not only improves the elasticity and adaptability of the microservice architecture, but also optimizes resource utilization through predictive management, reduces operating costs, and ultimately improves user experience.

[0238] (3) By training, validating, and testing the LSTM model, we can ensure that the model has good generalization capabilities on real-world data. The dynamic scaling method can more accurately adjust the number of service instances according to actual needs, which not only improves the elasticity and availability of the system, but also optimizes the user experience because the service can quickly respond to changes in demand and maintain high performance and stability. This solution ensures that the entire microservice architecture maintains efficient and reliable operation in a dynamically changing environment, improving the stability and reliability of the entire microservice architecture.

[0239] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0240] Based on the same inventive concept, the embodiment of the present application also provides a microservice scaling device for implementing the microservice scaling method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more microservice scaling device embodiments provided below can refer to the limitations of the microservice scaling method above, and will not be repeated here.

[0241] In an exemplary embodiment, Figure 4 As shown, a microservice scaling device is provided, including: a data acquisition module 401, a data processing module 402, a feature extraction module 403, a load prediction module 404, an instruction determination module 405 and an architecture processing module 406, wherein:

[0242] The data acquisition module 401 is used to obtain the historical load data of the microservices in the microservice architecture to be analyzed under the preset load performance index; the microservice architecture to be analyzed is deployed in the target container orchestration platform.

[0243] The data processing module 402 is used to preprocess the historical load data to obtain preprocessed historical load data.

[0244] The feature extraction module 403 is used to perform feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data.

[0245] The load prediction module 404 is used to input the target feature vector into the trained load prediction model to obtain the predicted load data of the microservice.

[0246] The instruction determination module 405 is used to determine the predicted threshold of the microservice based on the pre-processed historical load data, and determine the microservice scaling instructions of the microservice architecture to be analyzed based on the difference between the predicted load data and the predicted threshold; the predicted threshold is used to represent the predicted load data threshold.

[0247] The architecture processing module 406 is used to perform corresponding microservice scaling processing on the microservice architecture to be analyzed according to the microservice scaling instruction.

[0248] In an exemplary embodiment, the microservice scaling device also includes an indicator screening module, which is used to obtain business scenario information and user behavior pattern information of the microservice, as well as candidate load performance indicators associated with the microservice; from each candidate load performance indicator, screen out candidate load performance indicators that meet both the business scenario information and the user behavior pattern information as current load performance indicators corresponding to the microservice; determine the importance of each current load performance indicator; from each current load performance indicator, screen out a current load performance indicator whose importance is greater than a preset importance as a preset load performance indicator.

[0249] In an exemplary embodiment, the instruction determination module 405 is also used to obtain the average value and standard deviation corresponding to the preprocessed historical load data; determine the first weight corresponding to the average value and the second weight corresponding to the standard deviation; and sum the average value and the standard deviation according to the first weight and the second weight to obtain a prediction threshold.

[0250] In an exemplary embodiment, the instruction determination module 405 is also used to determine that the microservice scaling instructions of the microservice architecture to be analyzed are expansion instructions when the predicted load data is greater than the predicted threshold; or, when the predicted load data is less than the predicted threshold, determine that the microservice scaling instructions of the microservice architecture to be analyzed are shrinking instructions; or, when the predicted load data is equal to the predicted threshold, determine that the microservice scaling instructions of the microservice architecture to be analyzed are maintenance instructions.

[0251] In an exemplary embodiment, the feature extraction module 403 is also used to obtain the timestamp corresponding to the preprocessed historical load data; determine the first data type corresponding to the preprocessed historical load data, and the second data type corresponding to the timestamp; query the correspondence between the data type and the feature extraction model according to the first data type and the second data type, respectively, to determine the first feature extraction model corresponding to the preprocessed historical load data, and the second feature extraction model corresponding to the timestamp; input the preprocessed historical load data into the first feature extraction model for feature extraction processing to obtain the first feature vector corresponding to the preprocessed historical load data, and input the timestamp into the second feature extraction model for feature extraction processing to obtain the second feature vector corresponding to the timestamp; concatenate the first feature vector and the second feature vector to obtain the target feature vector.

[0252] In an exemplary embodiment, the microservice scaling device also includes a model training module, which is used to obtain multiple candidate load prediction models and the prediction efficiency of each candidate load prediction model; from each candidate load prediction model, screen out the candidate load prediction model with the highest prediction efficiency as the load prediction model to be trained; obtain sample historical load data of the sample microservice; preprocess the sample historical load data to obtain preprocessed sample historical load data; perform feature extraction on the preprocessed sample historical load data to obtain a sample target feature vector corresponding to the preprocessed sample historical load data; input the sample target feature vector into the load prediction model to be trained to obtain the predicted load data of the sample microservice; obtain the actual load data of the sample microservice, and obtain the mean square error loss value based on the difference between the actual load data and the predicted load data of the sample microservice; according to the mean square error loss value, iteratively train the load prediction model to be trained to obtain a trained load prediction model.

[0253] Each module in the above-mentioned microservice expansion and contraction device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0254] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 5 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store historical load data, predicted load data, etc. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a microservice expansion and contraction method is implemented.

[0255] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0256] In an exemplary embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0257] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0258] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0259] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0260] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0261] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A microservice expansion and contraction method, characterized in that: The method comprises: Obtaining historical load data of microservices in a microservice architecture to be analyzed under preset load performance indicators; the microservice architecture to be analyzed is deployed in a target container orchestration platform; Preprocessing the historical load data to obtain preprocessed historical load data; Performing feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data; Inputting the target feature vector into the trained load prediction model to obtain predicted load data of the microservice; Determine a prediction threshold of the microservice according to the preprocessed historical load data, and determine a microservice scaling instruction of the microservice architecture to be analyzed according to a difference between the predicted load data and the predicted threshold; the predicted threshold is used to represent a predicted load data threshold; According to the microservice scaling instruction, corresponding microservice scaling processing is performed on the microservice architecture to be analyzed.

2. The method according to claim 1, characterized in that Before obtaining the historical load data of the microservices in the microservice architecture to be analyzed under the preset load performance indicators, it also includes: Acquire business scenario information and user behavior pattern information of the microservice, and candidate load performance indicators associated with the microservice; From each of the candidate load performance indicators, select a candidate load performance indicator that satisfies both the business scenario information and the user behavior pattern information as the current load performance indicator corresponding to the microservice; Determining the importance of each of the current load performance indicators; From the current load performance indicators, a current load performance indicator whose importance is greater than a preset importance is selected as the preset load performance indicator.

3. The method according to claim 1, characterized in that Determining the prediction threshold of the microservice according to the preprocessed historical load data includes: Obtaining the average value and standard deviation corresponding to the preprocessed historical load data; Determine a first weight corresponding to the average value and a second weight corresponding to the standard deviation; The average value and the standard deviation are summed according to the first weight and the second weight to obtain the prediction threshold.

4. The method according to claim 1, characterized in that: The determining, according to the difference between the predicted load data and the predicted threshold, a microservice scaling instruction of the microservice architecture to be analyzed, comprises: When the predicted load data is greater than the predicted threshold, determining that the microservice scaling instruction of the microservice architecture to be analyzed is a scaling instruction; or, When the predicted load data is less than the predicted threshold, determining that the microservice scaling instruction of the microservice architecture to be analyzed is a scaling instruction; or, When the predicted load data is equal to the predicted threshold, it is determined that the microservice scaling instruction of the microservice architecture to be analyzed is a maintenance instruction.

5. The method according to claim 1, characterized in that The performing feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data includes: Obtaining a timestamp corresponding to the preprocessed historical load data; Determine a first data type corresponding to the preprocessed historical load data and a second data type corresponding to the timestamp; According to the first data type and the second data type, respectively, the corresponding relationship between the data type and the feature extraction model is queried to determine the first feature extraction model corresponding to the preprocessed historical load data and the second feature extraction model corresponding to the timestamp; Inputting the preprocessed historical load data into the first feature extraction model for feature extraction processing to obtain a first feature vector corresponding to the preprocessed historical load data, and inputting the timestamp into the second feature extraction model for feature extraction processing to obtain a second feature vector corresponding to the timestamp; The first feature vector and the second feature vector are concatenated to obtain the target feature vector.

6. The method according to any one of claims 1 to 5, characterized in that: The trained load prediction model is obtained by training in the following way: Obtaining multiple candidate load prediction models and the prediction efficiency of each candidate load prediction model; Selecting the candidate load prediction model with the highest prediction efficiency from each of the candidate load prediction models as the load prediction model to be trained; Get sample historical load data of sample microservices; Preprocessing the sample historical load data to obtain preprocessed sample historical load data; Performing feature extraction processing on the preprocessed sample historical load data to obtain a sample target feature vector corresponding to the preprocessed sample historical load data; Inputting the sample target feature vector into the load prediction model to be trained to obtain predicted load data of the sample microservice; Acquire actual load data of the sample microservice, and obtain a mean square error loss value according to a difference between the actual load data and the predicted load data of the sample microservice; According to the mean square error loss value, the load prediction model to be trained is iteratively trained to obtain the trained load prediction model.

7. A microservice expansion and contraction device, characterized in that: The device comprises: A data acquisition module, used to acquire historical load data of microservices in a microservice architecture to be analyzed under a preset load performance indicator; the microservice architecture to be analyzed is deployed in a target container orchestration platform; A data processing module, used for preprocessing the historical load data to obtain preprocessed historical load data; A feature extraction module, used to perform feature extraction processing on the preprocessed historical load data to obtain a target feature vector corresponding to the preprocessed historical load data; A load prediction module, used to input the target feature vector into the trained load prediction model to obtain predicted load data of the microservice; An instruction determination module is used to determine a prediction threshold of the microservice according to the preprocessed historical load data, and to determine a microservice scaling instruction of the microservice architecture to be analyzed according to a difference between the predicted load data and the predicted threshold; the predicted threshold is used to represent a predicted load data threshold; The architecture processing module is used to perform corresponding microservice expansion and contraction processing on the microservice architecture to be analyzed according to the microservice expansion and contraction instruction.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Cited By

  • Low-code process platform micro-service elastic scaling method and system

    CN120832244A

  • Rapid containerization packaging method, system and device for generative AI application and medium

    CN121116500A