Method and device for determining load balancing strategy and electronic equipment
By using the load prediction model in the Dubbo architecture to dynamically adjust the load balancing strategy, the problem that the load balancing strategy in the existing technology cannot accurately predict and adapt to emergencies, and more efficient and stable system load scheduling is achieved.
Patent Information
- Application Number
- CN202411729428.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-04-04
AI Technical Summary
Existing load balancing strategies cannot be dynamically adjusted when facing sudden events, and insufficient prediction accuracy and adaptability make it difficult to maintain efficient and stable in changing scenarios.
By determining the initial load balancing strategy on the preset time period, obtaining the current request data in the current time period, and inputting it into the load prediction model trained by historical load data, outputting the load prediction result, and adjusting the initial load balancing strategy based on the result to obtain the target load balancing strategy.
Accurate prediction and dynamic adjustment of load conditions are achieved, the dependence on personnel formulating load balancing strategies is reduced, and the accuracy of load balancing strategies and the performance and stability of the system are improved.
Smart Images

Figure CN119766733A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of financial technology, and in particular to a method for determining a load balancing strategy, a device thereof, and an electronic device. Background Art
[0002] In distributed systems, Dubbo (Dubbo RPC Framework, an open source microservice framework) is a commonly used service governance framework that provides high-performance RPC (Remote Procedure Call) communication capabilities. Load balancing is an important part of the Dubbo architecture, which can reasonably distribute client requests to different service providers to achieve high performance and high availability of the system.
[0003] At present, the main load balancing strategies include: threshold-based load balancing strategy and rule-based load balancing strategy. Among them, the threshold-based load balancing strategy determines the distribution of service requests by setting one or more thresholds. The threshold is set according to the load of the service provider (such as memory usage, current number of connections, etc.). When the load level of the service provider exceeds the preset threshold, the load balancer distributes new requests to servers with lower loads, thereby avoiding overloading of a certain server and ensuring the stable operation of the service. When the load of the service provider is lower than a certain threshold, some requests are allocated to the server. The rule-based load balancing strategy guides the distribution of service requests through predefined rules, such as polling, least connection or weight-based polling, or it can be a rule that comprehensively considers multi-dimensional factors such as geographic location, content type, user identity, historical request response time, etc.
[0004] However, the above load balancing strategy requires a lot of manual analysis and formulation based on experience, which limits the scientific nature and universality of the strategy to the ability of the developers and the scenario at the time. It cannot be adjusted dynamically in the face of emergencies, and the prediction accuracy and adaptability are insufficient, making it difficult to maintain efficiency and stability in ever-changing scenarios.
[0005] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0006] The embodiments of the present invention provide a method for determining a load balancing strategy, a device thereof, and an electronic device, so as to at least solve the technical problem in the related art that the load balancing strategy cannot be accurately determined, resulting in low processing efficiency of client requests.
[0007] According to one aspect of an embodiment of the present application, a determination method is provided, comprising: determining an initial load balancing strategy for a preset time period; obtaining current request data within the current time period, and inputting the current request data into a preset load prediction model, and outputting a load prediction result for the preset time period, wherein the preset load prediction model is a model trained based on historical load data, and the historical load data includes at least: the request volume and the response time of each request; based on the load prediction result, adjusting the initial load balancing strategy to obtain a target load balancing strategy for the preset time period.
[0008] Furthermore, before inputting the current request data into the preset load prediction model and outputting the load prediction result for the preset time period, it also includes: collecting the historical request volume within multiple preset time lengths in the historical time period and the response time of each request to obtain the historical load data; processing the historical load data to obtain preset training data; and training the initial load prediction model based on the preset training data to obtain the preset load prediction model.
[0009] Furthermore, the step of processing the historical load data to obtain preset training data includes: removing abnormal values and missing values in the historical load data to obtain initial training data; and smoothing the initial training data to obtain the preset training data.
[0010] Furthermore, after processing the historical load data to obtain preset training data, it also includes: determining a preset lag order based on the preset training data; and determining an autocorrelation diagram and a partial autocorrelation diagram based on the preset training data and the preset lag order.
[0011] Furthermore, after determining the autocorrelation graph and the partial autocorrelation graph, it also includes: determining the initial model parameter values of the initial load prediction model based on the autocorrelation graph and the partial autocorrelation graph, wherein the initial model parameter values include at least: an initial difference order, an initial moving average order, and an initial autoregressive order; using the preset training data to adjust the initial model parameter values of the initial load prediction model until the residual sum of squares is less than a preset residual threshold, to obtain a target model parameter value, wherein the residual sum of squares is determined based on a predicted index value and a true index value, the predicted index value is the index value obtained after the initial load prediction model processes the preset training data, the true index value is the index value contained in the preset training data, and the index value includes at least: the request volume and the response time of each request; adjusting the initial load prediction model based on the target model parameter value to obtain the preset load prediction model.
[0012] Furthermore, the step of determining the initial model parameter values of the initial load prediction model based on the autocorrelation graph and the partial autocorrelation graph includes: determining the initial difference order of the initial load prediction model; determining the initial moving average order of the initial load prediction model based on the autocorrelation graph; and determining the initial autoregressive order of the initial load prediction model based on the partial autocorrelation graph.
[0013] Furthermore, the load prediction result includes at least: a predicted index value. After adjusting the initial load balancing strategy based on the load prediction result to obtain the target load balancing strategy for the preset time period, it also includes: obtaining the current index value for the preset time period; and adjusting the preset load prediction model when the difference between the current index value and the predicted index value is greater than a preset difference threshold.
[0014] According to another aspect of an embodiment of the present application, a device for determining a load balancing strategy is also provided, including: a determination unit, used to determine an initial load balancing strategy for a preset time period; an output unit, used to obtain current request data within a current time period, and input the current request data into a preset load prediction model, and output the load prediction result for the preset time period, wherein the preset load prediction model is a model trained based on historical load data, and the historical load data includes at least: the request volume and the response time of each request; an adjustment unit, used to adjust the initial load balancing strategy based on the load prediction result to obtain a target load balancing strategy for the preset time period.
[0015] Furthermore, the determination device includes: a first acquisition module, which is used to collect the historical request volume within multiple preset time lengths in the historical time period and the response time of each request before inputting the current request data into the preset load prediction model and outputting the load prediction result in the preset time period to obtain the historical load data; a first processing module, which is used to process the historical load data to obtain preset training data; and a first training module, which is used to train the initial load prediction model based on the preset training data to obtain the preset load prediction model.
[0016] Furthermore, the first processing module includes: a first removal submodule, used to remove abnormal values and missing values in the historical load data to obtain initial training data; and a first processing submodule, used to smooth the initial training data to obtain the preset training data.
[0017] Furthermore, the determination device also includes: a first determination module, which is used to determine a preset lag order based on the preset training data after processing the historical load data to obtain preset training data; and a second determination module, which is used to determine an autocorrelation graph and a partial autocorrelation graph based on the preset training data and the preset lag order.
[0018] Furthermore, the determination device also includes: a third determination module, which is used to determine the initial model parameter values of the initial load prediction model based on the autocorrelation graph and the partial autocorrelation graph after determining the autocorrelation graph and the partial autocorrelation graph, wherein the initial model parameter values at least include: an initial difference order, an initial moving average order, and an initial autoregressive order; a first adjustment module, which is used to adjust the initial model parameter values of the initial load prediction model using the preset training data until the residual sum of squares is less than a preset residual threshold, so as to obtain a target model parameter value, wherein the residual sum of squares is determined based on a predicted index value and a true index value, the predicted index value is the index value obtained after the initial load prediction model processes the preset training data, the true index value is the index value contained in the preset training data, and the index value at least includes: the request volume and the response time of each request; a second adjustment module, which is used to adjust the initial load prediction model based on the target model parameter value to obtain the preset load prediction model.
[0019] Furthermore, the third determination module includes: a first determination submodule, used to determine the initial differential order of the initial load prediction model; a second determination submodule, used to determine the initial moving average order of the initial load prediction model based on the autocorrelation graph; and a third determination submodule, used to determine the initial autoregressive order of the initial load prediction model based on the partial autocorrelation graph.
[0020] Furthermore, the determination device also includes: a first acquisition module, used to obtain the current index value over the preset time period; and a third adjustment module, used to adjust the preset load prediction model when the difference between the current index value and the predicted index value is greater than a preset difference threshold.
[0021] According to another aspect of an embodiment of the present application, a computer program product is also provided, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for determining any one of the above-mentioned load balancing strategies is implemented.
[0022] According to another aspect of an embodiment of the present application, an electronic device is also provided, including one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the above-mentioned methods for determining the load balancing strategies.
[0023] In the present invention, an initial load balancing strategy for a preset time period is determined, current request data in the current time period is obtained, and the current request data is input into a preset load prediction model, and a load prediction result for the preset time period is output. Based on the load prediction result, the initial load balancing strategy is adjusted to obtain a target load balancing strategy for the preset time period, thereby solving the technical problem in related technologies that the load balancing strategy cannot be accurately determined, resulting in low processing efficiency of client requests.
[0024] In the present invention, the initial load balancing strategy for a preset time period can be determined, and the current request data in the current time period can be obtained. The current request data can be input into a preset load prediction model trained by historical load data, and the load prediction result for the preset time period can be output. The initial load balancing strategy can be adjusted according to the load prediction result, and the target load balancing strategy for the preset time period can be obtained, thereby reducing the dependence on personnel who formulate load balancing strategies. By combining historical load data analysis and real-time data input, accurate prediction of load conditions can be achieved, and the load balancing strategy can be dynamically adjusted according to the prediction results, thereby achieving the technical effect of improving the accuracy of the load balancing strategy. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0026] Figure 1 A hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for determining a load balancing strategy is shown;
[0027] Figure 2 is a flow chart of a method for determining a load balancing strategy according to Example 1 of the present application;
[0028] Figure 3 is a schematic diagram of an optional load balancing strategy determination device according to an embodiment of the present application;
[0029] Figure 4 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0032] It should be noted that the relevant information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) collected and involved in the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of relevant data are in compliance with the relevant laws, regulations and standards of the relevant regions, necessary confidentiality measures are taken, and public order and good customs are not violated, and corresponding operation entrances are provided for users to choose to authorize or refuse. For example, an interface is set between the system and the relevant users or organizations. Before obtaining relevant information, it is necessary to send an acquisition request to the aforementioned user or organization through the interface, and obtain relevant information after receiving the consent information fed back by the aforementioned user or organization.
[0033] In the present invention, the time series analysis method is used to analyze historical load data, which can more accurately predict the load conditions in future time periods, and can dynamically adjust the load balancing strategy according to the load prediction results. By combining the time series analysis method with the load balancing strategy of the Dubbo gateway, accurate scheduling of the system load is achieved. For scenarios where service load changes are sensitive and demand changes frequently (such as e-commerce platforms, online games, etc.), the load balancing strategy of the present invention can better cope with the ever-changing load conditions and improve the performance and stability of the system.
[0034] The present invention is described in detail below in conjunction with various embodiments.
[0035] Example 1
[0036] According to an embodiment of the present application, an embodiment of a method for determining a load balancing strategy is also provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0037] The method embodiment provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 The hardware structure block diagram of a computer terminal (or mobile device) for implementing a method for determining a load balancing strategy is shown. Figure 1 As shown, the computer terminal 10 (or mobile device) may include one or more ( Figure 1 102a, 102b, ..., 102n are used to illustrate) processor 102 (processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may also include: a display, a keyboard, a cursor control device, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera, wherein the network interface may be connected to a wired and / or wireless network. A person of ordinary skill in the art will understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0038] It should be noted that the one or more processors 102 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10 (or mobile device). As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0039] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the determination method in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the determination method of the load balancing strategy described above is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0040] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0041] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 (or mobile device).
[0042] Under the above operating environment, this application provides Figure 2 The method for determining the load balancing strategy is shown. Figure 2 is a flow chart of a method for determining a load balancing strategy according to Example 1 of the present application, such as Figure 2 As shown, the method comprises the following steps:
[0043] Step S201, determining an initial load balancing strategy for a preset time period.
[0044] Optionally, a preset time period (i.e., a period of time in the future, which can be a few minutes, hours, or longer) can be set in the Dubbo gateway as a time window for load forecasting and strategy adjustment. Based on the current system load situation and business needs, a load balancing strategy can be preliminarily formulated.
[0045] In an embodiment of the present invention, the initial load balancing strategy can be determined based on the request volume distribution and response time data in the historical load data. For example, the historical load data shows that the request volume of a certain order processing service increases significantly between 18:00 and 21:00 every day. In this case, some of the requests can be allocated to other order processing service instances to prevent overloading of a single instance.
[0046] Step S202, obtain current request data within the current time period, and input the current request data into a preset load prediction model, and output the load prediction result for the preset time period, wherein the preset load prediction model is a model trained based on historical load data, and the historical load data includes at least: the request volume and the response time of each request.
[0047] Optionally, the gateway can monitor and collect current request data within the current time period in real time, including key indicators such as request volume and response time, and input it into a preset load prediction model (i.e., a model trained based on historical load data) to obtain load prediction results for the preset time period.
[0048] In the embodiment of the present invention, a trained preset load prediction model can be used to predict the load in the future, estimate the load trend and change law of the system, and dynamically adjust the load balancing strategy according to the prediction results.
[0049] Step S203: Based on the load prediction result, the initial load balancing strategy is adjusted to obtain a target load balancing strategy for a preset time period.
[0050] Optionally, the initial load balancing strategy can be dynamically adjusted according to the load prediction results. The strategy obtained after adjustment is the target load balancing strategy for the preset time period. The target load balancing strategy can guide the service request scheduling of the Dubbo gateway in the future time window to cope with load changes.
[0051] For example, if the load forecast result indicates that the response time of the order processing service will be prolonged, the number of requests allocated to it can be reduced to avoid the impact of long response time on user experience.
[0052] In summary, the initial load balancing strategy for the preset time period can be determined, and the real-time load situation can be monitored. At the same time, the current request data in the current time period can be obtained, and the current request data can be input into the preset load prediction model trained by historical load data. The load prediction result for the preset time period can be output, and the initial load balancing strategy can be adjusted according to the load prediction result. The target load balancing strategy for the preset time period can be obtained, thereby solving the technical problem in the related technology that the load balancing strategy cannot be accurately determined, resulting in low processing efficiency of client requests.
[0053] In order to accurately obtain the preset load prediction model, in the method for determining the load balancing strategy provided in Example 1 of the present application, the historical request volume within multiple preset time periods in the historical time period and the response time of each request are collected to obtain historical load data; the historical load data is processed to obtain preset training data; based on the preset training data, the initial load prediction model is trained to obtain the preset load prediction model.
[0054] Optionally, by monitoring the load in the system, the gateway can collect historical load data (such as historical request volume and response time of each request) within multiple preset time periods in the historical time period, and pre-process the historical load data (such as removing outliers, removing missing values, smoothing, etc.), and obtain preset training data to ensure the quality and stability of the data.
[0055] In an embodiment of the present invention, the preset training data is used to train an initial load forecasting model (such as an ARIMA model (Autoregressive Integrated Moving Average Model)) through a time series analysis method to obtain a preset load forecasting model.
[0056] In some optional embodiments, the initial load prediction model can be LSTM (Long Short-Term Memory, recursive neural network), ARMA (Autoregressive Moving Average, a combination model of autoregressive model and moving average model), SARIMA (Seasonal Autoregressive Integrated Moving Average, a seasonal extension model of the ARIMA model), etc., without limitation here.
[0057] In order to accurately obtain the preset training data, in the method for determining the load balancing strategy provided in Example 1 of the present application, outliers and missing values in the historical load data are removed to obtain initial training data; the initial training data is smoothed to obtain the preset training data.
[0058] In an embodiment of the present invention, when collecting historical load data, due to network fluctuations, data synchronization delays, etc., there will be outliers and missing values in the data. If the data is used directly for model training, it will cause deviations in the model's prediction results, reducing the accuracy and reliability of the model. Therefore, it is necessary to preprocess the historical data.
[0059] Optionally, data that is far above or below the normal range can be identified and eliminated manually or through statistical analysis methods (such as Z-score (i.e. standard score), IQR (Interquartile Range) and other techniques) to eliminate the impact of outliers on the prediction model. It can also be checked whether there are missing values and the missing values can be eliminated (for example, a piece of data can have multiple dimensions. When a dimension (such as request volume, response time) is empty, the data can be discarded).
[0060] In an embodiment of the present invention, outliers and missing values in historical load data are removed to obtain initial training data, and the initial training data can be smoothed to obtain preset training data (i.e., data used for model training after data preprocessing), which can further reduce noise in the data, enhance the stability of the data, provide clearer and more accurate data input for model training, and improve the performance of the prediction model.
[0061] In order to accurately determine the autocorrelation graph and the partial autocorrelation graph, in the method for determining the load balancing strategy provided in Example 1 of the present application, based on the preset training data, the preset lag order is determined; based on the preset training data and the preset lag order, the autocorrelation graph and the partial autocorrelation graph are determined.
[0062] Optionally, the preset lag order (i.e., how many time units each data in the preset training data can be traced back to compare its correlation) can be determined based on the length, periodicity and other characteristics of the preset training data. The autocorrelation graph and partial autocorrelation graph can be determined based on the preset training data and the preset lag order.
[0063] For example, if the time series is recorded on a daily basis, then the preset lag order of 1 is the data of the previous day, the preset lag order of 2 is the data of the previous two days, and the preset lag order of 20 is the autocorrelation values from lag 0 to lag 19 (that is, the correlation between a certain data in the preset training data and itself and the data of the previous 1 time unit, 2 time units, to 19 time units).
[0064] In order to improve the accuracy of determining the preset load prediction model, in the method for determining the load balancing strategy provided in Example 1 of the present application, the initial model parameter values of the initial load prediction model are determined based on the autocorrelation graph and the partial autocorrelation graph, wherein the initial model parameter values at least include: the initial difference order, the initial moving average order and the initial autoregressive order; the initial model parameter values of the initial load prediction model are adjusted using the preset training data until the residual sum of squares is less than the preset residual threshold, and the target model parameter values are obtained, wherein the residual sum of squares is determined based on the predicted index value and the true index value, the predicted index value is the index value obtained after the initial load prediction model processes the preset training data, the true index value is the index value contained in the preset training data, and the index value at least includes: the request volume and the response time of each request; the initial load prediction model is adjusted based on the target model parameter value to obtain the preset load prediction model.
[0065] Optionally, the initial model parameter values can be determined by observing the autocorrelation plot and the partial autocorrelation plot. The autocorrelation plot (Autocorrelation Function plot, ACF) provides information about the autocorrelation in the time series data (i.e., the preset training data), and the partial autocorrelation plot (Partial Autocorrelation Function plot, PACF) provides information about the partial autocorrelation in the time series data, which can be used to preliminarily estimate the parameter values of the initial load forecasting model. For example, the initial moving average order can be determined based on the autocorrelation plot, and the initial autoregressive order can be determined based on the partial autocorrelation plot.
[0066] In an embodiment of the present invention, methods such as maximum likelihood estimation can be used to estimate the optimal parameters of the model, and optimization algorithms such as gradient descent can be used to minimize the residual sum of squares of the model. The residual sum of squares is an important indicator for evaluating the prediction accuracy of the model. The sum of squares of the difference (i.e., residual) between the indicator value predicted by the model and the true indicator value can be calculated. The smaller the residual sum of squares, the higher the accuracy of the model prediction.
[0067] In an embodiment of the present invention, the preset training data can be used to adjust the initial model parameter values of the initial load prediction model until the sum of squared residuals (i.e., the sum of squares of the differences between the indicator values (such as the number of requests and the response time of each request) obtained after the initial load prediction model processes the preset training data and the indicator values contained in the preset training data) is less than a preset residual threshold (such as a value close to 0).
[0068] In an embodiment of the present invention, when the residual sum of squares of the model drops below a preset threshold, the obtained target model parameter value (i.e., the optimized parameter) can be used to adjust the initial load prediction model, and the final prediction model (i.e., the preset load prediction model) can be obtained, which can more accurately predict the future load conditions of the system.
[0069] In order to accurately determine the initial model parameter values of the initial load prediction model, in the method for determining the load balancing strategy provided in Example 1 of the present application, the initial differential order of the initial load prediction model is determined; based on the autocorrelation graph, the initial moving average order of the initial load prediction model is determined; based on the partial autocorrelation graph, the initial autoregressive order of the initial load prediction model is determined.
[0070] Optionally, the specific value of the initial difference order (such as 2-10) can be determined according to the stationarity of the preset training data. The initial load prediction model may include an AR model (Autoregressive model) and an MA model (Moving Average Model). The autocorrelation graph of the AR model decays exponentially, while the autocorrelation graph of the MA model is truncated at the lag order after the model order (that is, the correlation coefficients all become 0 or close to 0). If the autocorrelation graph shows truncation after the lag order k, the lag order k is the model order of the MA model (that is, the initial moving average order).
[0071] In an embodiment of the present invention, the partial autocorrelation diagram of the AR model is truncated at the lag order after the model order, while the partial autocorrelation diagram of the MA model decays exponentially. If the partial autocorrelation diagram shows truncation after the lag order k, the lag order k is the model order of the AR model (i.e., the initial autoregressive order).
[0072] In the embodiment of the present invention, the first truncated lag order in the ACF and PACF diagrams may be selected as the candidate order of the model (ie, the initial model parameter value of the initial load forecasting model).
[0073] Exemplarily, the autocorrelation diagram is truncated after the lag order 3, and the partial autocorrelation diagram is truncated after the lag order 2. The ARIMA model order can be (p, d, q) = (3, d, 2), where p represents the initial autoregressive order of the AR model, q represents the initial moving average order of the MA model, and d represents the difference order.
[0074] In order to improve the accuracy of the prediction of the preset load prediction model, in the method for determining the load balancing strategy provided in Example 1 of the present application, the current index value over a preset time period is obtained; when the difference between the current index value and the predicted index value is greater than the preset difference threshold, the preset load prediction model is adjusted.
[0075] Optionally, during system operation, the gateway can monitor the current load and performance indicators of the system in real time, and can dynamically adjust the parameters and configuration of the load balancing strategy (i.e., adjust the preset load prediction model) according to the monitoring results to cope with the actual situation of the system.
[0076] In an embodiment of the present invention, the current index value over a preset time period (which may be a few minutes, hours or a longer time period) can be obtained, and the current index value can be compared with the predicted index value of a preset load prediction model. When the difference between the current index value and the predicted index value is greater than a preset difference threshold, the preset load prediction model is adjusted.
[0077] The method for determining the load balancing strategy provided in the embodiment of the present application can obtain a preset load prediction model by training the initial load prediction model with historical load data, and input the current request data obtained in the current time period into the preset load prediction model, so as to obtain the load prediction result for the preset time period, and dynamically adjust the load balancing strategy according to the prediction result. By combining the time series analysis method with the load balancing strategy of the Dubbo gateway, the gateway can more accurately predict future load conditions, thereby more effectively scheduling requests, thereby realizing accurate scheduling of the system load and improving the performance and stability of the system.
[0078] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0079] Example 2
[0080] The embodiment of the present application also provides a device for determining a load balancing strategy. It should be noted that the device for determining a load balancing strategy in the embodiment of the present application can be used to execute the method for determining a load balancing strategy provided in the embodiment of the present application. The following introduces the device for determining a load balancing strategy provided in the embodiment of the present application.
[0081] According to an embodiment of the present application, a device for implementing the above-mentioned method for determining the load balancing strategy is also provided. Figure 3 is a schematic diagram of an optional load balancing strategy determination device according to an embodiment of the present application, such as Figure 3 As shown, the load balancing strategy determination device may include: a determination unit 30 , an output unit 31 , and an adjustment unit 32 .
[0082] Wherein, the determination unit 30 is used to determine an initial load balancing strategy over a preset time period;
[0083] The output unit 31 is used to obtain current request data in a current time period, input the current request data into a preset load prediction model, and output a load prediction result for a preset time period, wherein the preset load prediction model is a model trained based on historical load data, and the historical load data at least includes: a request volume and a response time of each request;
[0084] The adjusting unit 32 is used to adjust the initial load balancing strategy based on the load prediction result to obtain a target load balancing strategy in a preset time period.
[0085] The device for determining the load balancing strategy provided in the embodiment of the present application can determine the initial load balancing strategy for a preset time period through the determination unit 30, obtain the current request data in the current time period through the output unit 31, and input the current request data into the preset load prediction model, output the load prediction result for the preset time period, and adjust the initial load balancing strategy based on the load prediction result through the adjustment unit 32 to obtain the target load balancing strategy for the preset time period.
[0086] Optionally, the determination device includes: a first acquisition module, which is used to collect historical request volumes and response times of each request within multiple preset time periods in a historical time period before inputting current request data into a preset load prediction model and outputting a load prediction result for a preset time period to obtain historical load data; a first processing module, which is used to process the historical load data to obtain preset training data; and a first training module, which is used to train an initial load prediction model based on the preset training data to obtain a preset load prediction model.
[0087] Optionally, the first processing module includes: a first removal submodule, used to remove abnormal values and missing values in the historical load data to obtain initial training data; and a first processing submodule, used to smooth the initial training data to obtain preset training data.
[0088] Optionally, the determination device also includes: a first determination module, used to determine a preset lag order based on the preset training data after processing the historical load data to obtain the preset training data; a second determination module, used to determine the autocorrelation graph and the partial autocorrelation graph based on the preset training data and the preset lag order.
[0089] Optionally, the determination device also includes: a third determination module, which is used to determine the initial model parameter values of the initial load prediction model based on the autocorrelation graph and the partial autocorrelation graph after determining the autocorrelation graph and the partial autocorrelation graph, wherein the initial model parameter values include at least: an initial difference order, an initial moving average order, and an initial autoregressive order; a first adjustment module, which is used to adjust the initial model parameter values of the initial load prediction model using preset training data until the residual sum of squares is less than a preset residual threshold, so as to obtain a target model parameter value, wherein the residual sum of squares is determined based on a predicted index value and a true index value, the predicted index value is an index value obtained after the initial load prediction model processes the preset training data, and the true index value is an index value contained in the preset training data, and the index value includes at least: the request volume and the response time of each request; a second adjustment module, which is used to adjust the initial load prediction model based on the target model parameter value to obtain a preset load prediction model.
[0090] Optionally, the third determination module includes: a first determination submodule, used to determine the initial differential order of the initial load prediction model; a second determination submodule, used to determine the initial moving average order of the initial load prediction model based on the autocorrelation graph; and a third determination submodule, used to determine the initial autoregressive order of the initial load prediction model based on the partial autocorrelation graph.
[0091] Optionally, the determination device also includes: a first acquisition module, used to obtain the current index value over a preset time period; and a third adjustment module, used to adjust the preset load prediction model when the difference between the current index value and the predicted index value is greater than a preset difference threshold.
[0092] The above-mentioned load balancing strategy determination device may also include a processor and a memory. The above-mentioned determination unit 30, output unit 31, adjustment unit 32, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to implement corresponding functions.
[0093] The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the target load balancing strategy in a preset time period can be obtained by adjusting kernel parameters.
[0094] The above-mentioned memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one storage chip.
[0095] It should be noted that the above-mentioned determination unit 30, output unit 31, and adjustment unit 32 correspond to steps S201 to S203 in Embodiment 1, and the above-mentioned units and corresponding steps implement the same instances and application scenarios, but are not limited to the contents disclosed in the above-mentioned Embodiment 1. It should be noted that the above-mentioned units may be hardware components or software components stored in a memory (e.g., memory 104) and processed by one or more processors (e.g., processors 102a, 102b, ..., 102n), and the above-mentioned units may also be part of the device and may be run in the computer terminal 10 provided in Embodiment 1.
[0096] Example 3
[0097] The embodiment of the present application may provide a computer terminal, which may be any computer terminal device in a computer terminal group. Optionally, in this embodiment, the computer terminal may also be replaced by a terminal device such as a mobile terminal or an electronic device.
[0098] Optionally, in this embodiment, the computer terminal may be located in at least one network device among a plurality of network devices of the computer network.
[0099] In this embodiment, the above-mentioned computer terminal can execute the program code of the following steps in the method for determining the load balancing strategy: determining the initial load balancing strategy for a preset time period; obtaining the current request data within the current time period, and inputting the current request data into a preset load prediction model, and outputting the load prediction result for the preset time period, wherein the preset load prediction model is a model trained based on historical load data, and the historical load data includes at least: the request volume and the response time of each request; based on the load prediction result, adjusting the initial load balancing strategy to obtain the target load balancing strategy for the preset time period.
[0100] Optionally, the above-mentioned computer terminal can execute the program code of the following steps in the method for determining the load balancing strategy: collecting the historical request volume and the response time of each request within multiple preset time periods in the historical time period to obtain historical load data; processing the historical load data to obtain preset training data; based on the preset training data, training the initial load prediction model to obtain a preset load prediction model.
[0101] Optionally, the computer terminal may execute the program code of the following steps in the method for determining a load balancing strategy: removing abnormal values and missing values in historical load data to obtain initial training data; and smoothing the initial training data to obtain preset training data.
[0102] Optionally, the computer terminal may execute the program code of the following steps in the method for determining a load balancing strategy: determining a preset lag order based on preset training data; determining an autocorrelation graph and a partial autocorrelation graph based on preset training data and preset lag order.
[0103] Optionally, the above-mentioned computer terminal can execute the program code of the following steps in the method for determining the load balancing strategy: based on the autocorrelation graph and the partial autocorrelation graph, determine the initial model parameter values of the initial load prediction model, wherein the initial model parameter values at least include: the initial difference order, the initial moving average order and the initial autoregressive order; use the preset training data to adjust the initial model parameter values of the initial load prediction model until the residual sum of squares is less than the preset residual threshold, and obtain the target model parameter value, wherein the residual sum of squares is determined based on the predicted index value and the true index value, the predicted index value is the index value obtained after the initial load prediction model processes the preset training data, the true index value is the index value contained in the preset training data, and the index value at least includes: the request volume and the response time of each request; adjust the initial load prediction model based on the target model parameter value to obtain the preset load prediction model.
[0104] Optionally, the above-mentioned computer terminal can execute the program code of the following steps in the method for determining the load balancing strategy: determining the initial differential order of the initial load prediction model; determining the initial moving average order of the initial load prediction model based on the autocorrelation graph; determining the initial autoregressive order of the initial load prediction model based on the partial autocorrelation graph.
[0105] Optionally, the above-mentioned computer terminal can execute the program code of the following steps in the method for determining the load balancing strategy: obtaining the current indicator value over a preset time period; when the difference between the current indicator value and the predicted indicator value is greater than a preset difference threshold, adjusting the preset load prediction model.
[0106] Optionally, Figure 4 is a structural block diagram of an electronic device according to an embodiment of the present application. Figure 4 As shown, the electronic device may include: one or more ( Figure 4 (only one is shown) processor 402, memory 404, storage controller, and peripheral interface, wherein the peripheral interface is connected to the radio frequency module, audio module and display.
[0107] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the determination method and device in the embodiment of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, the determination method of the above-mentioned load balancing strategy is realized. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories can be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0108] The processor may call the information and application programs stored in the memory through the transmission device to execute the above steps in the method for determining the load balancing strategy.
[0109] By adopting the embodiment of the present application, a solution for determining a load balancing strategy is provided. By using historical load data to train an initial load prediction model to obtain a preset load prediction model, and obtaining current request data in a current time period, the current request data is input into the preset load prediction model, and a load prediction result for a preset time period can be obtained. The load prediction result can help identify the changing trend of the load, can provide instant feedback on the system status, quickly respond to sudden high loads, and achieve accurate scheduling of the system load. By real-time monitoring of the request volume and response time, the parameters and configuration of the load balancing strategy can be dynamically adjusted, which can better cope with the ever-changing load conditions and maintain the smooth operation of the system, thereby solving the technical problem in the related technology that the load balancing strategy cannot be accurately determined, resulting in low efficiency in processing client requests.
[0110] It can be understood by those skilled in the art that Figure 4 The structure shown is for illustration only, and the electronic device may also be a terminal device such as a smart phone, a tablet computer, a PDA, and a mobile Internet device (Mobile Internet Devices, MID). Figure 4 The structure of the electronic device is not limited. Figure 4 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 4 Different configurations are shown.
[0111] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0112] Example 4
[0113] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to store the program code executed by the method for determining the load balancing strategy provided in the first embodiment.
[0114] Optionally, in this embodiment, the above storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.
[0115] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing the program of the method steps for determining a load balancing strategy.
[0116] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0117] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0118] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0119] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0120] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0121] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0122] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for determining a load balancing strategy, characterized in that: include: Determine an initial load balancing strategy for a preset time period; Obtain current request data within a current time period, input the current request data into a preset load prediction model, and output a load prediction result for the preset time period, wherein the preset load prediction model is a model trained based on historical load data, and the historical load data at least includes: a request volume and a response time for each request; Based on the load prediction result, the initial load balancing strategy is adjusted to obtain the target load balancing strategy for the preset time period.
2. The method for determining a load balancing strategy according to claim 1, characterized in that: Before inputting the current request data into a preset load prediction model and outputting the load prediction result for the preset time period, the method further includes: Collecting historical request volumes within multiple preset time periods in a historical time period and the response time of each request to obtain the historical load data; Processing the historical load data to obtain preset training data; Based on the preset training data, the initial load prediction model is trained to obtain the preset load prediction model.
3. The method for determining a load balancing strategy according to claim 2, characterized in that: The step of processing the historical load data to obtain preset training data includes: Removing outliers and missing values from the historical load data to obtain initial training data; The initial training data is smoothed to obtain the preset training data.
4. The method for determining a load balancing strategy according to claim 2, characterized in that: After the historical load data is processed to obtain preset training data, the method further includes: Based on the preset training data, determining a preset lag order; Based on the preset training data and the preset lag order, an autocorrelation graph and a partial autocorrelation graph are determined.
5. The method for determining a load balancing strategy according to claim 4, characterized in that: After determining the autocorrelation graph and partial autocorrelation graph, it also includes: Based on the autocorrelation graph and the partial autocorrelation graph, determining initial model parameter values of the initial load forecasting model, wherein the initial model parameter values at least include: an initial difference order, an initial moving average order, and an initial autoregressive order; The initial model parameter value of the initial load prediction model is adjusted by using the preset training data until the residual sum of squares is less than a preset residual threshold, and a target model parameter value is obtained, wherein the residual sum of squares is determined based on a predicted index value and a true index value, the predicted index value is an index value obtained after the initial load prediction model processes the preset training data, the true index value is an index value included in the preset training data, and the index value includes at least: the request volume and the response time of each request; The initial load prediction model is adjusted based on the target model parameter value to obtain the preset load prediction model.
6. The method for determining a load balancing strategy according to claim 5, characterized in that: The step of determining the initial model parameter values of the initial load prediction model based on the autocorrelation graph and the partial autocorrelation graph comprises: Determining the initial difference order of the initial load prediction model; Based on the autocorrelation graph, determining the initial moving average order of the initial load forecasting model; Based on the partial autocorrelation graph, the initial autoregressive order of the initial load forecasting model is determined.
7. The method for determining a load balancing strategy according to claim 1, characterized in that: The load prediction result at least includes: a prediction index value. After adjusting the initial load balancing strategy based on the load prediction result to obtain the target load balancing strategy in the preset time period, the following is further included: Obtaining the current indicator value over the preset time period; When the difference between the current index value and the predicted index value is greater than a preset difference threshold, the preset load prediction model is adjusted.
8. A device for determining a load balancing strategy, characterized in that: include: A determination unit, used to determine an initial load balancing strategy for a preset time period; An output unit, used to obtain current request data in a current time period, input the current request data into a preset load prediction model, and output a load prediction result for the preset time period, wherein the preset load prediction model is a model trained based on historical load data, and the historical load data at least includes: a request volume and a response time of each request; An adjustment unit is used to adjust the initial load balancing strategy based on the load prediction result to obtain a target load balancing strategy in the preset time period.
9. A computer program product, characterized in that It comprises a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for determining a load balancing strategy according to any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for determining the load balancing strategy described in any one of claims 1 to 7.
Citation Information
Cited By
User request distribution method and device, electronic equipment and storage medium
CN121442000A
Load balancing method and device, electronic equipment, program product and storage medium
CN121603498A