Scheduling method and device for load balancing in power data micro-service architecture

By combining round-robin and dynamic load balancing algorithms, the target server is dynamically selected to handle task requests, solving the problem of load imbalance in microservice architecture and improving the system's concurrency and stability.

CN120909765APending Publication Date: 2025-11-07INFORMATION & COMMUNICATION BRANCH STATE GRID JIBEI ELECTRIC POWER CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510880610.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-27
Publication Date
2025-11-07

AI Technical Summary

Technical Problem

In a microservice architecture, uneven load distribution across server clusters can lead to longer task response times and impact system concurrency.

Method used

A combination strategy of two load balancing algorithms and two time periods is adopted: a round-robin algorithm is used when the load utilization is below the threshold, and a dynamic load balancing algorithm is used when it is above the threshold, dynamically selecting the target server to handle task requests.

Benefits of technology

This improves system concurrency, avoids deploying microservice instances on high-load servers, and ensures the stability and efficiency of high-concurrency microservice operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120909765A_ABST
    Figure CN120909765A_ABST
Patent Text Reader

Abstract

The invention discloses a scheduling method and device for load balancing in an electric power data micro-service architecture, and relates to the technical field of electric power data micro-service architectures. According to the main technical scheme, two different algorithms are provided to select a target server responding to a task request according to the overall load utilization rate of a plurality of servers supporting the same micro-service, and two time periods with the inclusion relation are adopted; the selection of the two different algorithms can be dynamically updated, and especially for the selection of a preset dynamic load balancing algorithm, the target server responding to the task request can be dynamically updated and selected according to the current load balancing condition. By combining the two provided different algorithms and the two time periods, the micro-service instance on the optimal target server is dynamically updated and called to process the task request adapting to the current load condition, the concurrency of the system is improved, and the whole micro-service runs in a high-concurrency manner.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of power data micro-service architecture, and in particular to a load balancing scheduling method and device in a power data micro-service architecture. BACKGROUND

[0002] Microservices Architecture is a design pattern that breaks down a large application into a set of small, loosely coupled services, each focusing on a specific function and interacting through lightweight communication protocols such as RESTful APIs.

[0003] Power data micro-service architecture is a design pattern that breaks down power data-related systems (such as SCADA systems, power marketing systems, and smart meter data platforms) into multiple independent services, each responsible for processing specific types of power data (such as real-time data collection, historical data storage, and data analysis modeling), to achieve efficient management and application of power data.

[0004] Currently, in a micro-service architecture, each micro-service can be independently deployed on a single server or distributed to different servers, which form a cluster. As the system runs for a long time, the load of each server in the cluster will be unbalanced. When a client initiates a task request, if the scheduled micro-service instance is deployed on a high-load server, the task response time will be significantly prolonged. Therefore, how to design a solution for load balancing to improve the concurrency of the system and enable the entire micro-service to run in high concurrency is a technical problem that needs to be solved. SUMMARY

[0005] The present application provides a load balancing scheduling method and device in a power data micro-service architecture, which mainly aims to provide a load balancing solution using two different algorithms and two time periods to dynamically update the best target server instance to handle task requests, thereby improving the concurrency of the system and enabling the entire micro-service to run in high concurrency.

[0006] To achieve the above purpose, the present application mainly provides the following technical solutions:

[0007] The first aspect of the present application provides a load balancing scheduling method in a power data micro-service architecture, which comprises:

[0008] receive a high-concurrency task request sent by a client, the task request corresponding to a first microservice, the first microservice being one selected from a plurality of second microservices, the second microservices being a plurality of independent services into which power system business functions are split in a power data microservice architecture; when the second microservices are deployed on one or more servers, a plurality of microservice instances corresponding to the second microservices are started on each of the servers; and each of the servers corresponding to the second microservices constitutes a server cluster.

[0009] determine, from the server cluster, a server to which the first microservice is deployed;

[0010] when the server to which the first microservice is deployed is multiple, calculate, according to a first preset time period, current load utilization rates of the multiple servers to which the first microservice is deployed;

[0011] if the current load utilization rates do not exceed a preset threshold, select a first target server from the multiple servers to which the first microservice is deployed by using a preset round-robin algorithm, and process the task request by using a microservice instance on the first target server;

[0012] if the current load utilization rates exceed the preset threshold, select, in a second preset time period in the first preset time period, a second target server with the smallest load from the multiple servers to which the first microservice is deployed by using a preset dynamic load balancing algorithm, and process the task request by using a microservice instance on the second target server.

[0013] The second aspect of the application provides a scheduling device for load balancing in a power data microservice architecture, which comprises:

[0014] a receiving unit configured to receive a high-concurrency task request sent by a client, the task request corresponding to a first microservice, the first microservice being one selected from a plurality of second microservices, the second microservices being a plurality of independent services into which power system business functions are split in a power data microservice architecture; when the second microservices are deployed on one or more servers, a plurality of microservice instances corresponding to the second microservices are started on each of the servers; and each of the servers corresponding to the second microservices constitutes a server cluster.

[0015] a first determining unit configured to determine, from the server cluster, a server to which the first microservice is deployed;

[0016] a calculating unit configured to, when the server to which the first microservice is deployed is multiple, calculate, according to a first preset time period, current load utilization rates of the multiple servers to which the first microservice is deployed;

[0017] a first execution unit, configured to, if the current load utilization rate does not exceed the preset threshold, select a first target server from the plurality of servers corresponding to the first micro service by using a preset polling algorithm, and process the task request by using a micro service instance on the first target server;

