Load balancing method, apparatus, electronic device, storage medium, and computer program product

CN123011509APending Publication Date: 2026-10-30CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611196529.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-07
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0002]在云计算向分布式服务架构演进的过程中,微服务解耦机制通过将业务功能模块化为独立服务单元,实现了跨异构计算节点的弹性部署,又通过负载均衡技术解决计算节点资源错配的问题,但目前的微服务负载均衡调度算法较为固定,且考虑维度单一,负载均衡调度成功率和场景适配度均较低

Benefits of technology

[0015]本申请实施例提供的负载均衡方法、装置、电子设备、存储介质及计算机程序产品中,基于一个或多个第一节点中每个第一节点的负载信息、所述每个第一节点的第一信息和接收到的服务请求,构建所述每个第一节点的第一特征向量;所述第一信息表征对应第一节点处理历史服务请求的相关信息;所述服务请求用于请求提供用户服务;所述第一特征向量包括对应第一节点的CPU利用率、对应第一节点的内存利用率、对应第一节点的磁盘利用率、对应第一节点的历史服务请求的接收延迟、对应第一节点的历史服务请求的处理时长、所述用户服务的类型和所述用户服务的资源占用量;将所述每个第一节点的第一特征向量输入负载均衡网络,得到所述每个第一节点的调度评分;基于所述每个第一节点的调度评分,从所述一个或多个第一节点中选择出调度节点,并将所述接收到的服务请求调度到所述调度节点。上述方案,通过在服务请求的负载均衡调度时从节点负载情况、服务请求的类型、服务请求响应延迟、服务请求的资源占用量多个维度综合考虑,从而确定出服务请求的调度节点,能够提升负载均衡效果,提高用户服务请求的调度成功率和负载均衡方案的场景适配度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123011509A_ABST
    Figure CN123011509A_ABST
Patent Text Reader

Abstract

The application provides a load balancing method and device, electronic equipment, a storage medium and a computer program product. The method comprises the following steps: constructing a first feature vector of each first node based on load information of each first node in one or more first nodes, first information of each first node and a received service request; the first feature vector comprises CPU utilization of the corresponding first node, memory utilization of the corresponding first node, disk utilization of the corresponding first node, reception delay of a historical service request of the corresponding first node, processing duration of the historical service request of the corresponding first node, a type of user service and resource occupation of the user service; inputting the first feature vector of each first node into a load balancing network to obtain a scheduling score of each first node; selecting a scheduling node from the one or more first nodes based on the scheduling score of each first node, and scheduling the received service request to the scheduling node.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a load balancing method, apparatus, electronic device, storage medium, and computer program product. Background Technology

[0002] In the process of cloud computing evolving into a distributed service architecture, the microservice decoupling mechanism has achieved elastic deployment across heterogeneous computing nodes by modularizing business functions into independent service units. It has also solved the problem of resource mismatch between computing nodes through load balancing technology. However, the current microservice load balancing scheduling algorithm is relatively fixed and considers only one dimension, resulting in low load balancing scheduling success rate and low scenario adaptability. Summary of the Invention

[0003] To address the related technical issues, embodiments of this application provide a load balancing method, apparatus, electronic device, storage medium, and computer program product.

[0004] The technical solution of this application embodiment is implemented as follows: This application provides a load balancing method, the method comprising: Based on the load information of each of the one or more first nodes, the first information of each first node, and the received service requests, a first feature vector is constructed for each first node; the first information represents the relevant information of the corresponding first node in processing historical service requests; the service request is used to request the provision of user services; the first feature vector includes the utilization rate of the central processing unit (CPU) of the corresponding first node, the memory utilization rate of the corresponding first node, the disk utilization rate of the corresponding first node, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; The first feature vector of each first node is input into the load balancing network to obtain the scheduling score of each first node; Based on the scheduling score of each first node, a scheduling node is selected from the one or more first nodes, and the received service request is scheduled to the scheduling node.

[0005] In the above scheme, the first feature vector includes a second feature vector at each time point within a certain period; the step of constructing the first feature vector of each first node based on the load information of each of the one or more first nodes, the first information of each first node, and the received service requests includes: For each time point, based on the load information of the corresponding first node at that time point, the first information of the corresponding first node, and the received service request, a second feature vector of the corresponding first node at that time point is constructed; the second feature vector includes the CPU utilization rate of the corresponding first node at that time point, the memory utilization rate of the corresponding first node at that time point, the disk utilization rate of the corresponding first node at that time point, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; Based on the second feature vector of the corresponding first node at each time point, construct the first feature vector of the corresponding first node.

[0006] In the above scheme, the reception delay of the historical service request of the corresponding first node is determined based on the scheduling time of the historical service request and the time when the corresponding first node receives the historical service request; the processing time of the historical service request of the corresponding first node is determined based on the time when the corresponding first node receives the historical service request and the time when the corresponding first node responds to the historical service request.

[0007] In the above scheme, the training method of the load balancing network includes: For each training sample in the training sample set, the third feature vector in the training sample is input into the load balancing network to obtain the scheduling score corresponding to the third feature vector. The target score is calculated based on the reward in the training sample, the next state feature vector in the training sample, and the target network; the network structure of the target network is the same as that of the load balancing network; the parameters of the target network are obtained by copying the parameters of the load balancing network. Based on the scheduling score corresponding to the third feature vector, the target score, and the set loss function, the parameters of the load balancing network are updated until the training termination condition is met.

[0008] In the above scheme, the load balancing network is a Long Short Term Memory (LSTM) network.

[0009] In the above scheme, the reward value is -1 or 1. A reward value of -1 indicates that the request scheduling corresponding to the training sample failed, and a reward value of 1 indicates that the request scheduling corresponding to the training sample succeeded.

