A Microservice Deployment Method for Heterogeneity Based on Greedy Algorithm

Through the microservice deployment method based on greedy algorithm, the heterogeneity and passive defense problems of microservice systems under resource limitations are solved, and efficient and rapid multi-version microservice deployment is achieved, enhancing the system's ability to resist attacks.

CN119892840BActive Publication Date: 2025-07-22HARBIN INST OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510049469.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-13
Publication Date
2025-07-22
Estimated Expiration
2045-01-13

AI Technical Summary

Technical Problem

The lack of effective passive defense strategies in microservice systems in the prior art makes the system vulnerable to attack when active defense fails, and the deployment problems during microservice updates are complex, especially under resource limitations, heterogeneity is difficult to guarantee.

Method used

Using a heterogeneous microservice deployment method based on greedy algorithms, microservices are deployed in steps by computing node resources and microservice resources to ensure system heterogeneity. Combining traditional greedy algorithms to optimize the deployment solution, the deployment solution is generated in real time.

Benefits of technology

It realizes efficient deployment of multiple different versions of microservices under resource limitations, improves system heterogeneity, enhances passive defense capabilities, reduces attack losses, and significantly improves computing speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119892840B_ABST
    Figure CN119892840B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for deploying heterogeneous micro-services based on a greedy algorithm, and the method is as follows: S1. Calculate the remaining resources of each node and number them in descending order according to the remaining amount; S2. According to the order of node ranking, attempt to deploy one micro-service in each micro-service function on the nodes in sequence. If the deployment of a certain micro-service on a certain node fails, then the micro-service function to which the micro-service belongs will no longer be deployed on that node; S3. Return to S1 until the remaining deployment amount of each micro-service function is μ, or each micro-service function is marked as no longer deployable on all nodes; S4. Use the traditional greedy algorithm to deploy the remaining micro-service instances; S5. End the deployment and determine whether the result meets the constraints. The present invention can deploy multiple micro-service instances with different functions on multiple nodes according to requirements, and obtain a high degree of micro-service heterogeneity under strong resource constraints.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer services, and relates to a microservice deployment method, specifically to a microservice deployment method for heterogeneity based on a greedy algorithm. Background Art

[0002] Microservice technology has become the mainstream architecture mode in the field of software development and deployment. Compared with the traditional monolithic architecture, the microservice architecture disassembles a complete application into multiple independent service modules, enabling each module to be developed, deployed, and extended independently. This loosely coupled architecture greatly improves the flexibility, maintainability, and scalability of the system. Each microservice is only developed and built around a specific business and interacts through lightweight communication mechanisms (such as HTTP / REST, gRPC, message queues, etc.).

[0003] In the current situation where microservice technology is widely used, the security of microservices has become a very important issue. The security of the microservice architecture mainly involves external access security, inter-service communication security, etc. The defense mechanisms against attacks can be divided into two types, namely active defense and passive defense. Active defense is a preventive security strategy, and its core idea is to take measures to prevent potential threats before an attack occurs; passive defense focuses on identification, response, and recovery after being attacked. Currently, the research on active defense has been relatively in-depth, such as using authentication and authorization systems (OAuth, JWT, etc.), and it has been widely applied in practice. However, the current research and application of passive defense are still insufficient.

[0004] In addition, due to the characteristics of the microservice architecture, each module can be developed and deployed independently, and the number of deployments is flexible, which also brings deployment problems when microservices are updated, that is, how to replace and how many of the original old-version microservices should be replaced when deploying a new version of microservices.

[0005] Based on the above research background, it can be found that a passive defense strategy is needed to protect the microservice system, ensuring that the system still has a certain ability to resist or delay attacks when the active defense fails. At the same time, the passive defense strategy can utilize the characteristic that multiple different versions of microservices can be deployed simultaneously in microservices. One of the goals of passive defense is to reduce the losses after being attacked. If each microservice is highly homogeneous, that is, using the same image, software version, etc., the vulnerabilities it has are the same, which will enable attackers to easily destroy the entire microservice system through lateral attacks. Summary of the Invention