[0018] a second execution unit, configured to, if the current load utilization rate exceeds the preset threshold, select a second target server with the minimum load from the plurality of servers corresponding to the first micro service by using a preset dynamic load balancing algorithm in the first preset time period and the second preset time period, and process the task request by using a micro service instance on the second target server.

[0019] The third aspect of the present application provides a computer readable storage medium, and the computer readable storage medium stores a computer program. The computer program is executed by a processor to implement the scheduling method for load balancing in the power data micro service architecture.

[0020] The fourth aspect of the present application provides an electronic device, and the device includes at least one processor, at least one memory connected to the processor, and a bus.

[0021] The processor, the memory and the bus complete mutual communication through the bus.

[0022] The processor is configured to call program instructions in the memory to execute the scheduling method for load balancing in the power data micro service architecture.

[0023] By the above technical solution, the technical solution provided by the present application has at least the following advantages:

[0024] The application provides a scheduling method and device for load balancing in a power data micro-service architecture. In the power data micro-service architecture, power system business functions are divided into multiple independent services (i.e., micro-services). Each micro-service can be pre-deployed to one or more servers, and multiple micro-service instances can be started on each server. The servers serving different micro-services can be referred to as a server cluster. When a high-concurrency task request is received from a client, the application determines which servers the micro-service corresponding to the task request is deployed on, according to the task request. Then, according to a first preset time period, the current load utilization of the servers is compared with a preset threshold to determine whether the overall load of the servers is high or low, which indirectly determines whether the current high-concurrency quantity is high or low. If the overall current load of the servers is low, a preset polling algorithm is used to select a target server to respond to the task request. If not, a preset dynamic load balancing algorithm is used to select a target server to respond to the task request according to a second preset time period. Finally, the micro-service instance on the target server processes the task request and feeds back the result.

[0025] Compared with the control requirements of load balancing in the power data micro-service architecture in the prior art, the application provides two different algorithms to select a target server to respond to a task request according to the overall load utilization of multiple servers supporting the same micro-service, and uses two time periods in a containing relationship to dynamically update the selection of the two different algorithms. In particular, for the preset dynamic load balancing algorithm, the selection of the target server to respond to the task request can be dynamically updated according to the current load balancing situation. The above two different algorithms and two time periods make it possible to dynamically update the calling of the micro-service instance on the best target server to process the task request according to the current load situation. The load balancing solution provided by the application avoids deploying the scheduled micro-service instance on a high-load server, which is more conducive to improving the concurrency of the system and enabling the entire micro-service to run in high concurrency.

[0026] The above description is only a summary of the technical solutions of the application. In order to more clearly understand the technical means of the application, the application can be implemented according to the content of the specification, and in order to make the above and other purposes, features and advantages of the application more obvious and easy to understand, the following specific embodiments of the application are described. BRIEF DESCRIPTION OF DRAWINGS

[0027] Various other advantages and benefits will become apparent to those of ordinary skill in the art, upon reading the following detailed description of the preferred embodiments. The accompanying drawings are included to provide a description of the preferred embodiments and are not meant to limit the scope of the application. Moreover, the same reference numerals in the attached drawings indicate the same or similar components. In the drawings:

[0028] Figure 1 A flow chart of a scheduling method for load balancing in an electric power data micro-service architecture is provided for the embodiments of the present application.

[0029] Figure 2 A schematic diagram of a KOA algorithm flow is provided for the embodiments of the present application.

[0030] Figure 3 A scale method schematic diagram is provided for the embodiments of the present application.

[0031] Figure 4 A processing flow schematic diagram of a task processing model is provided for the embodiments of the present application.

[0032] Figure 5 A component block diagram of a scheduling device for load balancing in an electric power data micro-service architecture is provided for the embodiments of the present application.

[0033] Figure 6 A component block diagram of another scheduling device for load balancing in an electric power data micro-service architecture is provided for the embodiments of the present application. DETAILED DESCRIPTION

[0034] Exemplary embodiments of the present application will be described herein below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present application can be more thoroughly understood and so that the scope of the present application can be accurately conveyed to those skilled in the art.

[0035] The electric power data micro-service architecture is a distributed system design pattern for data management and application in the power industry, which disassembles data processing, storage, analysis, etc. in the traditional power system into multiple independent, lightweight micro-service units. Each micro-service focuses on a single business capability (such as data collection, real-time monitoring, load forecasting, etc.), cooperates through standardized interfaces, and realizes efficient management and value mining of electric power data.

[0036] The core feature of the electric power data micro-service architecture is mainly business decoupling and independent deployment, which disassembles complex business of the power system (such as power generation, power transmission, power distribution, power consumption) into independent micro-services, such as “substation data collection service” “user power consumption behavior analysis service”, etc. Each service can be independently developed, tested, and deployed, avoiding the impact of single service failure on the overall system, and improving development efficiency and system stability.

[0037] In the micro-service architecture, each micro-service can be independently deployed on a single server or distributed to different servers, which form a cluster. As the system runs for a long time, the load of each server in the cluster will be unbalanced. When the client initiates a task request, if the scheduled micro-service instance is deployed on a high-load server, the task response time will be significantly prolonged.

[0038] Therefore, in order to design a load balancing solution to make the server resources occupied by the micro-service executing tasks on each server relatively average, the embodiment of the present application provides a load balancing scheduling method in a power data micro-service architecture, as shown in Figure 1 The embodiment of the present application provides the following specific steps for this purpose:

[0039] 101, receiving a high-concurrency task request sent by a client, the task request corresponding to a first micro-service, the first micro-service being selected from a plurality of second micro-services, the second micro-service being a plurality of independent services split from the power system business functions in the power data micro-service architecture; when the second micro-service is deployed on one or more servers, a plurality of micro-service instances corresponding to the second micro-service are started on each server; and each server corresponding to each second micro-service constitutes a server cluster.