[0010] In the above scheme, selecting a scheduling node from one or more first nodes based on the scheduling score of each first node includes: The first node with the highest scheduling score among the one or more first nodes is determined as the scheduling node.

[0011] This application also provides a load balancing device, including: A construction unit is configured to construct a first feature vector for each of the first nodes based on the load information of each of the first nodes in one or more first nodes, the first information of each first node, and the received service requests; the first information represents the relevant information of the corresponding first node in processing historical service requests; the service request is used to request the provision of user services; the first feature vector includes the CPU utilization of the corresponding first node, the memory utilization of the corresponding first node, the disk utilization of the corresponding first node, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; An evaluation unit is used to input the first feature vector of each first node into the load balancing network to obtain a scheduling score for each first node. The scheduling unit is used to select a scheduling node from the one or more first nodes based on the scheduling score of each first node, and to schedule the received service request to the scheduling node.

[0012] This application also provides an electronic device, including a processor and a memory for storing a computer program that can run on the processor, wherein the processor, when running the computer program, performs the steps of any of the methods described above.

[0013] This application also provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of any of the above methods.

[0014] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above methods.

[0015] The load balancing method, apparatus, electronic device, storage medium, and computer program product provided in this application embodiment construct a first feature vector for each first node based on the load information of each first node in one or more first nodes, the first information of each first node, and the received service requests; the first information represents the relevant information of the corresponding first node in processing historical service requests; the service request is used to request the provision of user services; the first feature vector includes the CPU utilization rate of the corresponding first node, the memory utilization rate of the corresponding first node, the disk utilization rate of the corresponding first node, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; the first feature vector of each first node is input into the load balancing network to obtain the scheduling score of each first node; based on the scheduling score of each first node, a scheduling node is selected from the one or more first nodes, and the received service request is scheduled to the scheduling node. The above solution, by comprehensively considering multiple dimensions such as node load, service request type, service request response latency, and service request resource consumption during service request load balancing scheduling, determines the scheduling node for service requests, thereby improving load balancing performance, increasing the success rate of user service request scheduling, and enhancing the scenario adaptability of the load balancing solution. Attached Figure Description

[0016] Figure 1 A flowchart illustrating a load balancing method provided in an embodiment of this application; Figure 2 A schematic diagram of a Markov decision process provided for an embodiment of this application; Figure 3 A schematic diagram of a load balancing network provided in an embodiment of this application; Figure 4 A schematic diagram of a load balancing system architecture provided for an application embodiment of this application; Figure 5 This is a schematic diagram of the structure of a load balancing device provided in an embodiment of this application; Figure 6 This is a schematic diagram of the electronic device structure provided in the embodiments of this application. Detailed Implementation

[0017] In the process of cloud computing evolving into a distributed service architecture, the microservice decoupling mechanism has enabled elastic deployment across heterogeneous computing nodes by modularizing business functions into independent service units. While this architecture improves the system's disaster recovery capabilities and service availability, it has also exposed significant resource scheduling problems. Due to the significant differences in hardware configuration, network topology, and real-time load among the underlying computing nodes, traditional service scheduling strategies are prone to inefficient resource allocation, such as service response latency on high-load nodes and resource idleness on inefficient nodes. This resource mismatch will directly affect the user experience, especially when dealing with business scenarios with strict Quality of Service (QoS) requirements.

[0018] Current load balancing technologies can be broadly categorized into two systems: static scheduling algorithms and dynamic scheduling algorithms. Typical static scheduling algorithms include random allocation, round-robin scheduling, and weighted allocation algorithms, while common dynamic scheduling algorithms include the shortest response time algorithm. Static scheduling algorithms are based on preset rules, and their core drawback lies in their lack of dynamic awareness. They cannot adjust strategies in a timely manner based on the real-time load status of nodes, making them prone to scheduling imbalances in scenarios with sudden traffic surges or heterogeneous workloads. Dynamic scheduling algorithms obtain real-time load data from nodes through active probing mechanisms and construct dynamic weight models. While theoretically achieving better resource scheduling, the additional network overhead generated by the probing mechanism is too large, accounting for approximately 5%-15% of the total traffic. Furthermore, they only consider response time metrics, resulting in a single dimension of load assessment. For example, the Long Short-Term Memory (LSTM) prediction model, although introducing load trend prediction capabilities, fails to fully consider the collaborative optimization of multi-dimensional service quality indicators, particularly lacking an adaptive adjustment mechanism for differentiated business scenarios.

[0019] The types of services supported by cloud computing platforms exhibit significant scenario differentiation. Typical scenarios include: real-time interactive (such as cloud gaming), characterized by end-to-end latency of less than 50 milliseconds (ms) and a graphics processing unit (GPU) computing power ratio of more than 70%; high-throughput (such as e-commerce services), characterized by ensuring more than 100,000 input / output operations per second (IOPS) and more than 1 gigabits per second (Gbps) of network bandwidth usage; and compute-intensive (such as scientific computing), characterized by focusing on the efficiency of central processing unit (CPU) and / or GPU computing resource allocation.

[0020] Current load balancing technologies all use a uniform scheduling strategy, which cannot dynamically adjust resource evaluation weights and scheduling strategies according to specific scenario requirements. Therefore, it is difficult to achieve optimal global resource allocation in a mixed business deployment environment, which has become a key bottleneck restricting the improvement of cloud computing service quality.

