A micro-service deployment and scheduling method and system based on an improved genetic algorithm

By improving the dual substring encoding and adaptive operation of the genetic algorithm, the deployment and scheduling of microservices are optimized, solving the problem of inaccurate user request response time under limited resources, and achieving more efficient microservice scheduling and deployment.

CN115033364BActive Publication Date: 2026-01-02STATE GRID INFORMATION & TELECOMM GRP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210663217.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-13
Publication Date
2026-01-02
Estimated Expiration
2042-06-13

AI Technical Summary

Technical Problem

Existing microservice deployment and scheduling strategies fail to effectively consider the limited resources of the resource center, resulting in inaccurate user request response times, unreasonable evaluation of individual advantages, and excessively long individual code lengths affecting the efficiency of genetic algorithms.

Method used

An improved genetic algorithm is adopted, which uses a double substring encoding method to represent the resource center microservice deployment and user request scheduling respectively. Combined with adaptive crossover and mutation operations, the individual fitness calculation is optimized, the encoding length is reduced, and the search efficiency is improved.

Benefits of technology

Accurately calculating user request response time under limited resources solves the waiting time problem caused by microservice blocking, and improves the efficiency and accuracy of microservice deployment and scheduling.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115033364B_ABST
    Figure CN115033364B_ABST
Patent Text Reader

Abstract

The application provides a micro-service deployment and scheduling method and system based on an improved genetic algorithm, relates to the technical field of micro-service architecture, and encodes chromosomes based on deployment substrings and scheduling substrings; initializes a population; calculates fitness, and performs selection operation based on the combination of optimal preservation and roulette; performs two-point crossover operation based on self-adaption; performs basic bit mutation operation based on self-adaption; judges whether a termination condition is reached; if the termination condition is reached, performs catastrophe operation, so that the population iteratively evolves to a preset number of times, the individual with the highest fitness is saved, and the deployment substrings and scheduling substrings in the remaining individuals are subjected to mutation operation with a very high probability. The application establishes the deployment substrings and the scheduling substrings, the length of the deployment substrings depends on the number of resource centers and the number of micro-service types, and is much smaller than the number of tasks brought by user requests, so that the coding length of each individual is reduced, and the search efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of micro-service architecture, and particularly relates to a micro-service deployment and scheduling method and system based on an improved genetic algorithm. BACKGROUND

[0002] With the rapid development of information technology and the large-scale popularity of Internet applications, the drawbacks of traditional monolithic applications in meeting the needs of a large number of concurrent user requests have gradually emerged, and micro-service technology has emerged as the times require. Research on applications based on micro-service has become a hot topic. Micro-service architecture is a decentralized service management mechanism, and system components are provided in the form of services. The development between services is free, and the services can be independently deployed and easily maintained, which can better meet the development needs of enterprises. However, the flexible expansion and independent deployment characteristics of micro-services also bring some problems that need to be solved, and the most critical problem is the combined deployment and scheduling optimization of services, that is, when multiple resource centers can start multiple micro-service instances, the micro-service deployment and scheduling strategy is configured for multiple resource centers under the premise of comprehensively considering the user request response time, resource center load balancing rate, and resource center resource utilization rate. However, the current micro-service deployment and scheduling strategy still has the following problems.

[0003] 1) The prior art does not consider the case where the resources of the resource center are limited in the process of solving the individual fitness, and believes that all tasks can be executed by the micro-service deployed in any resource center. In the calculation of the execution time of each task, on the one hand, the waiting time of the current task due to insufficient resources is ignored, and on the other hand, the waiting time of the current task due to the insufficient resources of the previous task entering the blocking state and the current task being unable to execute is ignored. Ultimately, the user request response time obtained is inaccurate, and the evaluation of the individual advantage degree is unreasonable.

[0004] 2) The prior art establishes a task allocation substring and a task scheduling substring based on the micro-service tasks in all user requests when performing individual coding, that is, the coding length of each individual is twice the total number of user request micro-service tasks, which will affect the solving efficiency of the genetic algorithm. SUMMARY

[0005] The present application provides a micro-service deployment and scheduling method based on an improved genetic algorithm, which can reduce the coding length of each individual and improve the search efficiency.

[0006] The method comprises the following steps:

[0007] Step 1, performing chromosome coding based on deployment substrings and scheduling substrings;