[0040] In the power data micro-service architecture, the provided micro-service splitting principle is that the power system business is split into independent services according to functions (such as energy management, device monitoring, user metering, etc.), each service has a single responsibility and can be independently deployed and iterated; the provided cluster and instance relationship is that a single micro-service can be deployed on multiple servers (constituting a cluster), and multiple service instances (such as JVM processes) are started on each server to improve the concurrent processing capability through horizontal expansion; the provided request routing logic is that the client request needs to locate the available instance of the target micro-service through a service discovery mechanism, involving key technologies such as load balancing and health check.

[0041] It should be noted that the words "first" and "second" are used as identifiers in the embodiments of the present application, so that "second micro-service" represents a plurality of independent services split from the power system business functions, i.e. all micro-services, and "first micro-service" represents a target micro-service selected from all micro-services, and the target micro-service corresponds to the task request sent by the client, i.e. the task request needs to be processed by the micro-service instance of the target micro-service.

[0042] 102, determining the server to which the first micro-service is deployed from the server cluster.

[0043] In the embodiments of the present application, according to the deployment of the microservice in the power data microservice architecture as shown in 101, it can be seen that there is a corresponding relationship among the "task request", the "microservice" and the "server", that is, one task request needs a microservice instance of the target microservice to process, and then it needs to know which server or servers the target microservice is deployed on, so as to obtain the microservice instance of the target microservice on the server to process the task request.

[0044] 103、When the server corresponding to the first microservice is multiple, the current load utilization rate of the multiple servers corresponding to the first microservice is calculated according to the first preset time period.

[0045] Wherein, the "current load utilization rate" referred to in the embodiments of the present application is for the whole of the "multiple servers corresponding to the first microservice", not for a single server. For the multiple servers on which the first microservice is deployed, the microservice instance on each server can be applied to process the task request (which is corresponding to the first microservice). Therefore, the "current load utilization rate" is used to preliminarily measure the load state of these servers as a whole.

[0046] For example, the load utilization rate is a comprehensive index of the use degree and efficiency of hardware resources and system resources of the server cluster composed of the multiple servers corresponding to the first microservice when processing task requests. It quantifies the "busy degree" of the cluster through multi-dimensional data, and is a key basis for judging whether the cluster is in a reasonable load state and can efficiently process new tasks.

[0047] For example, the core dimensions of the load utilization rate can include but are not limited to: 1, hardware resource dimension, such as CPU load index, memory resource index, storage resource index, network resource index; 2, system and process dimension, such as process and thread index, system resource scheduling index, etc.

[0048] For example, the process and thread index, such as the number of processes and threads: the total number of processes / threads running in the system, which may exceed the system limit and cause resource exhaustion; the proportion of zombie processes: the proportion of processes that have been terminated but have not released resources, which may occupy PID resources or cause memory leakage.

[0049] For example, the system resource scheduling index, such as CPU scheduling queue length: the number of processes waiting for CPU scheduling, and a long queue indicates that CPU resources are tight; memory page replacement frequency: when the memory is insufficient, the frequency of the system replacing pages to the disk, and high frequency will affect the performance.

[0050] 104a, if the current load utilization rate does not exceed the preset threshold, a preset polling algorithm is used to select a first target server from the plurality of servers corresponding to the first microservice, and a microservice instance on the first target server is used to process the task request.

[0051] In the embodiment of the present application, the measurement threshold corresponding to different dimensions can be set according to the measurement dimension of the load utilization rate. The purpose is to measure the load condition of the server cluster composed of the plurality of servers corresponding to the first microservice, that is, the degree of busy, so as to indirectly represent the high or low task concurrency of the cluster corresponding to the degree.

[0052] Therefore, if the current load utilization rate does not exceed the preset threshold, it represents that the task concurrency of the current cluster is not large, so the preset polling algorithm is used to select a first target server from the plurality of servers corresponding to the first microservice, and a microservice instance on the first target server is used to process the task request. Alternatively, in some modified embodiments, the minimum connection number algorithm can also be used to select the first target server.

[0053] For the server cluster composed of the plurality of servers corresponding to the first microservice, how to measure that the overall load pressure of the cluster is not large, that is, the task concurrency corresponding to the cluster is not high, the polling algorithm and the minimum connection number algorithm can be used to efficiently select which server to process the task request.

[0054] The polling algorithm is the simplest load balancing strategy, and its core idea is to distribute the requests of the client to each server in the server cluster in turn according to the order, so as to ensure that each server can uniformly process the request.

[0055] The minimum connection number algorithm is a dynamic load balancing algorithm, which decides which server to distribute the new request according to the current number of connections of the server. Its core idea is to distribute the request to the server with the least number of connections, because the fewer the number of connections, the lighter the load of the server, and the more resources are available to process new requests.

[0056] 104b, if the current load utilization rate exceeds the preset threshold, a second preset time period is used in a first preset time period, and a preset dynamic load balancing algorithm is used to select a second target server with the smallest load from the plurality of servers corresponding to the first microservice, and a microservice instance on the second target server is used to process the task request.

[0057] However, if the current load utilization exceeds the preset threshold, it indicates that the task concurrency of the current cluster is large, and in a high concurrency environment, due to the imbalance of the performance of each server itself and the different resources occupied when processing tasks, the server load imbalance occurs, which slows down the task processing speed, increases the time delay, and affects the concurrency capability. Therefore, if the "round robin algorithm and minimum connection number algorithm" proposed in 1014a is still used, it is not sufficient to ensure the load balancing of the cluster.