[0021] Specifically, current load balancing algorithms still have the following shortcomings: The scheduling method is transparent and has low flexibility. Whether it is a static load balancing algorithm or a dynamic load balancing algorithm, the scheduling of servers adopts a fixed strategy that is set in advance. It is impossible to dynamically adjust the scheduling strategy according to the actual situation of the server nodes. Furthermore, the transparent and fixed scheduling strategy is difficult to cope with the unknown situations that may occur during the scheduling process. There are few scheduling reference indicators, making it difficult to measure the actual load of the server; most current dynamic load balancing algorithms only use a single indicator to measure the server load, without taking into account information such as CPU, disk, and memory. The current load balancing algorithms focus on whether the load balancing scheduling can be successful, without considering how to meet the different performance requirements of users in different scenarios and maximize the user experience.

[0022] Based on this, in various embodiments of this application, a first feature vector is constructed for each first node based on the load information of each of the one or more first nodes, the first information of each first node, and the received service requests; the first information represents the relevant information of the corresponding first node in processing historical service requests; the service request is used to request the provision of user services; the first feature vector includes the CPU utilization of the corresponding first node, the memory utilization of the corresponding first node, the disk utilization of the corresponding first node, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; the first feature vector of each first node is input into the load balancing network to obtain the scheduling score of each first node; based on the scheduling score of each first node, a scheduling node is selected from the one or more first nodes, and the received service request is scheduled to the scheduling node. The above solution, by comprehensively considering multiple dimensions such as node load, service request type, service request response latency, and service request resource consumption during service request load balancing scheduling, determines the scheduling node for service requests, thereby improving load balancing performance, increasing the success rate of user service request scheduling, and enhancing the scenario adaptability of the load balancing solution.

[0023] The present application will now be described in further detail with reference to the accompanying drawings and embodiments.

[0024] This application provides a load balancing method applied to an electronic device, which is used for load balancing scheduling and can be understood as cloud computing. Figure 1 As shown, the method includes: Step 101: Based on the load information of each of the one or more first nodes, the first information of each first node, and the received service requests, construct the first feature vector of each first node.

[0025] Wherein, the first information represents the relevant information of the first node in processing historical service requests; the service request is used to request the provision of user services; the first feature vector includes the CPU utilization of the first node, the memory utilization of the first node, the disk utilization of the first node, the reception delay of the historical service request of the first node, the processing time of the historical service request of the first node, the type of the user service, and the resource consumption of the user service.

[0026] Here, upon receiving a service request, log records for one or more first nodes can be retrieved from the local machine or log system. Based on these log records, the load information and first information of each first node are determined, thereby identifying CPU utilization, memory utilization, disk utilization, historical service request reception latency, and historical service request processing time in the first feature vector. Based on the information carried by the service request, the type of service request and resource consumption can be determined, including CPU usage time, memory consumption, and disk consumption. A first node can be understood as a server node in a cloud computing architecture, used to deploy microservices to provide user services.

[0027] The log system can be a distributed log system used to store the log records of all first nodes. For example, for each first node, the log record may include one or more of the following: CPU usage time of the first node, CPU idle time of the first node, memory usage of the first node, memory free amount of the first node, disk usage of the first node, disk free amount of the first node, time of scheduling historical service requests, time of receiving historical service requests by the first node, time of responding to historical service requests by the first node, and the result of executing historical service requests by the first node. Taking the i-th first node as an example, Table 1 shows the symbols and their corresponding meanings in the log record of the i-th first node.

[0028] Table 1. Symbols and their corresponding meanings in the log record of the i-th first node.

[0029] The result of executing historical service requests for the corresponding first node can be either 0 or 1. A value of 0 indicates scheduling failure, and a value of 1 indicates scheduling success. Log records in the log system are reported periodically by each first node.

[0030] Alternatively, the load information and first information of each first node can be obtained directly from the log system; for example, for each first node, the log record of the first node may also include one or more of the following: CPU utilization of the first node, memory utilization of the first node, disk utilization of the first node, reception latency of historical service requests of the first node, and processing time of historical service requests of the first node.

[0031] The logging system can also include the time point of the log record, that is, it can also include the time point of each log record of each first node.

[0032] Step 102: Input the first feature vector of each first node into the load balancing network to obtain the scheduling score of each first node.

[0033] Here, for each first node, its first feature vector can be input into the load balancing network to obtain the scheduling score of that first node; alternatively, the first feature vectors of all first nodes can be input into the load balancing network to output the scheduling score of each first node in all first nodes at once.

[0034] Step 103: Based on the scheduling score of each first node, select a scheduling node from the one or more first nodes, and schedule the received service request to the scheduling node.

[0035] Here, based on the scheduling score, the first node that is optimal for the currently received service request is selected from one or more first nodes as the scheduling node, and the received service request is scheduled to the scheduling node, that is, the scheduling node processes and responds to the received service request.

[0036] Since the load of a server node itself does not determine the speed of microservice execution in a real-world scenario, but only measures the success rate of scheduling, this embodiment measures the speed of microservice execution by introducing the reception latency and processing time of historical service requests from the first node, thereby improving the execution efficiency of microservices, i.e., improving the service request processing efficiency of the first node. It also introduces the type of user service, which improves the scenario adaptability of the load balancing scheme, making the load balancing scheme applicable to various application scenarios, and thus selecting the optimal scheduling scheme.

[0037] The load status of the first node at the moment a service request is received cannot fully assess the performance of the first node. To improve the availability and effectiveness of load information, avoid the misleading influence of instantaneous status on scheduling results, and thus improve the accuracy of load balancing and the success rate of service request scheduling, in one embodiment, the first feature vector includes a second feature vector for each time point within a certain period. The construction of the first feature vector for each first node based on the load information of each of one or more first nodes, the first information of each first node, and the received service request includes: For each time point, based on the load information of the corresponding first node at that time point, the first information of the corresponding first node, and the received service request, a second feature vector of the corresponding first node at that time point is constructed; the second feature vector includes the CPU utilization rate of the corresponding first node at that time point, the memory utilization rate of the corresponding first node at that time point, the disk utilization rate of the corresponding first node at that time point, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; Based on the second feature vector of the corresponding first node at each time point, construct the first feature vector of the corresponding first node.