[0006] To solve the problems existing in the background technology, the present invention provides a heterogeneous-oriented microservice deployment method based on a greedy algorithm. The present invention is applicable to the situation where there are different versions of microservices providing the same function. By modeling the node resources and the resources occupied by microservices, a real-time deployment plan is generated in combination with the deployment method proposed by the present invention.

[0007] The object of the present invention is achieved by the following technical solutions:

[0008] A heterogeneous-oriented microservice deployment method based on a greedy algorithm includes the following steps:

[0009] Step S1: Calculate the remaining resources of each node, and number them in descending order of the remaining amount, denoted as vector α. Its subscript corresponds to the node number, and the value stored in it corresponds to the ranking.

[0010] Step S2: According to the order of the node ranking α, try to deploy one microservice from each microservice function on the nodes in turn. If the deployment of a certain microservice on a certain node fails, then the microservice function to which the microservice belongs will no longer be deployed on that node later.

[0011] Step S3: After completing Step S2, return to Step S1 until the remaining deployment amount of each microservice function is μ, or each microservice function is marked as no longer deployable on all nodes.

[0012] Step S4: Use the traditional greedy algorithm to deploy the remaining microservice instances, that is, deploy the remaining microservices one by one in the direction of the maximum comprehensive heterogeneity.

[0013] Step S5: End the deployment and determine whether the result meets the constraints.

[0014] Compared with the prior art, the present invention has the following advantages:

[0015] 1. The present invention provides a method for quantitatively evaluating the heterogeneity of microservice systems, and uses the species evenness in biology to define the heterogeneity of microservice systems.

[0016] 2. The present invention proposes a deployment plan algorithm, which can deploy multiple microservice instances with different functions on multiple nodes according to requirements, and obtain a higher microservice heterogeneity under strong resource constraints.

[0017] 3. The deployment method of the present invention can adapt to different requirements by adjusting the remaining deployment amount μ. When the node structures are similar (that is, the resource amounts between nodes differ little), it is suitable to use a smaller μ to obtain a faster speed while ensuring heterogeneity; when the node structures differ greatly (for example, in the cloud-edge environment), it is suitable to use a larger μ to obtain a better solution.

[0018] 4. The deployment method of the present invention can complete calculations in real time. After testing, the calculation speed of this deployment method is significantly faster than that of a pure greedy algorithm, and the quality of its solution has a small gap with the solutions obtained by the greedy algorithm and the Cp solver. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a flowchart of a calculation method for the comprehensive heterogeneity of a microservice system;

[0020] Figure 2 It is a flowchart of a microservice deployment method for heterogeneity based on a greedy algorithm. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0021] The technical solution of the present invention will be further described below in conjunction with the drawings, but it is not limited thereto. Any modification or equivalent replacement of the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention shall be covered by the protection scope of the present invention.

[0022] The present invention provides a calculation method for the comprehensive heterogeneity of a microservice system, as Figure 1 shown, the method includes the following steps:

[0023] Step 1. Microservice function set S i is the set of all microservices s i,j that provide microservice function i, expressed as:

[0024]

[0025] where |S i | represents the number of types of microservices for microservice function i, and N func represents the number of microservice function sets.

[0026] Step 2. Microservice s i,j belongs to the microservice function set S i , and it has multiple attributes, including software attributes: software version v i,j , container image i i,j , programming language l i,j , resource attributes: processor occupancy p i,j , memory occupancy m i,j , disk space occupancy d i,j , expressed as:

[0027] s i,j = <v i,j , i i,j , l i,j , p i,j , m i,j , d i,j >

[0028] Step 3. The user initiates a request for the microservice function set S i and the system allocates it to an instance of microservice s i,j .

[0029] Step 4. A node can deploy multiple different or identical microservices s i,j , which also has resource attributes: the amount of processor resources p Nk , the amount of memory resources m Nk , and the amount of disk space resources d Nk , expressed as:

[0030] N k = <p Nk , m Nk , d Nk >

[0031] Step 5. Calculate the microservice heterogeneity by referring to the calculation method of species evenness. Species evenness is defined based on the Shannon-Wiener Diversity Index, where:

[0032] The Shannon-Wiener index H' borrows the method of information theory and can describe the heterogeneity of a community. Its form is as follows:

[0033]

[0034] where S' represents the total number of species, and p i represents the proportion of the i-th species in the total. When there is only one species in the community, H' reaches its minimum value of 0. When there is more than one species in the community and the number of individuals of the species is equal, H' reaches its maximum value of lnS'.

[0035] And species evenness is essentially the normalized Shannon-Wiener index J:

[0036]

[0037] Based on the definition of species evenness, where |S i | represents the number of microservice types of microservice function i, θ i,j represents the proportion of microservice j in the total number of examples, |s i,j | represents the number of instances of microservice j that provides microservice function i, and Sum i represents the total number of instances of microservice function i. Expand the definition of species evenness to a measure of microservice heterogeneity for a certain function:

[0038]

[0039] Among them, η i represents the heterogeneity of microservice function i.

[0040] On this basis, by taking the weighted average of the heterogeneity of different functional microservices, the system heterogeneity index H for the entire microservice system can be obtained ms :

[0041]

[0042] Among them, N func represents the number of microservice function sets, and γ i represents the proportion of the number of instances of microservice function i in all function sets.

[0043] Similarly, when the scope is limited from the entire microservice system to a certain node, the node heterogeneity index H can also be defined node :

[0044]

[0045] Among them, the superscript Ni represents being limited to node i. For example represents the heterogeneity of microservice function j in node i.

[0046] By synthesizing the above-mentioned system heterogeneity index and node heterogeneity index, the comprehensive heterogeneity index H of the microservice system can be obtained:

[0047] H = H ms + H node , H ∈ [0, 2]

[0048] When there is only one microservice function set in the microservice system, H reaches its minimum value. When there are more than one microservice function sets in the community and the number of instances contained in each microservice function set is equal, H reaches its maximum value of 2.

[0049] The present invention provides a heterogeneous-oriented microservice deployment method based on the greedy algorithm. The ideological basis of the method is to deploy microservices one by one using the greedy algorithm, and each deployment makes the overall heterogeneity after deployment the highest. However, according to the aforementioned heterogeneity calculation method, in the case of a large number of deployment instances and nodes, the timeliness of the pure greedy algorithm is lacking, mainly reflected in the excessive time consumption when performing a large number of heterogeneity calculations. In addition, it can also be noted that in the early stage of deployment, the remaining resource volume of the nodes is much larger than the resource volume required by each microservice. Therefore, this method divides the deployment into two parts. When there are still μ instances of each microservice function remaining undeployed (the remaining deployment volume is μ), the greedy algorithm is used for deployment. In the first part, since the remaining resource volume can be regarded as sufficient, the microservices are evenly deployed (that is, the number of instances of each microservice in the microservice function is equal). As Figure 2 shown, the specific steps are as follows:

[0050] Step S1: Calculate the remaining resource volume of each node, and number them in descending order of the remaining volume, denoted as vector α. Its subscript corresponds to the node number, and the value stored in it corresponds to the ranking. For example, there are three nodes A, B, and C, and their remaining resource volumes are a, b, and c respectively, and b > a > c, and the numbers are 0, 1, and 2; then α = [1, 0, 2], which means that node B has the most resources and ranks first, and node C has the least resources and ranks last.

[0051] Step S2: According to the order of the node ranking α, try to deploy one microservice in each microservice function on the nodes in turn. If taking the example in Step S1, deploy in the order of B, A, and C. Each time, try to deploy evenly to maintain its heterogeneity. If the deployment of a certain microservice on a certain node fails (such as insufficient resources), mark the microservice function to which the microservice belongs, and then no longer deploy on this node. The purpose of stopping the deployment is to keep the heterogeneity of this microservice function on the current node from deteriorating. If continuous deployment may lead to too many instances of a microservice with small resource occupancy and reduce heterogeneity.