[0058] Therefore, the embodiment of the present application adopts a preset dynamic load balancing algorithm to select a second target server with the smallest load from the plurality of servers corresponding to the first microservice, and uses the microservice instance on the second target server to process the task request.

[0059] Among them, the preset dynamic load balancing algorithm can be but not limited to Kepler optimization algorithm, the purpose of which is to find the optimal solution of the server with the smallest load from the server cluster composed of the plurality of servers corresponding to the first microservice. And the embodiment of the present application also provides a preset time period when using 104b, so as to constantly find the optimal solution of the server with the smallest load in the preset time period, and constantly dynamically update using the time period.

[0060] And between the selection of 104a or 104b, the embodiment of the present application also adds a preset time period in the judgment mechanism, so as to cooperate the preset time period of 103 and the time period of 104b (it needs to be explained that the former contains the latter), so as to constantly dynamically measure the "server cluster composed of the plurality of servers corresponding to the first microservice", so as to constantly select the best target server in the cluster under the current load condition to process the task request.

[0061] It needs to be explained that the above 101-104b is a sample explanation and description of processing high-concurrency task requests of a microservice, so when dealing with multiple microservices, use the above 101-104b to process the task requests of each microservice, then on the larger server cluster composed of the servers corresponding to all microservices, the server resources occupied by the microservices of each server to execute tasks will be optimized to be relatively average, so as to improve the concurrency of the system and make the whole microservice run in high concurrency.

[0062] The embodiments of the present application provide a load balancing scheduling method in the power data micro-service architecture. According to the overall load utilization of the multiple servers supporting the same micro-service, two different algorithms are provided to select the target server responding to the task request, and two time periods in a containing relationship are adopted, and the selection of the two different algorithms can be dynamically updated. In particular, for the selection of the preset dynamic load balancing algorithm, the target server responding to the task request can be dynamically updated according to the current load balancing situation. The two different algorithms and the two time periods are combined to dynamically update the optimal target server to process the task request according to the current load situation. The load balancing solution provided by the embodiments of the present application avoids deploying the scheduled micro-service instance on the high-load server, and is more conducive to improving the concurrency of the system, so that the entire micro-service runs in high concurrency.

[0063] In some modifications, for example, the "pre-set polling algorithm is used to select the first target server from the multiple servers corresponding to the first micro-service" in 104a is explained in detail. The embodiments of the present application provide the following steps:

[0064] A1, for the multiple servers corresponding to the first micro-service, the load utilization of each server is calculated;

[0065] As described above in 103, the embodiments of the present application exemplarily provide multiple dimensions of "load utilization", which can be referred to as measurement indicators of "load utilization". The embodiments of the present application do not limit the specific calculation of each indicator. However, it needs to be explained that no matter which dimensions the "load utilization" contains, the measurement data in each dimension is obtained. However, in order to facilitate the comparison of the load situation in A2-A4 and the corresponding call, the embodiments of the present application can but not limited to use weights to comprehensively process the data information in multiple indicators of "load utilization", so as to convert the indicator values contained in "load utilization" into scores or a value for measurement. This is equivalent to converting the complex data information in multiple dimensions into the same new standard for measurement, so as to facilitate the efficient comparison of the load situation of each server in the cluster composed of the multiple servers corresponding to the first micro-service.

[0066] A2, according to the standard of measuring load utilization from high to low, the multiple servers corresponding to the first micro-service are sorted;

[0067] A3, according to the sorting, a serial number is added to the multiple servers corresponding to the first micro-service;

[0068] A4, according to the serial number, the multiple servers corresponding to the first micro-service are polled to select the first target server.

[0069] As the polling algorithm shown in A1-A4, when a new task request arrives, the load balancer will assign the request to each server in turn according to the pre-set order (for example, the order of the server list). Like a roulette, it goes round and round, each time to the next server. For example, the server list is A, B, C, the first request is assigned to A, the second to B, the third to C, the fourth back to A, and so on.

[0070] In some implementations, as explained in detail for 104b "selecting the second target server with the smallest load from the plurality of servers corresponding to the first microservice using the preset dynamic load balancing algorithm", the embodiments of the present application provide the following steps including:

[0071] B1, for the plurality of servers corresponding to the first microservice, abstract each server as a planet, and the position of the planet is used to represent the current load state of the server.

[0072] B2, adopt the Kepler optimization algorithm to optimize by simulating the movement of the planet in space, so as to select the second target server with the smallest load from the plurality of servers corresponding to the first microservice.

[0073] As B1-B2, the preset dynamic load balancing algorithm provided by the embodiments of the present application, such as the Kepler optimization algorithm (Kepler Optimization Algorithm, KOA), is a meta-heuristic algorithm based on physics.

[0074] Next, combined with the KOA algorithm flow shown in Figure 2 The KOA algorithm flow shown in the figure, from the flow corresponding and load balancing application logic angle, explains how to use the Kepler optimization algorithm (KOA) to realize the load balancing of the server cluster to select the optimal target server.

[0075] (1), initialization link mapping: "initializing the position of the planet, eccentricity and orbital period" is mapped to the server cluster scenario:

[0076] The position of the planet -> the initial candidate server (such as the identification of each physical machine / virtual machine in the cluster, network address), which represents different servers that can handle tasks.

[0077] Eccentricity, orbital period -> can be set as parameters related to inherent properties of the server (such as performance coefficient, affecting the "motion" rule; task allocation period, simulating resource scheduling frequency), which sets the basis for subsequent "motion" (task allocation, state update).

[0078] (2), find "sun" (global optimum): "calculate fitness, find global optimum (i.e. sun)": fitness calculation -> define an index to evaluate server load capacity / processing efficiency (such as CPU usage, memory occupation, network bandwidth, task queue length weighted calculation), the higher the score represents the better "adaptability" of processing task requests.