[0038] Here, the first feature vector includes the second feature vector at each time point within a certain period. This period can be understood as a set time interval preceding the time the service request is received. The interval between time points can be determined based on the specific application, and the set time interval can be determined based on the user services provided by the first node, the application scenario, etc. The second feature vector at each time point is determined based on the currently received service request, the load information of the corresponding first node at that time point, and the first information of the first node. In practical applications, the second feature vector of each first node at each time point can be determined for each first node, thereby determining the first feature vector of the first node. Alternatively, the second feature vector of each first node at that time point can be determined for each first node, thereby determining the first feature vector of each first node. For example, for each first node, the log records of the first node within a certain period before receiving the service request are obtained. Based on the log records of the first node at each time point within that period, the load information of the first node at each time point is determined accordingly. Then, combined with the first information of the first node, the type of service request, and the resource consumption, the second feature vector of the first node at each time point is determined accordingly. The specific implementation method for each time point is similar to the specific implementation method for each first node described above.

[0039] The first information for each first node may include the reception latency and processing time of the last historical service request processed by the corresponding first node before the service request was received, or it may include the average reception latency and average processing time of all historical service requests processed by the corresponding first node before the service request was received.

[0040] The second feature vectors of the corresponding first node at each time point are combined to form the first feature vector of the corresponding first node. For example, the first feature vector can be represented as... ,in, The first feature vector represents the i-th first node at time t, where time t is the moment the service request is received, and n represents the set duration. The second eigenvector represents the i-th first node at time t-n+1. The second eigenvector of the i-th first node at time t can be expressed as: ,in, The CPU utilization of the i-th first node at time t is represented. The memory utilization rate of the i-th first node at time t is represented. The disk utilization rate of the i-th first node at time t is represented. The reception delay of historical service requests for the i-th first node up to time t is represented. The processing time of historical service requests for the i-th first node up to time t is represented by this parameter. Characterizes the type of user service; The average CPU usage time of a user service up to time t can be calculated by averaging the historical CPU usage time of this type of user service before time t. The average memory usage of a user service up to time t can be calculated from the historical average memory usage of this type of user service before time t. The average disk usage of a user service up to time t can be calculated from the historical average disk usage of that type of user service before time t.

[0041] In this embodiment, by using the load information of the period before receiving the service request, the load performance of the server node is fully evaluated from the load change trend, so as to fully evaluate the current performance of the server node and thus improve the availability and effectiveness of the first feature vector.

[0042] To measure the execution efficiency of microservices, improve the scheduling effect of load balancing, and enhance the response speed of service requests, in one embodiment, the reception latency of historical service requests for the corresponding first node is determined based on the scheduling time of the historical service requests and the time when the corresponding first node receives the historical service requests; the processing time of historical service requests for the corresponding first node is determined based on the time when the corresponding first node receives the historical service requests and the time when the corresponding first node responds to the historical service requests. The processing time of historical service requests can also be understood as the processing time of microservices.

[0043] Here, the reception latency of historical service requests corresponding to the first node can be calculated by subtracting the scheduling time of the most recent historical service request from the time the first node receives it; alternatively, it can be calculated by averaging the reception latency of all historical service requests received by the first node. For example, it can be obtained using the formula... The reception latency of the most recent historical service request of the i-th first node is calculated, where, This represents the time before the i-th first node received the most recent historical service request before time t. This represents the scheduling time of the most recent historical service request.

[0044] The processing time for a historical service request corresponding to the first node can be calculated by subtracting the time it took for the first node to receive the most recent historical service request from the time it took for the first node to respond to it; alternatively, it can be calculated by averaging the processing times of all historical service requests received by the first node. For example, it can be calculated using the formula... The reception latency of the most recent historical service request of the i-th first node is calculated, where, This represents the time before the i-th first node responded to the most recent historical service request received before time t. It represents the time before the i-th first node received the most recent historical service request before time t.

[0045] Additionally, CPU utilization can be calculated as the ratio of CPU usage time to total CPU time, and total CPU time can be calculated by adding CPU usage time and CPU idle time; for example, it can be calculated using the formula... The CPU utilization of the i-th first node at time t is calculated, where, The CPU usage time of the i-th first node at time t is represented. This represents the CPU idle time of the i-th first node at time t.

[0046] Memory utilization can be calculated as the ratio of memory usage to total memory capacity. Total memory capacity can be calculated by adding the amount of memory used and the amount of free memory. For example, it can be calculated using the formula... The memory utilization rate of the i-th first node at time t is calculated, where, This represents the memory usage of the i-th first node at time t. This represents the amount of free memory for the i-th first node at time t.

[0047] Disk utilization can be calculated as the ratio of disk usage to total disk capacity. Total disk capacity can be calculated by adding disk usage and free disk space; for example, it can be calculated using the formula... The CPU utilization of the i-th first node at time t is calculated, where, The CPU usage time of the i-th first node at time t is represented. This represents the CPU idle time of the i-th first node at time t.

[0048] To improve the load balancing evaluation performance and accuracy of load balancing scheduling evaluation in a load balancing network, in one embodiment, the training method for the load balancing network includes: For each training sample in the training sample set, the third feature vector in the training sample is input into the load balancing network to obtain the scheduling score corresponding to the third feature vector. The target score is calculated based on the reward in the training sample, the next state feature vector in the training sample, and the target network; the network structure of the target network is the same as that of the load balancing network; the parameters of the target network are obtained by copying the parameters of the load balancing network. Based on the scheduling score corresponding to the third feature vector, the target score, and the set loss function, the parameters of the load balancing network are updated until the training termination condition is met.