[0008] Step 2, initializing the population;

[0009] Step three, judge whether the catastrophe number is reached;

[0010] Step four, if the catastrophe number is not reached, calculate the fitness;

[0011] Step five, selection operation based on the combination of optimal preservation and roulette;

[0012] Step six, two-point crossover operation based on self-adaptation;

[0013] Step seven, basic bit mutation operation based on self-adaptation;

[0014] Step eight, judge whether the termination condition is reached; if the termination condition is reached, perform the catastrophe operation, save the individual with the highest fitness at the preset number of iterations, and perform mutation operation with a large probability on the deployment substring and the scheduling substring in the remaining individuals.

[0015] Further, in step one, the chromosome is encoded based on the individual encoding mode of double substrings, each individual consists of a deployment substring and a scheduling substring;

[0016] The deployment substring represents the number of instances of each microservice distributed and deployed in each resource center, each deployment substring is grouped by resource center, each group has a length of the number of microservice types, and the gene number in each group is the microservice type number, and the gene value is the number of instances of the corresponding microservice deployment, and the deployment substring should meet the constraints;

[0017] Each microservice is deployed at least one instance, and the total number of microservice instances deployed in each resource center cannot exceed its total capacity;

[0018] The scheduling substring represents the correspondence between each microservice task in the user request and the specific execution resource center.

[0019] Further, the population size in step two is set to 100, and 100 individuals are randomly generated based on the encoding mode of step one under the condition of meeting the constraints.

[0020] Further, the fitness of the individual is calculated by the total response time of the user request, the resource load balancing rate, and the resource effective utilization rate in step four;

[0021] After the fitness of the individual is calculated, normalization processing is performed, and then the individual fitness can be obtained according to the preset weight of each index, and the calculation formula is as follows:

[0022] f = θ1W T + θ2W B + θ3W E , 0 ≤ θ i ≤ 1, ∑ θ i = 1

[0023] W T denotes the normalized user request response time, W B denotes the normalized load balancing rate, W E denotes the normalized effective utilization rate.

[0024] It should be further explained that the way to calculate the total user request response time includes:

[0025] (1) For each individual, according to the deployment substring to obtain the deployment of the resource center microservice instance, according to the scheduling substring to obtain the user request execution list {Q1:R1.S1->R2.S2,Q2:R2.S1->:R1.S2->R1.S3,Q3:R1.S2->R2.S3};

[0026] (2) Add all the completed tasks in the user request execution list to the waiting execution microservice task list;

[0027] (3) If there is a task in the waiting execution microservice task list that can be executed by resources, the task is included in the executable microservice task list, and the execution time is obtained according to the microservice ETC matrix; if the task in the waiting execution list cannot be executed by resources, the waiting time is calculated until there is a resource that can execute it;

[0028] (4) Repeat steps (2) and (3) until all tasks in the user request execution list are executed;

[0029] (5) Calculate the total user request response time of all user requests by summing up the execution time and waiting time of the microservice tasks in each user request.

[0030] It should be further explained that the formula for calculating the resource load balancing rate is as follows:

[0031]

[0032] Where N represents the number of resource centers, B i represents the load rate of i resource center, represents the average load rate of all resource centers;

[0033] The formula for calculating the resource effective utilization rate is as follows:

[0034]

[0035] Where N represents the number of resource centers, T represents the total user request response time, |R i | represents the number of deployed microservice instances of i resource center, f T (Ri ) represents the running time of each micro-service instance of all i resource centers actually performing the task.

[0036] It should be further explained that in step five, after calculating the fitness of each individual in the population, the selection operation is used to randomly select individuals for subsequent crossover and mutation operations to generate a new population.

[0037] It should be further explained that in step six, the crossover operation exchanges the coding fragments of the corresponding positions of the two parent individuals obtained by the selection operation to generate two new individuals.

[0038] The adaptive two-point crossover method is used to perform crossover operation on the deployment substring and the scheduling substring in the selected parent individuals, and the adaptive crossover probability formula is as follows:

[0039]

[0040] Where f1 and f2 represent the fitness of the two parent individuals, f max is the maximum fitness in the population, and f avg is the average fitness in the population, and u1 and u2 are user-defined parameters.