[0079] Sun (global optimum) -> traverse the server cluster, filter out the server with the highest current fitness as the "optimal reference", similar to the core position of the sun in planetary motion.

[0080] (3), planetary motion simulation (task allocation logic): "determine the Euclidean distance of the sun and the planets" "evaluate the sun's gravity of each planet" -> calculate the "distance" of the candidate server (planet) and "sun" (optimal server), which can be understood as the difference in resource state (such as performance gap, load difference quantitative value); "gravity" is mapped to the "cooperation / competition relationship" between servers, and the server with greater gravity is more likely to adjust its state (strive for task allocation) by referring to the "sun".

[0081] "calculate the speed of the planet" -> combine the current load, task processing capacity of the server, and the gap with the "sun", dynamically calculate the "speed of processing task requests" (such as idle servers can quickly take on tasks, corresponding to high speed), simulate the change of planetary motion speed.

[0082] "generate random numbers rd and r" "update logic branch" -> introduce random mechanism to simulate the uncertainty of planetary motion (similar to the actual cluster in task request burst, server state fluctuation): if rd>r, directly "update the position of the planet" (adjust task allocation, let the server take on new tasks); if not satisfied, "update the distance between the sun and the planets" (re-evaluate the state difference between servers, adjust the task allocation strategy again).

[0083] (4), elite strategy and iterative optimization: "elite strategy" -> keep the servers that perform well in the optimization process (such as high historical fitness, stable task processing nodes), avoid losing high-quality resources due to random fluctuations, and ensure the continuous and efficient operation of the cluster "backbone" servers.

[0084] "calculate fitness, update global optimum (i.e. sun)" -> after task allocation, re-evaluate the server cluster state, update the "sun" (optimal target server), and ensure that the current optimal resource is always used to respond to high-concurrency requests.

[0085] (5) Termination condition and continuous load balancing: "Arrival of termination time" can correspond to two scenarios: single task scheduling period: after completing a batch of high-concurrency task allocation, the algorithm is suspended, and the process is restarted when new task requests are incoming. Dynamic continuous scheduling: real-time monitoring of cluster state, if the server load, task request volume reaches the threshold (such as resource depletion warning, request accumulation), trigger "restart", continuous optimization of task allocation, guarantee the load balancing of server cluster in high-concurrency scenario, let the optimal target server (sun and high-quality planets) efficiently process requests, avoid single point overload.

[0086] In summary, the KOA algorithm simulates the "selection-adjustment-iteration" process of planets revolving around the sun, dynamically adapts to the state of the server cluster, accurately selects and adjusts the optimal target server in high-concurrency task requests, balances the load of each node, efficiently utilizes resources, and ensures service stability.

[0087] Further, to improve the convergence speed and solution accuracy of the KOA algorithm, the TOPSIS method is introduced to participate in the iteration process after the selection of the elite strategy. TOPSIS is a sorting algorithm for approaching ideal solutions and is widely used in multi-objective decision analysis.

[0088] The basic principle is: normalize the data and construct a standardized matrix, determine the worst target object (anti-ideal solution) and the optimal target object (positive ideal solution) from the multi-objective set; calculate the Euclidean distance of each data in the evaluation target set from the worst and optimal target objects, obtain the closeness of each evaluation target object to the optimal target object (i.e. ideal closeness), and sort the evaluation target objects according to the ideal closeness value (between 0-1, the closer to 1 represents the better target object, the closer to 0 represents the worse target object).

[0089] In the server load evaluation scenario, first set the maximum performance value of each evaluation index of each server as the optimal solution and the worst performance value as the worst solution, calculate the Euclidean distance of each evaluation index from these two solutions; then calculate the closeness of each evaluation target object to the optimal target object as the corresponding evaluation index. After that, use the analytic hierarchy process to determine the weight of each index in the whole: construct a judgment matrix through the 1-9 scale method, solve the eigenvalue and eigenvector to obtain the weight of each evaluation index, and finally complete the comprehensive calculation of the load performance index, realize the effective evaluation of the server load. Among them, the 1-9 scale, such as Figure 3 The scale method is shown in the schematic diagram.

[0090] In some changes are implemented, such as in the power data microservice architecture, when the microservice is deployed on one or more servers, multiple microservice instances corresponding to the microservice are started on each server, and each server corresponding to the microservice constitutes a server cluster. In order to facilitate the implementation of determining on which server a certain microservice is deployed from the server cluster as described above in 102, the embodiments of the present application provide the following steps, which include:

[0091] C1, in the process of deploying the microservice on one or more servers, determining the mapping relationship between different microservices and different servers; C2, using microservice identifiers and server identifiers to represent the mapping relationship; C3, registering the represented mapping relationship to the microservice registry center; C4, determining the server to which the first microservice is deployed from the server cluster, including: determining the server to which the target microservice is deployed by searching the mapping relationship registered in advance in the microservice registry center.

[0092] In addition, for the execution steps of 101-104b as described above, the embodiments of the present application also provide a processing flow diagram of a task processing model as shown in the thread processing level, which is a specific implementation process of processing task requests using the master-slave Reactor multithreading model, which includes the following: Figure 4

[0093] D1, using a single thread of the main Reactor to listen to incoming task requests;

[0094] D2, according to whether the current load utilization rate of the multiple servers corresponding to the first microservice exceeds a preset threshold, the main Reactor selects a preset polling algorithm or a preset dynamic load balancing algorithm to determine the first target server or the second target server, and the first target server or the second target server is respectively assigned a slave Reactor;