[0049] Here, the load balancing network is trained using the Double Deep Q-Network (DDQN) training method. Specifically, multiple training samples can be randomly selected from the experience pool to form the training sample set for this training. For each training sample in the training sample set, the third feature vector of the training sample is input into the load balancing network to obtain the scheduling score corresponding to the third feature vector. The scheduling score corresponding to the third feature vector can be understood as the scheduling score of the server node corresponding to the third feature vector.

[0050] The training samples in the experience pool are collected by scheduling different service requests to different server nodes in actual applications. The training samples include at least a third feature vector, a reward, and a next-state feature vector. The third feature vector corresponds to the first feature vector and includes the CPU utilization, memory utilization, disk utilization, historical service request reception latency, historical service request processing time, user service type, and user service resource consumption of the corresponding first node; or it includes a second feature vector for each time point within a certain period, which includes the CPU utilization, memory utilization, disk utilization, historical service request reception latency, historical service request processing time, user service type, and user service resource consumption of the corresponding first node at that time point.

[0051] For each training sample, the next state can be understood as the state of the first node after the service request corresponding to that training sample is scheduled to the first node corresponding to the third feature vector in that training sample. The next state feature vector may include the CPU utilization, memory utilization, disk utilization, historical service request reception latency, historical service request processing time, service request type, and resource consumption of the first node in the next state. The historical service request reception latency and historical service request processing time of the first node can be the same as the corresponding parameter values ​​in the third feature vector, or they can be re-determined based on the processing result of the service request.

[0052] Based on the reward in the training sample, the next-state feature vector in the training sample, and the target network, the target score is calculated. Specifically, the next-state feature vector in the training sample is input into the target network to obtain the intermediate score; the sum of the reward in the training sample and the first product is calculated to obtain the target score, where the first product represents the product of the discount factor and the intermediate score. For example, the target score of the first training sample in the training sample set can be obtained using the formula... The calculation yielded that, The feature vector representing the next state Characterize the target network, Characterizing the discount factor, This represents the reward in the training sample.

[0053] Based on the scheduling score, target score, and set loss function corresponding to the third feature vector, the parameters of the load balancing network are updated until the training termination condition is met. Specifically, the loss value can be calculated based on the scheduling score, target score, and set loss function corresponding to the third feature vector, and gradient descent can be performed on the load balancing network based on the loss value and set loss function to update the parameters of the load balancing network until the training termination condition is met. The set loss function can be the mean squared error loss function, and the parameters of the load balancing network can be adjusted based on the loss value of a single training sample or based on the loss values ​​of all training samples in the training sample set. For example, the formula for the loss function can be expressed as follows: Where N represents the number of training samples in the training sample set. The target score represents the j-th training sample in the training sample set. The scheduling score represents the third feature vector in the j-th training sample. Characterizing the load balancing network, The third feature vector represents the j-th training sample. Training termination conditions may include reaching a preset number of training rounds for parameter updates, the average cumulative reward exceeding a preset reward threshold over N consecutive rounds, or the network parameters no longer showing significant updates. After the load balancing network has been updated a set number of times, the parameters of the load balancing network are copied to the target network.

[0054] In this embodiment, the training process of the load balancing network is based on the principle of reinforcement learning, such as... Figure 2 The Markov decision process shown in the diagram involves the load balancing network using the third feature vector. Mapped to scheduling score A reward and punishment mechanism is adopted to reward and penalize scheduling accuracy, and rewards are obtained accordingly. and the next state feature vector After training the load balancing network, the next training sample is obtained, and the third feature vector of the next training sample is used. Mapped to scheduling score Get rewards and the next state feature vector Continue training the load balancing network to obtain the fully trained load balancing network.

[0055] In order to integrate powerful time series processing capabilities and accurately determine the load change trend of the first node, in one embodiment, the load balancing network is an LSTM network.

[0056] Here, both the load balancing network and the target network are LSTM networks with the same network structure. The first or third feature vector is input into the load balancing network to obtain the corresponding scheduling score. The first feature vector includes the second feature vector at each time point within a certain period, and the third feature vector includes the fourth feature vector at each time point within a certain period. Specifically, for each second feature vector in the first feature vector, this second feature vector, along with the output result obtained based on the second feature vector at the previous time point, is input into the load balancing network to obtain the output result of the second feature vector. This output result is then input into the load balancing network along with the second feature vector at the next time point, until the output result of the last second feature vector is obtained. In other words, the output result of each second feature vector, along with the second feature vector at the next time point, is processed by the load balancing network and used for subsequent iterative calculations until the output result of the second feature vector at the last time point in the first feature vector is obtained, thus obtaining the scheduling score corresponding to the first feature vector, and consequently, the scheduling score of the corresponding first node. The output result of the second feature vector can also be understood as the hidden state of the second feature vector. The processing method for the third feature vector is the same as that for the first feature vector. The basic neural network structure of a gate in a load balancing network can be a three-layer perceptron. The input layer of the three-layer perceptron is used to receive the input feature vector, and the output layer consists of one neuron, which processes the output value through an activation function (such as the sigmoid activation function).

[0057] Taking the first feature vector as an example, such as Figure 3 As shown, the process of LSTM network processing time series data is described by the processing method of the last three second feature vectors of the first feature vector. This involves processing the second feature vector of the i-th first node at time t-2. Input load balancing network, get Output results ; the second eigenvector of the i-th first node at time t-1 Input load balancing network, get Output results ; the second eigenvector of the i-th first node at time t Input load balancing network, get Output results ,in, That is, the scheduling score of the i-th first node; Figure 3 In It is a three-layer perceptron.