[0041] It should be further explained that in step seven, the adaptive basic bit mutation method is used to perform mutation operation on the deployment substring and the scheduling substring in the selected parent individuals, and the adaptive mutation probability formula is as follows:

[0042]

[0043] Where f is the input individual fitness, f max is the maximum fitness in the population, and f avg is the average fitness in the population, and u3 and u4 are user-defined parameters.

[0044] The application also provides a micro-service deployment and scheduling system based on an improved genetic algorithm, which comprises a coding module, an initialization module, a judgment module, an fitness calculation module, a selection operation module, a crossover operation module, a basic bit mutation operation module and a catastrophe operation module.

[0045] The coding module is used for chromosome coding based on the deployment substring and the scheduling substring.

[0046] The initialization module is used for initializing the population.

[0047] The judgment module is used to determine whether the catastrophe number is reached, and if not, the fitness calculation module calculates the fitness of the individual by using the total response time, resource load balancing rate and resource effective utilization rate.

[0048] If the catastrophe number is reached, the output result is outputted, and the running is ended;

[0049] The selection operation module performs selection operation based on combination of optimal preservation and roulette method;

[0050] The crossover operation module generates two new individuals by exchanging the encoding fragments of the corresponding positions of the two parent individuals obtained through the selection operation based on self-adaption; the two-point crossover method is adopted to perform crossover operation on the deployment substring and the scheduling substring in the selected parent individuals respectively;

[0051] The basic bit mutation operation module performs mutation operation on the deployment substring and the scheduling substring in the selected parent individuals respectively based on self-adaption by adopting the self-adaptive basic bit mutation method;

[0052] The catastrophe operation module is used for judging whether the termination condition is reached; if the termination condition is reached, catastrophe operation is performed, so that the population iteratively evolves to the preset number of times, the individual with the highest fitness is preserved, and the deployment substring and the scheduling substring in the remaining individuals are subjected to mutation operation with a large probability respectively.

[0053] As can be seen from the above technical solution, the present application has the following advantages:

[0054] The present application improves the individual encoding method, so that each individual has a resource center micro-service deployment substring and a user request scheduling substring; that is, the deployment distribution of each resource center micro-service instance is set through the deployment substring, the scheduling relationship between the micro-service tasks in each user request and the resource center is set through the scheduling substring, and finally the user request response time under the condition of limited resources is calculated based on the deployment distribution state and the scheduling relationship.

[0055] Moreover, the user request response time of the micro-service calling chain is considered under the condition of limited resources; the user request response time considering the micro-service blocking state time is calculated when the resource center resources are limited, so as to perform micro-service deployment and scheduling.

[0056] The present application also improves the individual encoding method, establishes the deployment substring and the scheduling substring, and reduces the coding length of each individual and improves the search efficiency, because the length of the deployment substring depends on the number of resource centers and the number of micro-service types, which is much smaller than the number of tasks brought by the user request. The calculation of the execution time of each task is realized, the waiting time of the current task due to insufficient resources is considered, and the waiting time problem of the current task due to insufficient resources of the previous task entering the blocking state is solved. Furthermore, the method provided by the present application can solve the problem of inaccurate calculation of the user request response time and unreasonable evaluation of the individual advantage degree. BRIEF DESCRIPTION OF DRAWINGS

[0057] In order to more clearly illustrate the technical solutions of the present application, the drawings required to be used in the description will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor on the basis of these drawings.

[0058] Figure 1 Flow chart of microservice deployment and scheduling method based on improved genetic algorithm;

[0059] Figure 2 Schematic diagram of microservice deployment and scheduling system based on improved genetic algorithm. DETAILED DESCRIPTION

[0060] The technical solutions in the embodiments of the present application will be described clearly and completely in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0061] The microservice deployment and scheduling method and system based on improved genetic algorithm provided by the present application are mainly divided into five categories for microservice deployment and scheduling: the strategy of microservice deployment and scheduling by predicting user request sequence. The strategy of microservice deployment and scheduling by combining elasticity and load balancing. The strategy of microservice deployment and scheduling by monitoring application resource consumption. The strategy of microservice deployment and scheduling by enumerating, graph theory and other methods to solve the optimal solution. The strategy of microservice deployment and scheduling by approximate algorithm and heuristic algorithm to solve the approximate optimal solution.