[0095] D3, the task request is passed from the main Reactor to the slave Reactor, and the slave Reactor is a full-time IO processor. Each Reactor holds a task queue corresponding to it, which is used to temporarily store tasks for processing using resources in the thread pool.

[0096] As shown in Figure 4 , the model is based on the master-slave Reactor design pattern, cooperates with the load balancing mechanism and the thread pool, and builds a layered and asynchronous high-concurrency task processing system. The core components and functions are as follows:

[0097] (1) Main Reactor (Main Reactor):

[0098] Positioning: As the "entry gateway" of the system, it undertakes the connection management and initial scheduling responsibilities.

[0099] ​Core work: Listen to external requests (such as client network connection, task submission), quickly complete the connection establishment and other basic operations. Linkage load balancing algorithm, according to the preset strategy (such as weight, performance perception, polling, etc.), distribute the accessed tasks / connections to the Sub Reactor, realize the preliminary scheduling of requests. Performance advantage: Because the connection establishment, scheduling decision and other operations are "lightweight and short time-consuming", single thread can efficiently handle massive concurrent connection requests, avoid multi-thread switching overhead, and guarantee high throughput of the entry layer.

[0100] (2) Load Balancer:

[0101] Position: Connect the "scheduling center" of the main Reactor and the Sub Reactor, which is the key link to realize the reasonable allocation of cluster resources; Core work: Based on the server cluster state (such as the load of each Sub Reactor, server performance, task queue length, etc.), dynamically decide the task distribution direction. Cooperate with the main Reactor to complete the request shunting, ensure that the tasks are evenly and reasonably distributed to the Sub Reactor and the backend server, avoid single point overload, and improve the overall throughput and stability of the system.

[0102] (3) Sub Reactor:

[0103] Position: Each server's exclusive "IO and task coordinator", focusing on the read-write events and task preprocessing of specific connections. Core work: Receive the tasks / connections distributed by the main Reactor, listen to and handle read-write operations (such as receiving request data, returning response results).

[0104] Maintain the task queue, orderly store the parsed business tasks, and then batch / accordingly forward them to the thread pool, realize the "asynchronous decoupling" of IO processing and business logic.

[0105] Design value: Through the separation of "main-Sub" Reactor, let the main Reactor focus on high-concurrency connection access, and the Sub Reactor focus on IO events within a single server, improve the system's concurrent processing capability and resource utilization.

[0106] (4) Thread Pool:

[0107] Position: "Execution engine" of business logic, responsible for the processing of "CPU-intensive or time-consuming business tasks". Core work: Get tasks from the Sub Reactor task queue, assign threads to execute specific business logic (such as data calculation, database interaction, complex business process), complete the task and return the result, support the Sub Reactor to build responses and return to the client.

[0108] Advantages: Through the mechanism of "thread reuse, task queuing, and dynamic control of thread number" of the thread pool, the CPU resource overhead and task processing efficiency are balanced, the performance loss caused by frequent creation and destruction of threads is avoided, and the task fluctuation in high concurrency scenarios is adapted.

[0109] According to the processing flow diagram of the task processing model as shown in the drawings, the embodiment of the application provides a high-concurrency task processing flow (complete link), which includes the following: Figure 4

[0110] (1) Request access and initial scheduling:

[0111] The client initiates a large number of concurrent requests, the main Reactor listens to and captures the connection / task, triggers a load balancing algorithm, and decides which server corresponding to the slave Reactor the task should be distributed to according to the cluster state (such as server load, performance).

[0112] (2) Slave Reactor task coordination:

[0113] The slave Reactor receives the task distributed by the main Reactor, processes IO read / write (such as reading request messages and parsing parameters), and pushes the to-be-processed business task into the task queue of the slave Reactor, realizing asynchronous decoupling of "IO events" and "business logic".

[0114] (3) Thread pool business execution:

[0115] The thread pool pulls tasks from the task queue, allocates idle threads to execute specific businesses (such as data verification, database query, and business rule calculation), and returns the results to the slave Reactor after completion.

[0116] (4) Response construction and return:

[0117] The slave Reactor returns the results based on the thread pool, constructs response data (such as HTTP response and RPC reply), and returns the client through IO operation, completing a request processing.

[0118] Therefore, the advantages brought by the task processing model provided by the embodiment of the application include but are not limited to the following:

[0119] High concurrency support: The main Reactor processes a large number of connection accesses in a single thread, the slave Reactor focuses on IO events, the thread pool carries business logic, and the hierarchical asynchronous architecture adapts to high-concurrency traffic impact.

[0120] Reasonable allocation of resources: The load balancing algorithm dynamically schedules tasks, combines the division of labor of the main and slave Reactors and the reuse of the thread pool, optimizes the utilization of cluster resources, and avoids single-point bottlenecks.

[0121] ​Decoupling and scalability: IO processing (master-slave Reactor) and business logic (thread pool) are decoupled, which is convenient for independent expansion (such as expanding the number of slave Reactors, adjusting thread pool parameters), adapting to business changes and cluster size growth.

[0122] The above, the model constructs a set of efficient and scalable high-concurrency task processing system through the hierarchical design of "separating IO processing of master-slave Reactor, load balancing control flow, and thread pool carrying business", which can not only cope with massive connection requests, but also guarantee efficient execution of business logic and reasonable allocation of cluster resources.

[0123] Further, as an implementation of the method described above Figure 1 As an implementation of the method described above Figure 5 As an implementation of the method described above

[0124] The receiving unit 21 is configured to receive a high-concurrency task request sent by a client, the task request corresponding to a first microservice, the first microservice being selected from a plurality of second microservices, the second microservice being a plurality of independent services obtained by splitting power system business functions in a power data microservice architecture; when the second microservice is deployed on one or more servers, a plurality of microservice instances corresponding to the second microservice are started on each server; and each server corresponding to the second microservice constitutes a server cluster.