[0058] In order to control the optimization direction of the load balancing network, strengthen the guidance of the final result, and improve the scheduling success rate, in one embodiment, the reward value is -1 or 1. The reward value of -1 indicates that the request scheduling corresponding to the training sample failed, and the reward value of 1 indicates that the request scheduling corresponding to the training sample succeeded.

[0059] Here, a reward of +1 for successful scheduling or -1 for failed scheduling is used to assist in evaluating the scheduling result of dispatching a service request to the corresponding first node. When acquiring training samples, a request is dispatched to a server node. If the scheduling is successful, the reward is set to +1; if the scheduling fails, the reward is set to -1. Based on the load information and first information of the server node before scheduling, as well as the relevant information of the request, the third feature vector of the training sample is constructed. After the server node is dispatched, the load information and first information are acquired to construct the next state feature vector, thereby collecting the training sample.

[0060] To determine the optimal scheduling scheme, in one embodiment, selecting a scheduling node from the one or more first nodes based on the scheduling score of each first node includes: The first node with the highest scheduling score among the one or more first nodes is determined as the scheduling node.

[0061] Here, the higher the scheduling score, the more likely the currently received service request will be scheduled to the corresponding first node. That is, given the scheduling score of each first node, all first nodes are sorted from highest to lowest scheduling score, and the first node with the highest scheduling score is selected as the scheduling node. The scheduling score can also be dynamically adjusted by combining the historical service request handling volume. For example, the scheduling score of the first node whose number of service requests handled is greater than or equal to a first set threshold can be reduced, and / or the scheduling score of the first node whose number of service requests handled is less than or equal to a second set threshold can be increased. Specifically, the scheduling score can be dynamically adjusted by setting the weight corresponding to the historical service request handling volume.

[0062] The following section provides a more detailed description of this application with reference to application examples.

[0063] like Figure 4As shown, the load balancing method can be implemented by the load balancer scheduler in the load balancing system. The load balancing system can also include a security gateway, a service registry, and a distributed log system, forming a closed-loop decision-making mechanism. The load balancer scheduler, service registry, and distributed log system can be centrally deployed on a single device or distributed across different devices. Service requests sent by users pass through the security gateway to the load balancer scheduler. The load balancer scheduler monitors the status of each microservice through the service registry. Microservices are deployed on the first node, and the load balancer obtains load information and other information from the distributed log system for each first node to schedule service requests to the optimal first node. The microservices on the first node then provide user services, achieving load balancing scheduling of service requests.

[0064] As the system entry point, the security gateway uses authorization protocols (such as OAuth2.0) to implement request authentication and traffic shaping. It ensures the security of service access through token verification using JSON Web Tokens (JWT) based on JavaScript Object Notation. At the same time, it integrates a Web Application Firewall (WAF) module to defend against network security threats such as Distributed Denial of Service (DDoS) attacks.

[0065] The service registry employs a distributed key-value storage architecture to maintain real-time topology status information of service nodes, with each service node serving as the primary node. The data model comprises a three-layer metadata structure: the physical layer records node hardware configurations, including the number of CPU cores, memory capacity, and GPU (Graphics Processing Unit) model; the network layer stores inter-node latency matrices and bandwidth parameters; and the service layer dynamically updates the health status of each microservice instance. The service registry also utilizes a heartbeat mechanism to ensure the timeliness of node information, providing a precise service discovery foundation for load balancing.

[0066] The distributed log system is built on the Elastic Stack technology stack to achieve the collection and analysis of full load data. It is designed with a three-stage data processing pipeline: First, a data collector (such as Fluentd) is used to capture node performance indicators in real time, including parameters such as CPU utilization, memory usage, and bandwidth. Then, a high-throughput message queue is built using a distributed messaging system (such as Apache Kafka) to achieve buffering and partitioning of log data. Finally, feature engineering is completed in the Spark structured stream processing engine to generate an enhanced load dataset containing time-series trends and statistical features.

[0067] Load balancing methods may include the following steps: Step 1: Based on the load information of each first node in one or more first nodes, the first information of each first node, and the received service requests, construct the first feature vector of each first node.

[0068] Here, the first feature vector includes the second feature vector at each time point within a certain period. For each time point, based on the load information of the corresponding first node at that time point, the first information of the corresponding first node, and the received service requests, a second feature vector of the corresponding first node at that time point is constructed. The second feature vector includes the CPU utilization, memory utilization, disk utilization, historical service request reception latency, historical service request processing time, user service type, and user service resource consumption of the corresponding first node at that time point. Based on the second feature vector of the corresponding first node at each time point, a first feature vector of the corresponding first node is constructed. The historical service request reception latency of the corresponding first node is determined based on the scheduling time of the historical service request and the time when the corresponding first node receives the historical service request. The historical service request processing time of the corresponding first node is determined based on the time when the corresponding first node receives the historical service request and the time when the corresponding first node responds to the historical service request. For example, if there are currently m first nodes that can participate in scheduling, and the first feature vectors of each first node are respectively... The first feature vector of each first node includes the second feature vector of each corresponding time point.

[0069] Step 2: Input the first feature vector of each first node into the load balancing network to obtain the scheduling score of each first node.

[0070] Here, for each first node, its first feature vector is input into the load balancing network to obtain its scheduling score; for example, the scheduling scores of each first node are as follows: The load balancing network is trained using DDQN, and deep reinforcement learning further enhances its flexibility and intelligence, enabling it to handle unforeseen failures.

[0071] Step 3: Based on the scheduling score of each first node, select a scheduling node from one or more first nodes and schedule the received service requests to the scheduling node.

[0072] Here, the first node with the highest scheduling score among one or more first nodes is determined as the scheduling node; for example, through the formula... Determine the number of the scheduling node.