[0062] Among the above-mentioned five types of microservice deployment and scheduling methods, there are problems of ignoring the waiting time of the current task due to insufficient resources and ignoring the waiting time of the current task due to insufficient resources of the previous task entering the blocking state, which cannot be executed. Ultimately, the user request response time obtained is inaccurate, and the individual advantage degree evaluation is unreasonable. In view of the above-mentioned problems, the present application proposes a microservice deployment and scheduling method based on improved genetic algorithm.

[0063] The improved genetic algorithm proposed by the present application, such as genetic algorithm model and deep learning model, can provide improved strategies for microservice deployment and scheduling.

[0064] Figure 1 The flow chart of the microservice deployment and scheduling method based on the improved genetic algorithm according to an embodiment of the present application is schematically shown.

[0065] The method steps of the embodiments of the present disclosure can be executed by a terminal device, a server, or the terminal device and the server in interaction, but the present disclosure is not limited thereto.

[0066] The method comprises:

[0067] Step one, chromosome coding based on deployment substring and scheduling substring;

[0068] Specifically, the individual coding method based on double substrings comprises two parts, i.e., a deployment substring and a scheduling substring.

[0069] The deployment substring represents the number of instances of each microservice distributed and deployed in each resource center, each deployment substring is grouped according to resource centers, each group has a length of the number of microservice types, the gene sequence number in each group is the microservice type sequence number, and the gene value is the number of instances of the corresponding microservice deployed.

[0070] For example, assuming that there are two resource centers {R1, R2} that can provide three microservices {S1, S2, S3}, and each resource center can deploy a maximum of 10 microservice instances, the deployment substring [213, 123] represents that the resource center R1 deploys 2 instances of the microservice S1, 1 instance of the microservice S2, and 3 instances of the microservice S3, and the resource center R2 deploys 1 instance of the microservice S1, 2 instances of the microservice S2, and 3 instances of the microservice S3, wherein the number of instances of each resource center is less than 10 and each microservice is deployed at least one instance, which satisfies the constraint.

[0071] The scheduling substring represents the corresponding relationship between each microservice task in the user request and the specific execution resource center. For example, in the case of the above deployment substring, assuming that there are three user requests [Q1, Q2, Q3], the microservice call chain of Q1 is [S1, S2], the microservice call chain of Q2 is [S1, S2, S3], and the microservice call chain of Q3 is [S2, S3], and the scheduling substring [12, 211, 12] represents the execution order Q1: R1.S1->R2.S2, Q2: R2.S1->:R1.S2->R1.S3, and Q3: R1.S2->R2.S3.

[0072] Step two, initializing the population;

[0073] Wherein, the population is the scope of the genetic algorithm, the population initialization content includes setting the population size, initializing the coded value in each individual. The population size has an influence on the search efficiency and accuracy of the genetic algorithm, if the population is too small, it will affect the population gene diversity and lead to the algorithm converging to a local optimal solution, if the population is too large, it will increase the iteration calculation time and affect the algorithm efficiency.

[0074] In the application, the population size is set to 100, and 100 groups of individuals are randomly generated based on the preset coding mode under the condition of meeting the constraints.

[0075] Step three, judge whether the catastrophe number is reached or not;

[0076] Step four, if the catastrophe number is not reached, calculate the fitness, otherwise, output the result and end the running.

[0077] Specifically, in the genetic algorithm, the fitness of the population individual to the environmental constraints is used to evaluate the individual's degree of excellence. In the application, the user request total response time, resource load balancing rate and resource effective utilization rate are requested by the user to calculate the fitness of the individual.

[0078] The method for calculating the total user request response time is: for the case that the resource center resource is limited and the user request exists the micro-service call chain relationship, the application proposes a user request response time calculation method considering the micro-service call chain under the limited resource.

[0079] The method for calculating the total user request response time comprises:

[0080] (1) for each individual, according to the deployment substring to obtain the deployment of the resource center micro-service instance, according to the scheduling substring to obtain the user request execution list {Q1:R1.S1->R2.S2,Q2:R1.S1->:R1.S2->R1.S3,Q3:R1.S2->R2.S3};

[0081] (2) all the completed tasks in the user request execution list are added to the waiting execution micro-service task list;

[0082] (3) if there is a task in the waiting execution micro-service task list that can be executed by the resource, the task is included in the executable micro-service task list, and the execution time is obtained according to the micro-service ETC matrix; if the task in the waiting execution list cannot be executed by the resource, the waiting time is calculated until the resource can be executed;

