A micro-service load balancing method, device, computer equipment and storage medium
Patent Information
- Application Number
- CN202410773161.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2044-06-17
Smart Images

Figure CN118656209B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of resource scheduling, and particularly relates to a micro-service load balancing method and device, a computer device and a storage medium. BACKGROUND
[0002] To optimize system performance and resource utilization, load balancing is a key technology across many fields. With the popularity of micro-service architecture, the functional modules of an application are gradually split into independent micro-service units, providing a more flexible, maintainable and scalable software development and deployment mode. However, micro-services also bring new challenges, one of which is how to effectively manage and balance the load of micro-service instances.
[0003] In this context, a mode of distributing a single micro-service to multiple micro-service instances for distributed execution through batch scheduling has emerged, as shown in Figure 1 , which is a schematic diagram of the prior art micro-service distribution mode. In this mode, the unit of a single scheduling is a batch, and a batch contains multiple micro-service subtasks. Deploying multiple micro-service instances can provide fault tolerance, improve service availability, and at the same time, can improve the concurrency and overall processing capacity of tasks. When multiple micro-service instances are deployed in a ring-shaped manner, and there is also a ring-shaped communication relationship between the subtasks scheduled in a batch, the order of the subtasks in the batch should be maintained during the distribution process. This way of maintaining the order of subtasks is very important for reducing communication overhead and improving overall execution efficiency. With the widespread application of this batch scheduling mode, load balancing of multiple micro-service instances has become a problem to be solved. For this problem, the current random scheduling method selects the same number of micro-service instances as the number of batch subtasks at random, and then selects the starting point of the batch subtasks at random, and then distributes the batch subtasks to the selected micro-service instances accordingly, to achieve the scheduling function. However, the random scheduling method cannot achieve load balancing between micro-service instances, and has the following shortcomings:
[0004] 1. Some micro-service instances may be idle due to insufficient load, while other micro-service instances are overloaded, resulting in waste of server resources.
[0005] 2. Since the final completion time of a task is determined by the last completed subtask, and uneven load will cause some subtasks to be delayed, it will affect the execution efficiency of the task. SUMMARY
[0006] The present application provides a micro-service load balancing method, device, computer device and storage medium, which aims to at least solve one of the above technical problems in the prior art to some extent.
[0007] To solve the above problems, the application provides the following technical solutions:
[0008] A micro-service load balancing method, comprising:
[0009] Obtaining a micro-service task, dividing the micro-service task into sub-tasks according to the number of micro-service instances in the current system, and placing all the sub-tasks in a ring form into the same batch;
[0010] Obtaining the cumulative load of each micro-service instance in the current system and the load of each sub-task in the batch respectively, taking the cumulative load and the load of each sub-task in the batch as two ring sequences, and aligning the two ring sequences by using a sequence alignment algorithm based on dynamic programming, so that the maximum "load value" in all micro-service instances is minimized;
[0011] Based on the alignment result of the two ring sequences, each sub-task in the batch is assigned to a micro-service instance, so that the predecessor-successor relationship of the sub-task assigned to the micro-service instance remains unchanged.
[0012] The technical solutions adopted by the embodiments of the application further comprise, before obtaining the micro-service task:
[0013] Obtaining the number of micro-service instances in the current system; wherein the number of micro-service instances is m, and the m micro-service instances are deployed in a ring form.
[0014] The technical solutions adopted by the embodiments of the application further comprise: the sub-task division of the micro-service task according to the number of micro-service instances in the current system is specifically:
[0015] The number of sub-task division of the micro-service task is less than or equal to the number m of micro-service instances in the current system.
[0016] The technical solutions adopted by the embodiments of the application further comprise, after taking the cumulative load and the load of each sub-task in the batch as two ring sequences:
[0017] The elements in the two ring sequences S1 and S2 are sequentially placed on a ring, and the number of positions on the ring is the same as the number of micro-service instances in the current system.
[0018] The technical solutions adopted by the embodiments of the application further comprise: the alignment of the two ring sequences by using a sequence alignment algorithm based on dynamic programming is specifically:
[0019] Under the condition constraints that the predecessor-successor relationship of sequence elements is not changed and the length of the merged sequence is not greater than the number of microservice instances, a sequence alignment algorithm based on dynamic programming is used to align two ring sequences S1 and S2 at m positions, and corresponding elements in the aligned two ring sequences S1 and S2 are merged to obtain a new load sequence S3, so that the maximum "load value" in all microservice instances is minimized.
[0020] The technical scheme adopted by the embodiment of the application further includes that the sequence alignment algorithm based on dynamic programming is used to align the two ring sequences, specifically:
[0021] The dynamic programming array S is initialized as a four-dimensional array, S i,j (p, q) records the maximum sum of corresponding elements in the current two ring sequences, and simultaneously implies that the algorithm has proceeded to the i th element of S1 and the j th element of S2, and is represented as a i and b i respectively, and p gaps have been used for S1 and q gaps have been used for S2, then the dynamic transition equation is:
[0022]
[0023] The parameters i, j, p, and q in the above formula satisfy the following constraints:
[0024]
[0025] wherein |S1| and |S2| represent the number of elements of the two ring sequences S1 and S2 respectively, the inequalities represent the index range of the elements or the gaps that can be used of the two ring sequences respectively, and the equation represents that the elements or the gaps of S1 and S2 correspond to each other;
[0026] When starting to run the sequence alignment algorithm, the starting point of the dynamic programming process is calculated first:
[0027]
[0028] wherein the first equation represents that S1 and S2 are aligned using gaps, the second and third equations represent that one sequence in S1 and S2 is aligned using a gap and the other sequence is aligned using an element, and the fourth equation represents that S1 and S2 are aligned using elements, and the parameter χ is all possible values that satisfy the condition constraints.
[0029] The technical scheme adopted by the embodiment of the application further includes that based on the alignment result of the two ring sequences, each subtask in the batch is allocated to a microservice instance, specifically:
[0030] The subtasks in the batch are passed to the task adjustment area. In the initial stage of the system, if the number of microservice instances involved in the allocation scheme is less than the number of microservice instances in the current system, the subtasks in the batch are cached in the task adjustment area. Then, the scheduler allocates the circularly organized subtasks to the circularly deployed microservice instances. The preceding and following subtasks of each subtask in the batch remain unchanged after being allocated to the microservice instances.
[0031] Another technical solution adopted in this application embodiment is: a microservice load balancing device, comprising:
[0032] Microservice partitioning module: used to obtain microservice tasks, divide the microservice tasks into subtasks according to the number of microservice instances in the current system, and organize all subtasks in a circular manner into the same batch;
[0033] Sequence alignment module: used to obtain the cumulative load of each microservice instance in the current system and the load of each subtask in the batch, respectively, and to align the cumulative load and the load of each subtask in the batch as two circular sequences, and to use a sequence alignment algorithm based on dynamic programming to align the two circular sequences so that the maximum "load value" in all microservice instances is minimized.
[0034] Task allocation module: Based on the alignment result of the two circular sequences, it allocates each subtask in the batch to a microservice instance, so that the successor relationship of the subtasks allocated to the microservice instance remains unchanged.
[0035] Another technical solution adopted in this application embodiment is: a computer device, the computer device including a processor and a memory coupled to the processor, wherein,
[0036] The memory stores program instructions for implementing the microservice load balancing method;
[0037] The processor is used to execute the program instructions stored in the memory to control the microservice load balancing method.
[0038] Another technical solution adopted in this application embodiment is: a storage medium storing processor-executable program instructions, the program instructions being used to execute the microservice load balancing method.
[0039] Compared to existing technologies, the beneficial effects of the embodiments of this application are as follows: The microservice load balancing method, apparatus, computer equipment, and storage medium of the embodiments of this application propose a sequence alignment algorithm based on dynamic programming. This algorithm treats the cumulative load of each microservice instance in the current system and the load of the same batch of subtasks as two circular sequences. Elements from the two circular sequences are ordered into a single ring. Under the constraints of not changing the successive relationships of elements in the circular sequences and ensuring that the length of the merged sequence does not exceed the number of microservice instances, the alignment of the two circular sequences is achieved, minimizing the maximum "load value" among all microservice instances. Finally, based on the alignment result, the batch of subtasks organized in a circular pattern are scheduled to the circularly deployed microservice instances, achieving load balancing for microservices. The embodiments of this application can maintain a good load balancing effect during microservice scheduling. For the server side, it optimizes resource utilization and improves task throughput; for the client side, it improves task processing efficiency and saves time. Attached Figure Description
[0040] Figure 1 A schematic diagram of existing microservice allocation patterns;
[0041] Figure 2 This is a flowchart of a microservice load balancing method according to an embodiment of this application;
[0042] Figure 3 This is a schematic diagram of ring sequence alignment and merging according to an embodiment of this application;
[0043] Figure 4 This is a pseudocode diagram illustrating the sequence alignment algorithm of an embodiment of this application;
[0044] Figure 5 This is a schematic diagram of the microservice scheduling simulation experiment results of an embodiment of this application;
[0045] Figure 6 This is a schematic diagram of the microservice load balancing device structure according to an embodiment of this application;
[0046] Figure 7 This is a schematic diagram of the computer device structure according to an embodiment of this application;
[0047] Figure 8 This is a schematic diagram of the structure of the storage medium according to an embodiment of this application. Detailed Implementation
[0048] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0049] The terms "first," "second," and "third" in this application are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first," "second," or "third" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified. All directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of this application are only used to explain the relative positional relationships and movements between components in a specific orientation (as shown in the figures). If the specific orientation changes, the directional indications also change accordingly. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or computer device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or computer devices.
[0050] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0051] Specifically, please refer to Figure 2 This is a flowchart of a microservice load balancing method according to an embodiment of this application. The microservice load balancing method according to an embodiment of this application includes the following steps:
[0052] S100: Get the number of microservice instances in the current system;
[0053] In this step, the number of microservice instances is m, and the m microservice instances are deployed in a ring.
[0054] S110: Obtain microservice tasks, divide a single microservice task into subtasks based on the number of microservice instances, and organize all subtasks of a single microservice task in a circular manner into the same batch. Inside;
[0055] In this step, the number of subtasks for a single microservice task is less than or equal to the number of microservice instances m in the current system.
[0056] S120: Obtain the cumulative load of each microservice instance in the current system and the load of each subtask in the current batch respectively. Use the cumulative load and the load of each subtask in the current batch as two circular sequences S1 and S2, and put the elements in the two circular sequences S1 and S2 into a ring in an orderly manner.
[0057] In this step, the number of positions on the ring is the same as the number of microservice instances in the current system, that is, it includes m positions.
[0058] S130: The two circular sequences S1 and S2 are aligned using a sequence alignment algorithm based on dynamic programming. The corresponding elements in the aligned circular sequences S1 and S2 are then merged to generate a new load sequence S3. The new load sequence S3 minimizes the maximum load value among all microservice instances.
[0059] In this step, when scheduling all batches of subtasks, an iterative merging approach is adopted. At each step, the local optimum is greedily achieved, ensuring that the scheduling of subtasks in each batch is the current optimal solution. The cumulative load of each microservice instance in the current system and the load of each subtask in the current batch are considered as two circular sequences S1 and S2. The elements of these two sequences are ordered into a ring with m positions. Under the constraints of not changing the successive relationships of the elements and ensuring that the length of the merged sequence does not exceed the number of microservice instances, the two circular sequences are aligned at the m positions. Finally, the corresponding elements in the aligned two circular sequences are merged to obtain a new load sequence S3, minimizing the maximum "load value" among all microservice instances. Specifically... Figure 3 The diagram shown is a schematic diagram of the alignment and merging of circular sequences according to an embodiment of this application, wherein gaps may exist between any adjacent elements of the same circular sequence.
[0060] Specifically, for aligning two circular sequences, S1 is treated as a regular fixed sequence during execution, and the starting element of S2 is iterated, thus transforming it into aligning two non-circular sequences. It's important to note that the optimal alignment solution may not be unique. To better balance the load, it's necessary to find the solution with the smallest maximum "load difference" among multiple optimal alignment solutions for each microservice instance. This application proposes a sequence alignment algorithm based on dynamic programming. Specifically, the algorithm initializes the dynamic programming array S as a four-dimensional array, S... i,j (p,q) records the maximum sum of corresponding elements in the current two circular sequences, and also indicates that the algorithm has reached the i-th element of S1 (using a). i (represented by b) the j-th element of S2 (in b) i If S1 has used p gaps and S2 has used q gaps, then the dynamic transition equation is:
[0061]
[0062] The parameters i, j, p, q in the above formula are not independent and should satisfy the following constraints:
[0063]
[0064] Where |S1| and |S2| represent the number of elements in the two circular sequences S1 and S2, respectively; the inequalities represent the index range of the elements or available gaps in the two circular sequences, respectively; and the equations represent the correspondence between the elements or gaps of S1 and S2.
[0065] When starting the sequence alignment algorithm, the boundary conditions are first calculated, which is the starting point (base case) of the dynamic programming process:
[0066]
[0067] In this algorithm, the first equation indicates that both S1 and S2 are aligned using gaps; the second and third equations indicate that one sequence of S1 and S2 is aligned using gaps, while the other sequence is aligned element-wise; and the fourth equation indicates that both S1 and S2 are aligned element-wise. The parameter χ represents all possible values that satisfy the constraints. The pseudocode for the sequence alignment algorithm based on dynamic programming is as follows: Figure 4 As shown.
[0068] S140: Based on the sequence alignment results, the scheduler groups the same batch... The batch of subtasks organized in a ring are assigned to microservice instances deployed in a ring, so that the successive relationship of the batch of subtasks assigned to the microservice instances remains unchanged.
[0069] In this step, during the initial stage of the system, if the number of microservice instances involved in the allocation scheme is less than the number of microservice instances in the current system, the system does not perform actual scheduling operations. Instead, it caches the subtasks in the batch in the task adjustment area, and then the scheduler allocates the batch of subtasks, which are organized in a ring, to the microservice instances that are deployed in a ring. The preceding and following subtasks of the same batch remain unchanged after being allocated to the microservice instances, thereby achieving load balancing of microservices and giving full play to the advantages of the sequence alignment algorithm, which is conducive to improving the flexibility of subtask adjustment.
[0070] To verify the feasibility and effectiveness of the embodiments of this application, a simulation experiment was conducted for comparative verification. In the simulation experiment, it was assumed that there were 10 microservice instances, with the number and load of subtasks in each batch being integers. The number of subtasks in each batch was randomly generated from a discrete uniform distribution of 1 to 10, and the subtask load was randomly generated from a discrete uniform distribution of 1 to 10000. For ease of analysis, the average load value evenly distributed across all microservice instances was taken as an ideal value. By analyzing the ratio of the experimental results to this ideal value, the effectiveness of the embodiments of this application can be more intuitively understood. The microservice scheduling simulation experiment results are as follows: Figure 5 As shown in the figure, the vertical axis represents the ratio of the simulation results to the ideal values, the horizontal axis represents the number of scheduled batches, the upper line represents the running results of the random scheduling algorithm, and the lower line represents the running results of the algorithm proposed in this application embodiment. Experimental results show that the embodiment of this application can maintain a better load balancing effect during the scheduling process.
[0071] Based on the above, the microservice load balancing method of this application proposes a sequence alignment algorithm based on dynamic programming. It treats the cumulative load of each microservice instance and the load of the same batch of subtasks in the current system as two circular sequences. Elements from the two circular sequences are ordered into a single ring. Under the constraints of not changing the successive relationships of elements in the circular sequences and ensuring that the length of the merged sequence does not exceed the number of microservice instances, the two circular sequences are aligned, minimizing the maximum "load value" among all microservice instances. Finally, based on the alignment result, the batch of subtasks organized in a circular pattern are scheduled to the circularly deployed microservice instances, achieving microservice load balancing. This application embodiment can maintain good load balancing during microservice scheduling. For the server side, it optimizes resource utilization and improves task throughput; for the client side, it improves task processing efficiency and saves time.
[0072] Please see Figure 6 This is a schematic diagram of the microservice load balancing device structure according to an embodiment of this application. The microservice load balancing device 40 according to an embodiment of this application includes:
[0073] Microservice partitioning module 41: used to obtain microservice tasks, divide the microservice tasks into subtasks according to the number of microservice instances in the current system, and organize all subtasks in a circular manner into the same batch;
[0074] Sequence alignment module 42: is used to obtain the cumulative load of each microservice instance in the current system and the load of each subtask in the batch, respectively, and to take the cumulative load and the load of each subtask in the batch as two circular sequences, and to align the two circular sequences using a sequence alignment algorithm based on dynamic programming, so that the maximum "load value" in all microservice instances is minimized.
[0075] Task allocation module 43: Based on the alignment result of the two circular sequences, it allocates each subtask in the batch to a microservice instance, so that the successor relationship of the subtasks allocated to the microservice instance remains unchanged.
[0076] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0077] The apparatus provided in this application can be applied to the foregoing method embodiments. For details, please refer to the description of the above method embodiments, which will not be repeated here.
[0078] Please see Figure 7 This is a schematic diagram of a computer device structure according to an embodiment of this application. The computer device 50 includes:
[0079] Memory 51 storing executable program instructions;
[0080] Processor 52 connected to memory 51;
[0081] The processor 52 is used to call the executable program instructions stored in the memory 51 and perform the following steps: obtain microservice tasks, divide the microservice tasks into subtasks according to the number of microservice instances in the current system, and organize all subtasks in a ring and put them into the same batch; obtain the cumulative load of each microservice instance in the current system and the load of each subtask in the batch, take the cumulative load and the load of each subtask in the batch as two ring sequences, and use a sequence alignment algorithm based on dynamic programming to align the two ring sequences so that the maximum "load value" in all microservice instances is minimized; based on the alignment result of the two ring sequences, assign each subtask in the batch to the microservice instance so that the successive relationship of the subtasks assigned to the microservice instance remains unchanged.
[0082] The processor 52 can also be referred to as a CPU (Central Processing Unit). The processor 52 may be an integrated circuit chip with signal processing capabilities. The processor 52 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor.
[0083] Please see Figure 8This is a schematic diagram of the storage medium in an embodiment of this application. The storage medium in this embodiment stores program instructions 61 capable of implementing the following steps: obtaining microservice tasks; dividing the microservice tasks into subtasks based on the number of microservice instances in the current system; and organizing all subtasks in a circular manner within the same batch; obtaining the cumulative load of each microservice instance in the current system and the load of each subtask in the batch; using the cumulative load and the load of each subtask in the batch as two circular sequences; and aligning the two circular sequences using a sequence alignment algorithm based on dynamic programming to minimize the maximum "load value" among all microservice instances; and, based on the alignment result of the two circular sequences, allocating each subtask in the batch to a microservice instance, ensuring that the successive relationships of the subtasks allocated to the microservice instance remain unchanged. These program instructions 61 can be stored in the aforementioned storage medium in the form of a software product, including several instructions to cause a computer device (which may be a personal computer, server, or network computer device, etc.) or processor to execute all or part of the steps of the methods in various embodiments of this application. The aforementioned storage media include: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program instructions, or terminal computer devices such as computers, servers, mobile phones, and tablets. Servers can be independent servers or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0084] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, apparatuses, or units, and may be electrical, mechanical, or other forms.
[0085] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated units described above can be implemented in hardware or as software functional units. The above are merely embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made based on the description and drawings of this application, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A microservice load balancing method, characterized in that, include: Obtain microservice tasks, divide the microservice tasks into subtasks according to the number of microservice instances in the current system, and organize all subtasks in a circular manner into the same batch; The cumulative load of each microservice instance in the current system and the load of each subtask in the batch are obtained respectively. The cumulative load and the load of each subtask in the batch are used as two circular sequences. The two circular sequences are aligned using a sequence alignment algorithm based on dynamic programming so that the maximum load value in all microservice instances is minimized. Based on the alignment results of the two circular sequences, each subtask in the batch is assigned to a microservice instance, so that the successor relationship of the subtasks assigned to the microservice instance remains unchanged. Before obtaining the microservice task, the process also includes: Obtain the number of microservice instances in the current system; wherein the number of microservice instances is m, and the m microservice instances are deployed in a ring configuration; The step of aligning the two circular sequences using a sequence alignment algorithm based on dynamic programming is as follows: Under the constraints of not changing the successor relationship of sequence elements and the length of the merged sequence not being greater than the number of microservice instances, a sequence alignment algorithm based on dynamic programming is used to align two circular sequences S1 and S2 at m positions, and the corresponding elements in the aligned two circular sequences S1 and S2 are merged to obtain a new load sequence S3, so that the maximum load value among all microservice instances is minimized. The sequence alignment algorithm based on dynamic programming is as follows: Initialize the dynamic programming array as a four-dimensional array, S i,j (p,q) records the maximum sum of corresponding elements in the current two circular sequences S1 and S2, which also means that the algorithm has reached the i-th element of S1 and the j-th element of S2, and is represented as a. i and b j And S1 has used p gaps and S2 has used q gaps, then the dynamic transition equation is: The parameters i, j, p, q in the above formula satisfy the following constraints: Where |S1| and |S2| represent the number of elements in the two circular sequences S1 and S2, respectively; the inequalities represent the index range of the elements or available gaps in the two circular sequences S1 and S2, respectively; and the equations represent the correspondence between the elements or gaps in S1 and S2. When starting the sequence alignment algorithm, the starting point of the dynamic programming process is first calculated: In this context, the first equation (1) indicates that S1 and S2 are both aligned using gaps, the second equation (2) and the third equation (3) indicate that one sequence of S1 and S2 is aligned using gaps and the other sequence is aligned using elements, and the fourth equation (4) indicates that S1 and S2 are both aligned using elements. The parameter χ is all possible values that satisfy the condition constraints.
2. The microservice load balancing method according to claim 1, characterized in that, The process of dividing the microservice task into subtasks based on the number of microservice instances in the current system is as follows: The number of subtasks of the microservice task is less than or equal to the number of microservice instances m in the current system.
3. The microservice load balancing method according to any one of claims 1 to 2, characterized in that, After obtaining the cumulative load of each microservice instance in the current system and the load of each subtask in the batch, and treating the cumulative load and the load of each subtask in the batch as two circular sequences, the process further includes: The elements in two circular sequences S1 and S2 are placed in an ordered manner onto a ring, the number of positions on the ring being the same as the number of microservice instances in the current system.
4. The microservice load balancing method according to claim 1, characterized in that, Based on the alignment result of the two circular sequences, the subtasks in the batch are assigned to microservice instances, specifically as follows: The subtasks in the batch are passed to the task adjustment area. In the initial stage of the system, if the number of microservice instances involved in the allocation scheme is less than the number of microservice instances in the current system, the subtasks in the batch are cached in the task adjustment area. Then, the scheduler allocates the circularly organized subtasks to the circularly deployed microservice instances. The preceding and following subtasks of each subtask in the batch remain unchanged after being allocated to the microservice instances.
5. A microservice load balancing device utilizing the microservice load balancing method of claim 1, characterized in that, include: Microservice partitioning module: used to obtain microservice tasks, divide the microservice tasks into subtasks according to the number of microservice instances in the current system, and organize all subtasks in a circular manner into the same batch; Sequence alignment module: used to obtain the cumulative load of each microservice instance in the current system and the load of each subtask in the batch, respectively, and to align the cumulative load and the load of each subtask in the batch as two circular sequences, and to use a sequence alignment algorithm based on dynamic programming to align the two circular sequences so that the maximum "load value" in all microservice instances is minimized. Task allocation module: Based on the alignment result of the two circular sequences, it allocates each subtask in the batch to a microservice instance, so that the successor relationship of the subtasks allocated to the microservice instance remains unchanged.
6. A computer device, characterized in that, The computer device includes a processor and a memory coupled to the processor, wherein, The memory stores program instructions for implementing the microservice load balancing method according to any one of claims 1-4; The processor is used to execute the program instructions stored in the memory to control the microservice load balancing method.
7. A storage medium, characterized in that, The system stores processor-executable program instructions for performing the microservice load balancing method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Cluster task distribution method, device and equipment and storage medium
CN111338793A