[0052] Step S3: Return to Step S1 until the remaining deployment volume of each microservice function is μ, or all nodes are marked as no longer deployable.

[0053] Step S4: Use the traditional greedy algorithm to deploy the remaining microservice instances, that is, deploy the remaining microservices one by one in the direction of the maximum overall heterogeneity.

[0054] Step S5: End the deployment and determine whether the result meets the constraints.

Claims

1. A calculation method for the comprehensive heterogeneity of a microservice system, characterized in that The method includes the following steps: Step 1, Microservice Function Set To provide microservice functions all microservices The set is represented as: Among them, represents the number of types of microservices of microservices with respect to microservice function, and represents the number of microservice function sets; Step 2, Microservices Belong to the microservice function set , which has multiple attributes, including software attributes: software version , container image , programming language , resource attributes: processor occupancy , memory occupancy , disk space occupancy , expressed as: Step 3: The user initiates a request for the microservice function set , and the system allocates it to an instance of the microservice ; Step Four: Node Deploy multiple different or identical microservices which have resource attributes: processor resource quantity , memory resource quantity , disk space resource quantity , expressed as: Step Five: Calculate the microservice heterogeneity according to the calculation method of the reference species evenness, where the species evenness is defined based on the Shannon-Wiener index, and: Shannon-Wiener index Describes the heterogeneity of a community and has the following form: Among them, represents the total number of species, represents the proportion of the -th species in the total number; Species evenness is essentially the Shannon-Wiener index after normalization : Based on the definition of species evenness, there is representing the number of types of microservices with a certain microservice function, representing the proportion of microservices among the total number of examples, representing the number of instances of microservices providing a certain microservice function, and representing the total number of instances of microservices with a certain microservice function. The definition of species evenness is extended to a measure of the microservice heterogeneity of a certain function: Among them, represents the heterogeneity of microservice functions ; Perform a weighted average on the heterogeneity of different functional microservices to obtain a system heterogeneity index for the entire microservice system : Among them, represents the number of microservice function sets, represents the proportion of the number of instances of microservice functions in all function sets; Similarly, when the scope is limited from the entire microservice system to a certain node, define the node heterogeneity index : Among them, The superscript represents being confined to the node among represents the microservice function in the node heterogeneity; Combining the above system heterogeneity index and node heterogeneity index, the comprehensive heterogeneity index of the microservice system is obtained : 。 2. The calculation method for the comprehensive heterogeneity of the microservice system according to claim 1, wherein When there is only one microservice function set in the microservice system, it reaches its minimum value of 0. When there are more than one microservice function sets in the community and the number of instances contained in each microservice function set is equal, it reaches its maximum value .

3. A microservice deployment method for heterogeneity based on the greedy algorithm, characterized in that The method includes the following steps: Step S1: Calculate the remaining resources of each node, and number them in descending order of the remaining amount, denoted as vector , whose subscript corresponds to the node number, and the value stored in it corresponds to the ranking; Step S2. According to the node ranking in sequence, attempt to deploy one microservice from each microservice function on the nodes one by one. If the deployment of a certain microservice on a certain node fails, then the microservice function to which the microservice belongs will no longer be deployed on that node later; Step S3: After step S2 is completed, return to step S1 until the remaining deployment volume of each microservice function is , or each microservice function is marked as no longer deployable on all nodes; Step S4: Deploy the remaining microservice instances using the traditional greedy algorithm, that is, deploy the remaining microservices one by one in the direction with the maximum comprehensive heterogeneity calculated by the calculation method described in claim 1; Step S5: End the deployment and determine whether the result meets the constraints.

Citation Information

Patent Citations

  • Task and resource awareness-oriented micro-service deployment method

    CN111736983A

  • Data processing method, device and equipment and computer readable storage medium

    CN113762514A