[0083] (4) repeat steps (2) and (3) until all the tasks in the user request execution list are executed;

[0084] (5) The sum of the execution time and the waiting time of the micro-service task in each user request is counted, and the total response time of the user request is calculated.

[0085] The resource load balancing rate related to the present application is used to measure the load degree of each resource center when processing user requests, avoid the polarization situation, and avoid the long-term high-load operation of part of the resource center and the waste of resources due to the frequent idling of part of the resource center. The calculation formula is as follows:

[0086]

[0087] Wherein, N represents the number of resource centers, B i represents the load rate of the i resource center, represents the average load rate of all resource centers.

[0088] The resource effective utilization rate related to the present application is used to measure the actual running task proportion of the micro-service started by each resource center, and it is expected that the micro-service instance started by the resource center can be allocated to the task as much as possible, so as to avoid the waste of resources due to the start of a large number of micro-service instances and the actual user request only on a few instances. The calculation formula of the resource effective utilization rate is as follows:

[0089]

[0090] Wherein, N represents the number of resource centers, T represents the total response time of the user request, |R i | represents the number of micro-service instances deployed in the i resource center, f T (R i ) represents the running time of the actual execution task of each micro-service instance of all i resource centers.

[0091] After the above index calculation is completed, normalization processing is performed, and then the individual fitness can be obtained according to the preset weight of each index. The individual fitness calculation formula is as follows:

[0092] f=θ1W T +θ2W B +θ3W E , 0≤θ i ≤1, ∑θ i =1

[0093] W T represents the normalized user request response time, W B represents the normalized load balancing rate, and W E represents the normalized effective utilization rate.

[0094] Step five, selection operation based on the combination of optimal preservation and roulette method;

[0095] After the fitness of each individual in the population is calculated, the individuals are randomly selected by the selection operation for the subsequent crossover and mutation operations to generate a new population. The selection operation of the present application uses a combination of the optimal preservation strategy and the roulette selection method. The above method is a common selection operation of genetic algorithms and will not be described here.

[0096] Step six, adaptive two-point crossover operation;

[0097] Genetic algorithms obtain new individuals through crossover operations to ensure the species diversity of the population. The crossover operation exchanges the coding fragments of the corresponding positions of two parent individuals obtained by the selection operation to generate two new individuals. The adaptive two-point crossover method is used in the present application to perform crossover operations on the deployment substring and the scheduling substring in the selected parent individuals. The two-point crossover method is a common crossover operation and will not be described here. The adaptive crossover probability formula is as follows:

[0098]

[0099] wherein f1 and f2 represent the fitness of two parent individuals, fmax represents the maximum fitness in the population, fave represents the average fitness in the population, and u1 and u2 are self-defined parameters. max avg

[0100] Step seven, adaptive basic bit mutation operation;

[0101] The mutation operation in genetic algorithms obtains the fund fragments that have not appeared in the population to ensure the species diversity and specificity of the population. The adaptive basic bit mutation method is used in the present application to perform mutation operations on the deployment substring and the scheduling substring in the selected parent individuals. The basic bit mutation method is a common mutation operation and will not be described here. The adaptive mutation probability formula is as follows:

[0102]

[0103] wherein f represents the input individual fitness, fmax represents the maximum fitness in the population, fave represents the average fitness in the population, and u3 and u4 are self-defined parameters. max avg

[0104] Step eight, judgment of whether the termination condition is reached. If the termination condition is reached, the cataclysmic operation is performed to make the population iteratively evolve to the preset number of times, save the individual with the highest fitness, and perform mutation operations with a large probability on the deployment substring and the scheduling substring in the remaining individuals.

[0105] ​​​​The present application adds a catastrophe operation in a genetic algorithm to reduce the probability of the algorithm falling into a local optimal solution. The catastrophe operation occurs when the population iteratively evolves to a certain number of times, saves the individual with the highest fitness, and then performs a large probability mutation operation on the deployment substring and the scheduling substring in the remaining individuals.

[0106] The present application can also perform a decoding operation, which reversely converts the deployment substring and the scheduling substring of the selected optimal individual into a resource center micro-service instance deployment scheme and a user request scheduling scheme according to the encoding rules. Details are not repeated here.