[0073] To implement the method of the embodiments of this application, the embodiments of this application also provide a load balancing device, such as... Figure 5 As shown, the device includes: The construction unit 501 is configured to construct a first feature vector for each first node based on the load information of each first node in one or more first nodes, the first information of each first node, and the received service requests; the first information represents the relevant information of the corresponding first node in processing historical service requests; the service request is used to request the provision of user services; the first feature vector includes the CPU utilization of the corresponding first node, the memory utilization of the corresponding first node, the disk utilization of the corresponding first node, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; Evaluation unit 502 is used to input the first feature vector of each first node into the load balancing network to obtain the scheduling score of each first node; The scheduling unit 503 is used to select a scheduling node from the one or more first nodes based on the scheduling score of each first node, and to schedule the received service request to the scheduling node.

[0074] In one embodiment, the first feature vector includes a second feature vector for each time point within a certain period; the construction unit 501 is specifically configured to construct a second feature vector for each time point based on the load information of the corresponding first node at that time point, the first information of the corresponding first node, and the received service request; the second feature vector includes the CPU utilization rate of the corresponding first node at that time point, the memory utilization rate of the corresponding first node at that time point, the disk utilization rate of the corresponding first node at that time point, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; Based on the second feature vector of the corresponding first node at each time point, construct the first feature vector of the corresponding first node.

[0075] In one embodiment, the reception delay of the historical service request of the corresponding first node is determined based on the scheduling time of the historical service request and the time when the corresponding first node receives the historical service request; the processing time of the historical service request of the corresponding first node is determined based on the time when the corresponding first node receives the historical service request and the time when the corresponding first node responds to the historical service request.

[0076] In one embodiment, the device further includes: The training unit is used to input the third feature vector of each training sample in the training sample set into the load balancing network to obtain the scheduling score corresponding to the third feature vector. The target score is calculated based on the reward in the training sample, the next state feature vector in the training sample, and the target network; the network structure of the target network is the same as that of the load balancing network; the parameters of the target network are obtained by copying the parameters of the load balancing network. Based on the scheduling score corresponding to the third feature vector, the target score, and the set loss function, the parameters of the load balancing network are updated until the training termination condition is met.

[0077] In one embodiment, the load balancing network is an LSTM network.

[0078] In one embodiment, the reward value is -1 or 1, where a reward value of -1 indicates that the request scheduling corresponding to the training sample failed, and a reward value of 1 indicates that the request scheduling corresponding to the training sample succeeded.

[0079] In one embodiment, the scheduling unit 503 is specifically used to determine the first node with the highest scheduling score among the one or more first nodes as the scheduling node.

[0080] In practical applications, the construction unit 501, the evaluation unit 502, the scheduling unit 503, and the training unit can be implemented by the processor in the load balancing device combined with the communication interface.

[0081] It should be noted that the load balancing device provided in the above embodiments is only illustrated by the division of the above program modules. In practical applications, the above processing can be distributed to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the processing described above. In addition, the load balancing device and the load balancing method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.

[0082] Based on the hardware implementation of the above program modules, embodiments of this application also provide an electronic device, such as... Figure 6 As shown, the electronic device 600 includes: The communication interface 601 allows for information exchange with other devices or network nodes.

[0083] The processor 602 is connected to the communication interface 601 to enable information interaction with other devices or network nodes, and to execute the methods provided by one or more technical solutions in the above embodiments when running computer programs.

[0084] Memory 603 is used to store computer programs that can run on processor 602.

[0085] Specifically, the processor 602 is configured to construct a first feature vector for each of the one or more first nodes based on the load information of each first node, the first information of each first node, and the received service requests; the first information represents the relevant information of the corresponding first node in processing historical service requests; the service request is used to request the provision of user services; the first feature vector includes the CPU utilization of the corresponding first node, the memory utilization of the corresponding first node, the disk utilization of the corresponding first node, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; The first feature vector of each first node is input into the load balancing network to obtain the scheduling score of each first node; Based on the scheduling score of each first node, a scheduling node is selected from the one or more first nodes, and the received service request is scheduled to the scheduling node.

[0086] In one embodiment, the first feature vector includes a second feature vector for each time point within a certain period; the processor 602 is specifically configured to construct a second feature vector for each time point based on the load information of the corresponding first node at that time point, the first information of the corresponding first node, and the received service request; the second feature vector includes the CPU utilization rate of the corresponding first node at that time point, the memory utilization rate of the corresponding first node at that time point, the disk utilization rate of the corresponding first node at that time point, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; Based on the second feature vector of the corresponding first node at each time point, construct the first feature vector of the corresponding first node.

[0087] In one embodiment, the reception delay of the historical service request of the corresponding first node is determined based on the scheduling time of the historical service request and the time when the corresponding first node receives the historical service request; the processing time of the historical service request of the corresponding first node is determined based on the time when the corresponding first node receives the historical service request and the time when the corresponding first node responds to the historical service request.

[0088] In one embodiment, the processor 602 is further configured to input the third feature vector in the training sample to the load balancing network for each training sample in the training sample set, so as to obtain the scheduling score corresponding to the third feature vector. The target score is calculated based on the reward in the training sample, the next state feature vector in the training sample, and the target network; the network structure of the target network is the same as that of the load balancing network; the parameters of the target network are obtained by copying the parameters of the load balancing network. Based on the scheduling score corresponding to the third feature vector, the target score, and the set loss function, the parameters of the load balancing network are updated until the training termination condition is met.

[0089] In one embodiment, the load balancing network is an LSTM network.

[0090] In one embodiment, the reward value is -1 or 1, where a reward value of -1 indicates that the request scheduling corresponding to the training sample failed, and a reward value of 1 indicates that the request scheduling corresponding to the training sample succeeded.

[0091] In one embodiment, the processor 602 is specifically configured to determine the first node with the highest scheduling score among the one or more first nodes as the scheduling node.