[0125] The first determining unit 22 is configured to determine a server to which the first microservice is deployed from the server cluster.

[0126] The computing unit 23 is configured to, when the server to which the first microservice is deployed is a plurality of servers, calculate current load utilization rates of the plurality of servers corresponding to the first microservice according to a first preset time period.

[0127] The first execution unit 24 is configured to, if the current load utilization rate does not exceed a preset threshold, select a first target server from the plurality of servers corresponding to the first microservice by using a preset polling algorithm, and process the task request by using a microservice instance on the first target server.

[0128] The second execution unit 25 is configured to, if the current load utilization rate exceeds the preset threshold, select, in the first preset time period, a second target server with the smallest load from the plurality of servers corresponding to the first microservice by using a preset dynamic load balancing algorithm and a second preset time period, and process the task request by using the microservice instance on the second target server.

[0129] Further, as shown in Figure 6 the first execution unit 24 is specifically configured to:

[0130] For the plurality of servers corresponding to the first microservice, calculate the load utilization rate corresponding to each server;

[0131] According to the standard of measuring the load utilization rate from high to low, sort the plurality of servers corresponding to the first microservice;

[0132] According to the sorting, add a serial number to the plurality of servers corresponding to the first microservice;

[0133] According to the serial number, select the first target server by polling the plurality of servers corresponding to the first microservice.

[0134] Further, as shown in Figure 6 the second execution unit 25 is specifically configured to:

[0135] For the plurality of servers corresponding to the first microservice, abstract each server into a planet, and the position of the planet is used to represent the current load state of the server;

[0136] By using the Kepler optimization algorithm, the optimization is performed by simulating the movement of the planet in space to select the second target server with the smallest load from the plurality of servers corresponding to the first microservice.

[0137] Further, as shown in Figure 6 before the device receives the high-concurrency task request sent by the client, the device further comprises:

[0138] The second determination unit 26 is configured to determine the mapping relationship between different second microservices and different servers in the process of deploying the second microservice to one or more servers;

[0139] The third determination unit 27 is configured to represent the mapping relationship by using a microservice identifier and a server identifier;

[0140] The registration unit 28 is configured to register the represented mapping relationship to the microservice registry center;

[0141] The first determining unit 22 is also specifically configured to determine the server to which the first microservice corresponds by searching the mapping relationship pre-registered in the microservice registration center.

[0142] Further, as shown in the figure, the task request is processed by using the master-slave Reactor multithreading model, and the device further comprises a processing unit 29 specifically configured to: Figure 6

[0143] The master Reactor listens to the incoming task request by using a single thread.

[0144] According to whether the current load utilization rate of the plurality of servers corresponding to the first microservice exceeds the preset threshold, the master Reactor selects the preset polling algorithm or the preset dynamic load balancing algorithm to determine the first target server or the second target server, and the first target server or the second target server is respectively assigned a slave Reactor.

[0145] The task request is transmitted from the master Reactor to the slave Reactor, and the slave Reactor is a full-time IO processor. Each Reactor holds a task queue corresponding to it, which is used to temporarily store tasks for processing by using resources in the thread pool.

[0146] In summary, the load balancing scheduling device in the power data microservice architecture comprises a processor and a memory. The above-mentioned receiving unit, first determining unit, calculating unit, first executing unit and second executing unit are all stored in the memory as program units, and the corresponding functions are realized by the processor executing the above-mentioned program units stored in the memory.

[0147] The processor contains a core, and the core retrieves the corresponding program unit from the memory. The core can be set to one or more, and by adjusting the core parameters, two different algorithms and two time periods are used to provide a load balancing solution, which realizes dynamic updating of the best target server on which the microservice instance is called to process the task request to adapt to the current load, improves the concurrency of the system, and enables the entire microservice to run in high concurrency.

[0148] The embodiment of the application provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is executed by a processor, the load balancing scheduling method in the power data microservice architecture is realized.

[0149] ​The embodiment of the present application provides an electronic device, the device comprises at least one processor, and at least one memory connected with the processor, a bus; wherein the processor, the memory complete mutual communication through the bus; the processor is used for sharing program instructions in the memory, to execute the scheduling method of load balancing in the power data micro-service architecture as described above.

[0150] The present application also provides a computer program product, when executed on a data processing device, is suitable for executing the program of initializing the scheduling method step of load balancing in the power data micro-service architecture.

[0151] The present application is described with reference to flowcharts and / or block diagrams of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of the flow and / or block in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to the processor of general-purpose computer, special-purpose computer, embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a machine for realizing the functions specified in the flowchart and / or block diagram. Figure 1 The function specified in one flow or multiple flows and / or blocks Figure 1 The function specified in one flow or multiple flows and / or blocks

[0152] In a typical configuration, the device comprises one or more processors (CPU), memory and bus. The device can also include input / output interface, network interface, etc.

[0153] The memory can include non-permanent memory in computer readable medium, random access memory (RAM) and / or non-volatile memory such as read only memory (ROM) or flash memory (flash RAM), the memory includes at least one memory chip. The memory is an example of computer readable medium.

[0154] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carriers.

[0155] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover a non-exclusive inclusion, such that a process, method, article or apparatus that comprises a list of elements does not only include those elements, but can also include other elements not expressly listed or inherent to such process, method, article or apparatus. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or apparatus that includes the element.

[0156] Those skilled in the art will appreciate that embodiments of the present application can be provided as a method, system or computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, etc.) containing computer usable program code.