[0107] Based on the above method, each individual has a resource center micro-service deployment substring and a user request scheduling substring. That is, the deployment distribution of each resource center micro-service instance is set through the deployment substring, and the scheduling relationship between the micro-service task in each user request and the resource center is set through the scheduling substring. Finally, the user request response time under the condition of limited resources is calculated based on the deployment distribution state and the scheduling relationship. Moreover, the user request response time of the micro-service call chain is considered under the condition of limited resources. The user request response time considering the micro-service blocking state time is calculated when the resource center resource is limited, to perform micro-service deployment and scheduling.

[0108] Based on the above method, the present application also provides a micro-service deployment and scheduling system based on an improved genetic algorithm, as shown in Figure 1 The system includes an encoding module, an initialization module, a judgment module, an adaptability calculation module, a selection operation module, a crossover operation module, a basic bit mutation operation module, and a catastrophe operation module.

[0109] The encoding module is used for chromosome encoding based on the deployment substring and the scheduling substring.

[0110] The initialization module is used for initializing the population.

[0111] The judgment module is used for judging whether the catastrophe number is reached. If the catastrophe number is not reached, the adaptability calculation module calculates the adaptability of the individual through three indexes of the total user request response time, the resource load balancing rate, and the resource effective utilization rate.

[0112] If the catastrophe number is reached, the result is output, and the running is ended.

[0113] The selection operation module performs selection operation based on the combination of optimal saving and roulette.

[0114] The crossover operation module generates two new individuals by exchanging the encoding fragments of the corresponding positions of the two parent individuals obtained through the selection operation based on self-adaptation. The two-point crossover method is used to perform crossover operation on the deployment substring and the scheduling substring in the selected parent individuals.

[0115] The basic bit mutation operation module performs mutation operation on the selected deployment substring and scheduling substring in the parent individual based on adaptive basic bit mutation method.

[0116] The catastrophe operation module is used for judging whether the termination condition is reached; if the termination condition is reached, catastrophe operation is performed, the population is iteratively evolved to the preset number of times, the individual with the highest fitness is saved, and the deployment substring and scheduling substring in the remaining individuals are subjected to mutation operation with a large probability.

[0117] Illustratively, the microservice architecture of the microservice deployment and scheduling system based on the improved genetic algorithm provided by the application is divided according to business functions, each service has a specific function, and is easy to develop and maintain; each independent microservice can be in different languages; the sub-service can be independently deployed, and can realize sustainable integration and delivery; the fault tolerance is powerful, and the problem of a single microservice will not affect the operation of other services of the system; and dynamic on-demand real-time expansion can be realized.

[0118] Resource center: an entity capable of providing an environment for the instance start and operation of a microservice.

[0119] Microservice collection: a collection of all different microservices that can be run by the resource center.

[0120] Microservice call chain: the corresponding microservice call dependency relationship of each user request.

[0121] Microservice deployment strategy: the strategy of the type and instance number of the microservice deployed when the resource center is started.

[0122] Microservice task: a task sequence obtained by decomposing a user request according to the microservice call chain.

[0123] Microservice scheduling strategy: the strategy of assigning each microservice in the microservice task sequence to different resource centers for execution.

[0124] Microservice ETC matrix: the expected execution time of each microservice task in different resource centers.

[0125] Genetic algorithm: a heuristic algorithm for solving optimization problems, by defining coding, decoding, crossover, mutation operation, the optimal solution of the problem, the invention is used to solve micro service deployment strategy and task allocation strategy. Strategy is to consider the user request response time of micro service call chain under the condition of limited resources. When the resource center resource is limited, the user request response time considering the micro service blocking state time is calculated to carry out micro service deployment and scheduling. By improving the individual coding method, deployment substring and scheduling substring are established. Since the length of the deployment substring depends on the number of resource centers and the number of micro service types, it is much smaller than the number of tasks brought by user requests, so the length of each individual coding is reduced, and the search efficiency is improved. The calculation of the execution time of each task is realized, and the waiting time of the current task due to insufficient resources is considered. The waiting time problem caused by the current task due to insufficient resources of the previous task entering the blocking state and the current task unable to execute is solved. Further, the method provided by the present application causes the user request response time solved to be inaccurate, and the evaluation of the individual advantage degree is unreasonable.