[0092] It should be noted that the specific processing procedure of processor 602 can be understood by referring to the above method. Of course, in practical applications, the various components in electronic device 600 are coupled together through bus system 604. It can be understood that bus system 604 is used to realize the connection and communication between these components. In addition to the data bus, bus system 604 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in... Figure 6 The general designated all buses as Bus System 604.

[0093] The memory 603 in this embodiment is used to store various types of data to support the operation of the electronic device 600. Examples of such data include any computer program used to operate on the electronic device 600.

[0094] The methods disclosed in the embodiments of this application can be applied to, or implemented by, the processor 602. The processor 602 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by the integrated logic circuitry of the hardware in the processor 602 or by instructions in software form. The processor 602 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 602 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, specifically in memory 603. The processor 602 reads information from memory 603 and, in conjunction with its hardware, completes the steps of the aforementioned method.

[0095] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned method.

[0096] It is understood that the memory (memory 603) in this embodiment of the application can be volatile memory or non-volatile memory, or it can include both volatile memory and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), magnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); the magnetic surface memory can be disk storage or magnetic tape storage. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memories described in the embodiments of this application are intended to include, but are not limited to, these and any other suitable types of memories.

[0097] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 603 storing a computer program, which can be executed by the processor 602 of the electronic device 600 to complete the steps described in any of the aforementioned methods. The computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM.

[0098] For example, embodiments of this application also provide a computer program product, including a computer program that can be executed by a processor 602 of an electronic device 600 to perform the steps described in any of the foregoing methods.

[0099] It should be noted that terms such as "first" and "second" are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. The term "and / or" in this document merely describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The terms "one or more" and "one or more" in this document are exemplary expressions and can be replaced with any possible expressions, such as one or more, at least one, or at least one. Furthermore, the technical solutions described in the embodiments of this application can be arbitrarily combined without conflict. The above descriptions are merely preferred embodiments of this application and are not intended to limit the scope of protection of this application.

Claims

1. A load balancing method, characterized in that, The method includes: Based on the load information of each of the one or more first nodes, the first information of each first node, and the received service requests, a first feature vector is constructed for each first node; the first information represents the relevant information of the corresponding first node in processing historical service requests; the service request is used to request the provision of user services; the first feature vector includes the CPU utilization of the corresponding first node, the memory utilization of the corresponding first node, the disk utilization of the corresponding first node, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; The first feature vector of each first node is input into the load balancing network to obtain the scheduling score of each first node; Based on the scheduling score of each first node, a scheduling node is selected from the one or more first nodes, and the received service request is scheduled to the scheduling node.

2. The method according to claim 1, characterized in that, The first feature vector includes a second feature vector for each time point within a certain period; the construction of the first feature vector for each first node based on the load information of each of the one or more first nodes, the first information of each first node, and the received service requests includes: For each time point, based on the load information of the corresponding first node at that time point, the first information of the corresponding first node, and the received service request, a second feature vector of the corresponding first node at that time point is constructed; the second feature vector includes the CPU utilization rate of the corresponding first node at that time point, the memory utilization rate of the corresponding first node at that time point, the disk utilization rate of the corresponding first node at that time point, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service; Based on the second feature vector of the corresponding first node at each time point, construct the first feature vector of the corresponding first node.

3. The method according to claim 1 or 2, characterized in that, The reception delay of the historical service request of the corresponding first node is determined based on the scheduling time of the historical service request and the time when the corresponding first node receives the historical service request; the processing time of the historical service request of the corresponding first node is determined based on the time when the corresponding first node receives the historical service request and the time when the corresponding first node responds to the historical service request.

4. The method according to claim 1 or 2, characterized in that, The training method for the load balancing network includes: For each training sample in the training sample set, the third feature vector in the training sample is input into the load balancing network to obtain the scheduling score corresponding to the third feature vector. The target score is calculated based on the reward in the training sample, the next state feature vector in the training sample, and the target network; the network structure of the target network is the same as that of the load balancing network; the parameters of the target network are obtained by copying the parameters of the load balancing network. Based on the scheduling score corresponding to the third feature vector, the target score, and the set loss function, the parameters of the load balancing network are updated until the training termination condition is met.

5. The method according to claim 2, characterized in that, The load balancing network is a Long Short-Term Memory (LSTM) network.

6. The method according to claim 4, characterized in that, The reward value is either -1 or 1. A reward value of -1 indicates that the request scheduling corresponding to the training sample failed, and a reward value of 1 indicates that the request scheduling corresponding to the training sample succeeded.

7. The method according to claim 1, characterized in that, The step of selecting a scheduling node from one or more first nodes based on the scheduling score of each first node includes: The first node with the highest scheduling score among the one or more first nodes is determined as the scheduling node.

8. A load balancing device, characterized in that, include: The construction unit is used to construct a first feature vector for each first node based on the load information of each first node in one or more first nodes, the first information of each first node, and the received service requests; the first information represents the relevant information of the corresponding first node in processing historical service requests. The service request is used to request the provision of user services; the first feature vector includes the CPU utilization of the corresponding first node, the memory utilization of the corresponding first node, the disk utilization of the corresponding first node, the reception latency of the historical service requests of the corresponding first node, the processing time of the historical service requests of the corresponding first node, the type of the user service, and the resource consumption of the user service. An evaluation unit is used to input the first feature vector of each first node into the load balancing network to obtain a scheduling score for each first node. The scheduling unit is used to select a scheduling node from the one or more first nodes based on the scheduling score of each first node, and to schedule the received service request to the scheduling node.

9. An electronic device, characterized in that, The method includes a processor and a memory for storing a computer program capable of running on the processor, wherein, when the processor is used to run the computer program, it performs the steps of the method according to any one of claims 1 to 7.

10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.

11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.