[0157] The above merely provides embodiments of the present application and is not intended to limit the present application. Various modifications and changes can be made to the present application by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the scope of the claims of the present application.

Claims

1. A method for load balancing scheduling in an electric power data microservice architecture, characterized in that, The method comprises: receiving a high-concurrency task request sent by a client, the task request corresponding to a first microservice, the first microservice being a target microservice selected from a plurality of second microservices, the second microservices being a plurality of independent services into which power system business functions are divided in a power data microservice architecture; when the second microservices are deployed on one or more servers, starting a plurality of microservice instances corresponding to the second microservices on each of the servers; the server corresponding to each of the second microservices constituting a server cluster; determining a server to which the first microservice is deployed from the server cluster; when the server to which the first microservice is deployed is a plurality of servers, calculating a current load utilization rate of the plurality of servers to which the first microservice is deployed according to a first preset time period; if the current load utilization rate does not exceed a preset threshold, selecting a first target server from the plurality of servers to which the first microservice is deployed by using a preset polling algorithm, and processing the task request by using a microservice instance on the first target server; if the current load utilization rate exceeds the preset threshold, selecting a second target server with the smallest load from the plurality of servers to which the first microservice is deployed by using a preset dynamic load balancing algorithm in a second preset time period in the first preset time period, and processing the task request by using a microservice instance on the second target server.

2. The method of claim 1, wherein, The method comprises: for the plurality of servers to which the first microservice is deployed, calculating a load utilization rate corresponding to each server; sorting the plurality of servers to which the first microservice is deployed according to a criterion of measuring load utilization rate from high to low; adding a serial number to the plurality of servers to which the first microservice is deployed according to the sorting; selecting the first target server by polling the plurality of servers to which the first microservice is deployed according to the serial number.

3. The method of claim 1, wherein, The method comprises: for the plurality of servers to which the first microservice is deployed, abstracting each server into a planet, the position of the planet being used to represent the current load state of the server; selecting the second target server with the smallest load from the plurality of servers to which the first microservice is deployed by using a Kepler optimization algorithm to simulate the movement of the planet in space to achieve optimization.

4. The method according to any one of claims 1 to 3, characterized in that, Before the method receives the high-concurrency task request sent by the client, the method further comprises: determining a mapping relationship between different second microservices and different servers in the process of deploying the second microservices on one or more servers; representing the mapping relationship by using microservice identifiers and server identifiers; registering the represented mapping relationship to a microservice registry center; The determining, from the server cluster, of the server to which the first microservice is deployed comprises: determining the server to which the first microservice is deployed by searching the mapping relationship pre-registered in the microservice registry.

5. The method according to any one of claims 1 to 3, characterized in that, The task request is processed by using the master-slave Reactor multithreading model, and the method further comprises: The master Reactor listens to the incoming task request by using a single thread; According to whether the current load utilization of the multiple servers corresponding to the first microservice exceeds the preset threshold, the master Reactor selects the preset polling algorithm or the preset dynamic load balancing algorithm to determine the first target server or the second target server, and the first target server or the second target server is respectively assigned a slave Reactor; The task request is transferred from the master Reactor to the slave Reactor, and the slave Reactor is responsible for IO processing, and each Reactor holds a task queue for temporarily storing tasks to process by using resources in a thread pool. 6.A scheduling device for load balancing in a power data microservice architecture, characterized in that, The device comprises: A receiving unit is configured to receive a high-concurrency task request sent by a client, the task request corresponding to a first microservice, the first microservice being a target microservice selected from a plurality of second microservices, the second microservice being a plurality of independent services obtained by splitting a power system business function in a power data microservice architecture; when the second microservice is deployed on one or more servers, a plurality of microservice instances corresponding to the second microservice are started on each server; and each server corresponding to the second microservice constitutes a server cluster. A first determining unit is configured to determine, from the server cluster, a server to which the first microservice is deployed. A calculating unit is configured to, when the server to which the first microservice is deployed is multiple, calculate a current load utilization of the multiple servers corresponding to the first microservice according to a first preset time period. A first executing unit is configured to, if the current load utilization does not exceed a preset threshold, select a first target server from the multiple servers corresponding to the first microservice by using a preset polling algorithm, and process the task request by using a microservice instance on the first target server. A second executing unit is configured to, if the current load utilization exceeds the preset threshold, select a second target server with the smallest load from the multiple servers corresponding to the first microservice by using a preset dynamic load balancing algorithm in a second preset time period in the first preset time period, and process the task request by using a microservice instance on the second target server.

7. The apparatus of claim 6, wherein, The first executing unit is specifically configured to: calculate the load utilization of each server corresponding to the multiple servers corresponding to the first microservice; sort the multiple servers corresponding to the first microservice according to a standard of measuring load utilization from high to low; add a serial number to the multiple servers corresponding to the first microservice according to the sorting. According to the sequence, a plurality of servers corresponding to the first microservice are polled to select the first target server.

8. The apparatus of claim 6, wherein, The second execution unit is specifically configured to: For the plurality of servers corresponding to the first microservice, each server is abstracted into a planet, and a planet position is used to represent a current load state of the server. A Kepler optimization algorithm is used to perform optimization by simulating the movement of the planet in space to select a second target server with the smallest load from the plurality of servers corresponding to the first microservice.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the load balancing scheduling method in the power data microservice architecture according to any one of claims 1-5.

10. An electronic device, comprising: The device includes at least one processor, and at least one memory connected with the processor through a bus; The processor, the memory and the bus complete mutual communication through the bus; The processor is configured to call program instructions in the memory to execute the load balancing scheduling method in the power data microservice architecture according to any one of claims 1-5.