[0126] The units and algorithm steps of each example described in the embodiments disclosed in the micro service deployment and scheduling method and system based on the improved genetic algorithm provided by the present application can be realized by electronic hardware, computer software or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description. Whether the functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.

[0127] The block diagram shown in the micro service deployment and scheduling method and system based on the improved genetic algorithm provided by the present application in the accompanying drawings is only a functional entity, and does not necessarily correspond to a physically independent entity. That is, these functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0128] In the micro-service deployment and scheduling method and system based on the improved genetic algorithm provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, another division mode can be used. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can also be electrical, mechanical or other forms of connection.

[0129] The above description of disclosed embodiments enables those skilled in the art to carry out or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A microservice deployment and scheduling method based on an improved genetic algorithm, characterized in that, The methods include: Step 1: Chromosome encoding based on deployment substrings and scheduling substrings; including: chromosome encoding based on a dual-substring individual encoding method, where each individual consists of two parts: a deployment substring and a scheduling substring; The deployment substring represents the number of instances of each type of microservice deployed in each resource center. Each deployment substring is grouped by resource center, and the length of each group is the number of microservice types. The gene number in each group is the microservice type number, and the gene value is the number of instances deployed for the corresponding microservice. The deployment substring should satisfy the constraints. Each type of microservice must have at least one instance deployed, and the total number of microservice instances deployed in each resource center cannot exceed its total capacity; The scheduling substring represents the correspondence between each microservice task in the user request and the specific resource center that executes it; Step 2: Initialize the population; Step 3: Determine if the required number of catastrophic events has been reached; Step 4: If the number of disasters has not been reached, calculate the fitness; calculate the fitness of an individual using three indicators: total user request response time, resource load balancing rate, and resource utilization rate. After calculating the fitness of each individual, normalization is performed, and then the individual fitness is obtained according to the preset weights of each indicator. The calculation formula is as follows: This represents the normalized total response time for user requests. This represents the normalized load balancing rate. This represents the normalized effective utilization rate; Methods for calculating the total response time for a user request include: (1) For each individual, the deployment status of the resource center microservice instance is obtained based on the deployment substring, and the user request execution list is obtained based on the scheduling substring {Q}. 1: R 1. S1-> R 2. S2, Q 2: R 2. S1-> : R 1. S2-> R 1. S3, Q 3: R 1. S2-> R 2. S3}; where Q1, Q2, and Q3 are user requests, R1 and R2 are resource centers, and S1, S2, and S3 are microservices; (2) Add all completed prerequisite tasks from the user request execution list to the list of microservice tasks waiting to be executed; (3) If there are tasks with resources to execute in the list of microservice tasks waiting to be executed, then the task is added to the list of executable microservice tasks, and the execution time is obtained according to the microservice ETC matrix; if there are no resources to execute the tasks in the list of tasks waiting to be executed, the waiting time is calculated until there are resources to execute. (4) Repeat steps (2) and (3) until all tasks in the user request execution list have been completed; (5) Calculate the sum of the execution time and waiting time of the microservice tasks in each user request, and calculate the total response time of all user requests; The formula for calculating the resource load balancing rate is as follows: in, Indicates the number of resource centers. express Resource center load rate This represents the average load factor across all resource centers. The formula for calculating resource utilization efficiency is as follows: in, Indicates the number of resource centers. This indicates the total response time for a user request. express The number of microservice instances deployed in the resource center. Indicates all The actual runtime of tasks executed by each microservice instance in the resource center; Step 5: Selection operation based on a combination of optimal saving and roulette wheel betting methods; Step 6: Adaptive two-point intersection operation; Step 7: Adaptive basic bit mutation operation; Step 8: Determine if the termination condition has been met; if the termination condition has been met, perform a catastrophe operation, so that when the population has iterated and evolved to the preset number of times, save the individual with the highest fitness, and perform a high-probability mutation operation on the deployment substring and scheduling substring of the remaining individuals respectively.

2. The microservice deployment and scheduling method based on the improved genetic algorithm according to claim 1, characterized in that, In step two, the population size is set to 100, and 100 groups of individuals are randomly generated based on the encoding method in step one while satisfying the constraints.

3. The microservice deployment and scheduling method based on the improved genetic algorithm according to claim 1, characterized in that, In step five, after calculating the fitness of each individual in the population, individuals are randomly selected through a selection operation to perform subsequent crossover and mutation operations, thereby generating a new population.

4. The microservice deployment and scheduling method based on the improved genetic algorithm according to claim 1, characterized in that, In step six, the crossover operation swaps the corresponding encoded segments of two parent individuals obtained through the selection operation to generate two new individuals; An adaptive two-point crossover method is used to perform crossover operations on the deployment substring and scheduling substring in the selected parent individuals, respectively. The adaptive crossover probability formula is as follows: in, This represents the individual fitness of two parent classes. The maximum fitness in the population, The average fitness of the population. For custom parameters.

5. The microservice deployment and scheduling method based on the improved genetic algorithm according to claim 1, characterized in that, In step seven, an adaptive basic bit mutation method is used to mutate the deployment substring and scheduling substring in the selected parent individual, respectively. The adaptive mutation probability formula is as follows: in, For the individual fitness of the input, The maximum fitness in the population, The average fitness of the population. For custom parameters.

6. A microservice deployment and scheduling system based on an improved genetic algorithm, characterized in that, The system adopts the microservice deployment and scheduling method based on the improved genetic algorithm as described in any one of claims 1 to 5; The system includes: an encoding module, an initialization module, a judgment module, a fitness calculation module, a selection operation module, a crossover operation module, a basic bit mutation operation module, and a catastrophe operation module; The encoding module is used for chromosome encoding based on deployment substrings and scheduling substrings; The initialization module is used to initialize the population; The judgment module is used to determine whether the number of disasters has been reached; if the number of disasters has not been reached, the fitness calculation module calculates the fitness of an individual based on three indicators: total user request response time, resource load balancing rate, and resource effective utilization rate. After calculating the fitness of each individual, normalization is performed, and then the individual fitness is obtained according to the preset weights of each indicator. The calculation formula is as follows: This represents the normalized total response time for user requests. This represents the normalized load balancing rate. This represents the normalized effective utilization rate; Methods for calculating the total response time for a user request include: (1) For each individual, the deployment status of the resource center microservice instance is obtained based on the deployment substring, and the user request execution list is obtained based on the scheduling substring {Q}. 1: R 1. S1-> R 2. S2, Q 2: R 2. S1-> : R 1. S2-> R 1. S3, Q 3: R 1. S2-> R 2. S3}; (2) Add all completed prerequisite tasks from the user request execution list to the list of microservice tasks waiting to be executed; (3) If there are tasks with resources to execute in the list of microservice tasks waiting to be executed, then the task is added to the list of executable microservice tasks, and the execution time is obtained according to the microservice ETC matrix; if there are no resources to execute the tasks in the list of tasks waiting to be executed, the waiting time is calculated until there are resources to execute. (4) Repeat steps (2) and (3) until all tasks in the user request execution list have been completed; (5) Calculate the sum of the execution time and waiting time of the microservice tasks in each user request, and calculate the total response time of all user requests; The formula for calculating the resource load balancing rate is as follows: in, Indicates the number of resource centers. express Resource center load rate This represents the average load factor across all resource centers. The formula for calculating resource utilization efficiency is as follows: in, Indicates the number of resource centers. This indicates the total response time for a user request. express The number of microservice instances deployed in the resource center. Indicates all The actual runtime of tasks executed by each microservice instance in the resource center; If the number of catastrophes is reached, output the result and the process ends. The selection operation module combines optimal saving and roulette wheel selection methods; The crossover module generates two new individuals by adaptively swapping the corresponding positions of the encoded segments of two parent individuals obtained through the selection operation; it uses an adaptive two-point crossover method to perform crossover operations on the deployment substring and scheduling substring in the selected parent individuals respectively. The basic bit mutation operation module adaptively uses an adaptive basic bit mutation method to perform mutation operations on the deployment substring and scheduling substring in the selected parent individual respectively; The catastrophe operation module is used to determine whether the termination condition has been met. If the termination condition is met, a catastrophe operation is performed, which saves the individual with the highest fitness when the population has iterated and evolved to a preset number of times, and performs high-probability mutation operations on the deployment substring and scheduling substring of the remaining individuals.

Citation Information

Patent Citations

  • Genetic and differential hybrid evolutionary cloud computing task scheduling algorithm based on early-stage catastrophe strategy

    CN110851257A