Microservice migration methods, apparatus, devices, and computer-readable storage media
By calculating microservice priorities and optimizing migration strategies using reinforcement learning, the high latency and resource constraints of microservice migration in edge networks are solved, achieving efficient, reliable, and energy-saving service migration and improving the responsiveness and resource utilization efficiency of edge networks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- THREE GORGES HI TECH INFORMATION TECH CO LTD
- Filing Date
- 2025-11-27
- Publication Date
- 2026-06-30
AI Technical Summary
In edge networks, microservice migration faces challenges such as high latency, resource constraints, heterogeneity, and the complexity of dynamic dependencies, leading to a decline in service quality. Existing research has failed to effectively address the dynamic migration and resource optimization of service instances.
By calculating microservice priorities and constructing objective functions for constraints and optimization goals, and combining reinforcement learning to optimize migration strategies, the migration needs of high-priority microservices are prioritized, reducing latency and energy consumption of the edge network after migration, and distributed deployment is carried out using service nodes composed of edge servers and IoT devices.
It enables efficient, reliable, and energy-saving microservice migration under resource constraints, improves the responsiveness and resource utilization efficiency of edge networks, and meets the dual requirements of modern network environments for service performance and energy efficiency.
Smart Images

Figure CN121644675B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of mobile edge computing technology, specifically to a microservice migration method, apparatus, device, and computer-readable storage medium. Background Technology
[0002] Microservice architecture is an emerging service design paradigm that breaks down traditional monolithic applications into a set of independent, loosely coupled, and collaborative modules. It boasts high modularity, scalability, and system fault tolerance, and has been widely adopted by leading companies in cloud computing and internet service scenarios. Considering that most modern applications are extremely sensitive to service response latency, deeply integrating microservice architecture with edge computing networks—which are geographically closer to end users and offer low transmission latency—has become an effective way to improve service quality and response speed.
[0003] In edge networks, microservice-based applications need to handle a large number of concurrent requests from terminal devices across a wide geographical area. This characteristic not only leads to recursive calls and frequent data interactions between microservices, but also frequently triggers service instance migrations due to dynamic changes in service request patterns. To ensure service quality, especially when users move or service demands change, service instances need to be able to migrate to new, optimal edge nodes in real time. However, the limited resources and complex service dependencies in edge environments result in a high degree of coupling between service migration decisions and request routing paths. This coupling presents a core challenge in large-scale microservice orchestration, primarily in balancing low latency, minimal migration overhead, and service state consistency. Furthermore, the dynamic dependency structure in the service chain, as well as the instantaneous state synchronization and additional latency during migration, further exacerbate the complexity of service migration and instance-level orchestration in edge environments.
[0004] First, the delivery of high-quality network services is highly dependent on the deployment of microservice instances and the design of request routing strategies. A large number of user requests arrive at multi-level queues on edge nodes and are processed sequentially by deployed service instances. Due to the complexity of cross-node data communication and service call dependencies, the deployment location of service instances (including their migration locations) is closely related to the request routing path. On the one hand, the effectiveness of routing strategies depends on the precise location of service instances; on the other hand, instance deployment must also consider the request routing path of the service chain. Most existing research typically focuses only on optimizing service deployment or routing individually, neglecting the complex dependencies between microservices, often leading to suboptimal global solutions. Only a few studies have attempted to jointly optimize service deployment and routing, but their modeling is usually based on static environment assumptions, failing to fully consider the continuous changes caused by user mobility and dynamic service changes. Such static optimization inevitably leads to a degradation in service quality in dynamic edge environments.
[0005] Secondly, efficient and reliable microservice migration must consider the heterogeneity of edge servers and the resource limitations of each node. The migration of service instances between nodes is not a homogeneous process. When users or terminals move, to ensure service continuity and meet stringent latency requirements, the relevant service instances must be accurately migrated to the most suitable neighboring node. However, edge servers located in different geographical regions vary significantly in terms of computing power and available resources. These factors directly affect whether the target node has sufficient capacity to support the migrated service instances and whether the migrated service can achieve the expected performance. Furthermore, many edge nodes themselves have limited resources and struggle to support service instances with high computing demands. In some cases, insufficient resources may lead to unstable operation of the migrated service or even migration failure. Therefore, the feasibility, stability, and performance issues arising from server heterogeneity and resource constraints must be given special attention in the design of microservice migration strategies.
[0006] Third, efficient service migration requires accurate analysis of end-to-end service latency and network energy consumption under random request patterns. Due to the complexity of microservice call dependencies, dynamic reuse of service instances, multi-instance modeling, and the time-varying nature of user requests, the migrated system has specific service call paths and multiple possible request routing paths. Although existing research attempts to analyze request processing and communication processes using coarse-grained methods, it often ignores the fine-grained latency introduced by multi-level nested queuing and iterative interactions. These methods are not suitable for large-scale microservice migration and are difficult to meet the stringent Service Level Objectives (SLOs) requirements of critical microservices. In particular, when service states and dynamic orchestration caused by migration are considered, instance-level service deployment and routing strategies become highly volatile. This volatility significantly disrupts queuing latency and propagation latency, making end-to-end latency difficult to predict. Summary of the Invention
[0007] To address at least one of the aforementioned technical problems, this application provides a microservice migration method, apparatus, device, and computer-readable storage medium.
[0008] In a first aspect, embodiments of this application provide a microservice migration method, the microservice migration method comprising:
[0009] Calculate the priority of each microservice in the microservice set S, and sort them according to priority to determine the microservices that need to be migrated first;
[0010] For microservices that need to be migrated first, an objective function containing constraints and optimization goals is constructed, and the microservice migration strategy is obtained by solving the objective function. The constraints include computing resource constraints, request routing constraints, and service capability constraints. The optimization goals include minimizing the latency and energy consumption of the edge network after migration. The edge network consists of service nodes composed of edge servers and IoT computing devices. Multiple microservice instances are distributed and deployed in the service nodes. Different types of microservices are combined to form a service chain structure through chained call relationships. Each microservice has one or more instances in the edge network, and different request types correspond to different service chain paths.
[0011] Secondly, embodiments of this application provide a microservice migration apparatus, the microservice migration apparatus comprising:
[0012] The priority determination module is used to calculate the priority of each microservice in the microservice set S, and determine the microservices that need to be migrated first according to the priority order.
[0013] The migration strategy formulation module is used to construct an objective function containing constraints and optimization objectives for microservices that need to be migrated first, and solve the objective function to obtain the microservice migration strategy. The constraints include computing resource constraints, request routing constraints, and service capability constraints. The optimization objectives include minimizing the latency and energy consumption of the edge network after migration. The edge network consists of service nodes composed of edge servers and IoT computing devices. Multiple microservice instances are distributed and deployed in the service nodes. Different types of microservices are combined to form a service chain structure through chained call relationships. Each microservice has one or more instances in the edge network, and different request types correspond to different service chain paths.
[0014] Thirdly, embodiments of this application provide a microservice migration device, which includes a processor, a memory, and a microservice migration program stored in the memory and executable by the processor, wherein when the microservice migration program is executed by the processor, it implements the steps of the microservice migration method as described in the first aspect.
[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing a microservice migration program, wherein when the microservice migration program is executed by a processor, it implements the steps of the microservice migration method as described in the first aspect.
[0016] The beneficial effects of the technical solutions provided in this application include:
[0017] By prioritizing microservices, the migration needs of high-priority microservices are met first, thereby improving overall network service performance. After prioritization, with the goal of minimizing latency and energy consumption in the migrated edge network, a microservice migration strategy is determined under constraints such as resource constraints, request routing constraints, and service capacity constraints. This effectively reduces latency and energy consumption and improves the responsiveness and resource utilization efficiency of the edge network. Attached Figure Description
[0018] Figure 1 This is a schematic diagram illustrating the migration and routing of microservices on a service node in one embodiment of the microservice migration method of this application.
[0019] Figure 2 This is a flowchart illustrating an embodiment of the microservice migration method of this application;
[0020] Figure 3 This is a schematic diagram of the microservice migration strategy optimization algorithm based on reinforcement learning in one embodiment of the microservice migration method of this application;
[0021] Figure 4 This is a schematic diagram of the functional modules of an embodiment of the microservice migration device of this application;
[0022] Figure 5 This is a schematic diagram of the hardware structure of the microservice migration device involved in the embodiments of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0024] First, some of the technical terms used in this application will be explained to help those skilled in the art understand this application.
[0025] A mobile edge network architecture comprises multiple service nodes, including edge servers and IoT computing devices, encompassing both base stations and servers. The base stations are primarily responsible for data transmission with neighboring service nodes, while the servers host microservice instances to handle user requests. The service nodes are interconnected via communication links, forming a connected edge network topology to enable efficient transmission of user requests and service data. Propagation latency varies between different service nodes, while the transmission latency of user requests within the same service node is negligible. Each service node is configured with multiple CPU cores to represent its computing resources, and there is heterogeneity in computing resources among different service nodes.
[0026] In one embodiment, microservices are divided into fine-grained service units based on business needs, with each microservice specializing in handling a specific type of functional task. Multiple instances of each microservice can be deployed in the edge network, and a single microservice instance can occupy one or more CPU cores. Microservice instances deployed on different CPU cores are isolated from each other, and the load between different service nodes does not affect each other.
[0027] User requests are processed in the form of service chains. Each service chain consists of multiple microservices with data dependencies, and the service chain type, service path, and latency requirements vary for different user requests. User requests first enter a multi-level input queue in the edge network, and are then forwarded to service nodes with corresponding microservice instances for processing step by step according to the scheduling strategy. User requests need to call multiple microservice instances sequentially according to the service chain order until the entire service chain is completed.
[0028] As an application of this embodiment, a microservice migration method is proposed based on the edge network architecture constructed above. During the microservice migration process, this method can dynamically determine the migration target of microservice instances. Specifically, it determines the migration location of instances based on the system status and adjusts the number of instances deployed in real time. It also supports adding, deleting, and redeploying instances to adapt to dynamic changes in service node load and continuously meet service quality assurance requirements.
[0029] Based on the constructed edge network architecture, an energy consumption-latency joint optimization model can be established, constrained by computing resources, request routing, and service capabilities. For further explanation, please refer to [link to relevant documentation]. Figure 1This diagram illustrates the migration and routing of microservices on service nodes. The request routing strategy involves designing the specific routing paths for requests between servers. By jointly optimizing the deployment of microservice instances and request routing, the coupling between the two can be fully utilized. Instance deployment is used as a prerequisite for the request routing strategy, while the latency obtained after request routing is used as the criterion for evaluating the effectiveness of the deployment strategy. The algorithm optimizes both of these issues simultaneously, with the ultimate goal of achieving the optimal microservice migration solution. Therefore, the migration method proposed in this application not only focuses on service availability and processing efficiency but also considers system energy consumption, aiming to reduce energy consumption during network operation and improve overall energy efficiency. Through the above design, this application can provide users with efficient, reliable, and energy-saving mobile edge computing services, meeting the dual requirements of modern network environments for service performance and energy efficiency.
[0030] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0031] Firstly, embodiments of this application provide a microservice migration method.
[0032] In one embodiment, reference is made to Figure 2 , Figure 2 This is a flowchart illustrating an embodiment of the microservice migration method of this application. Figure 2 As shown, microservice migration methods include:
[0033] Step S10: Calculate the priority of each microservice in the microservice set S, and determine the microservices that need to be migrated first according to the priority.
[0034] In this embodiment, since the resources of the edge network are limited, it is impossible to perform a full migration of all microservices. Therefore, the microservices are prioritized based on the latency tolerance of user requests, the request arrival rate of microservices, and the call frequency of microservices in user requests. This prioritizes the migration needs of high-priority microservices to improve the overall network service performance.
[0035] Furthermore, in one embodiment, each microservice in the microservice set S priority The priority of a microservice is determined by the following formula:
[0036]
[0037] in, Indicates user request The types of microservices included in it, This indicates that it includes microservices. The minimum latency tolerance for user requests. Indicates user request Request delivery rate microservices In user request The frequency of calls in and These are the weighting factors for latency tolerance and arrival rate, respectively.
[0038] Step S20: For the microservices that need to be migrated first, construct an objective function containing constraints and optimization objectives, and solve the objective function to obtain the microservice migration strategy. The constraints include computing resource constraints, request routing constraints, and service capability constraints. The optimization objectives include minimizing the latency and energy consumption of the edge network after migration. The edge network consists of service nodes composed of edge servers and IoT computing devices. Multiple microservice instances are distributed and deployed in the service nodes. Different types of microservices are combined through chained call relationships to form a service chain structure. Each microservice has one or more instances in the edge network, and different request types correspond to different service chain paths.
[0039] Furthermore, in one embodiment, each service node has limited computing resources, especially the number of CPU cores, therefore a large number of microservice instances cannot be deployed centrally on a single service node. In addition, microservice migration can only occur based on existing instances on the current service node; therefore, the computing resource constraints are as follows:
[0040]
[0041]
[0042] in, microservices From node Migrate to node The number of CPU cores, microservices At the service node The number of CPU cores used. microservices At the service node The number of CPU cores used. Indicates service node Total number of CPU cores.
[0043] Furthermore, in one embodiment, user requests can only be routed to the deployment of microservices. The service nodes must be fully served, and each user request must be completely served. Therefore, the request routing constraints are expressed as follows:
[0044]
[0045]
[0046] in, Indicates at the service node Complete microservices The request is then routed to the service node. Microservices The probability, microservices From service node Migrate to service node The number of CPU cores, Indicates service node Total number of CPU cores microservices At the service node The number of CPU cores used. This represents the set of all service nodes.
[0047] Furthermore, in one embodiment, to maintain the stability of the edge network, it is required that the service node be deployed... For each microservice, the total arrival rate cannot exceed the processing capacity of that microservice. Therefore, the service capacity constraint is expressed as follows:
[0048]
[0049] in, Indicates service node Microservice Examples Total request delivery rate This indicates the basic processing capacity of the service node server. The calculation formula is as follows:
[0050]
[0051] in, Indicates service node Microservice Examples Total request delivery rate Represents the set of user requests A user request;
[0052] In latency-sensitive mobile edge computing (MEC) networks, users are most concerned with the end-to-end latency of service requests, as this directly affects network service quality. This embodiment models microservice request processing as an M / M / C queuing system and uses a Jackson queuing network for modeling. In the M / M / C queuing system, when the request arrival rate... When service capacity is exceeded, it will result in infinite queuing delays. Therefore, service nodes... Microservices The service utilization rate must be less than 1, as defined below:
[0053]
[0054] express .
[0055] Furthermore, in one embodiment, according to the little formula, the user request is made at the service node. Microservices Queue delay for:
[0056]
[0057] in, express , Indicates service node Microservice Examples Total request delivery rate The calculation formula is:
[0058]
[0059] in:
[0060]
[0061]
[0062]
[0063] Represents a node Microservices Total number of CPU cores used microservices From service node Migrate to service node The number of CPU cores, microservices At the service node The number of CPU cores used. Indicates service node Microservice Examples Total request delivery rate This indicates the basic processing capacity of the service node server. Indicates service node Microservices The steady-state probability of arrival without request. Indicates service node Microservices The intensity of real-time service;
[0064] node Microservices The sum of queuing and processing delays Expressed using the convolution formula of the probability distribution function and the little rule:
[0065]
[0066] In a MEC network, user requests are forwarded across multiple service nodes via wireless links. Simultaneously, user requests must be processed sequentially according to the predetermined order of microservices within the service chain. For user requests The set of all routing paths, where This indicates the number of paths. Each route is routed according to the order of the microservices in the service chain. Path It contains the sequence of service nodes visited in turn. Indicates the first The total number of service nodes for each path Indicates the first The first of the routing paths The node, the Propagation delay of each routing path The calculation is as follows:
[0067]
[0068] In summary, delay Represented as:
[0069]
[0070] in, Indicates user request The total length of the micro-service chain, Indicates at the service node Complete microservices The request is then routed to the service node. Microservices The probability, Indicates at the service node Processing microservices Queuing delay and processing delay, among which Refers to user requests The The first of the routing paths Each node.
[0071] Furthermore, in one embodiment, service migration typically increases energy consumption, but after migration, the energy consumption and latency for processing user requests can be significantly reduced. Therefore, a reasonable migration decision can compensate for the energy overhead introduced by migration, thereby improving the overall performance of the system in terms of energy consumption and service latency. This embodiment classifies the energy consumption of the edge network into the following categories:
[0072] Idle power consumption: when the service node When the device is powered on, idle power consumption occurs. The total idle energy consumption is then expressed as:
[0073]
[0074] This represents the set of all service nodes;
[0075] Communication energy consumption: In edge networks, communication between service nodes is accomplished through base stations, and its communication energy consumption varies depending on various user requests. exist Arrival rate at time Related, then the total communication energy consumption Represented as:
[0076]
[0077] The unit communication energy consumption coefficient, For the collection of user requests;
[0078] Processing energy consumption: During the process of processing user requests, the service node... The energy consumption sources include the CPU, and its utilization rate is expressed as:
[0079]
[0080] Therefore, the total processing energy consumption can be obtained. for:
[0081]
[0082] in, This represents the energy consumption coefficient during server operation.
[0083] Migration energy consumption: Migration energy consumption depends on the changes in CPU core allocation caused by the migration of microservice instances between different nodes. This represents the energy consumed to complete a single CPU core migration, or the total migration energy consumption. Represented as:
[0084]
[0085] microservices From service node Migrate to service node The number of CPU cores;
[0086] In summary, the energy consumption of the edge network after migration Represented as:
[0087]
[0088] In summary, this embodiment uses the weighted average method to construct the objective function, which includes constraints and the optimization objective, as follows:
[0089]
[0090]
[0091] in and is a weighting coefficient used to balance the priority between minimizing delay and minimizing energy consumption.
[0092] In this embodiment, by prioritizing microservices, the migration needs of high-priority microservices are met first, thereby improving the overall network service performance. After prioritization, with the goal of minimizing the latency and energy consumption of the migrated edge network, a microservice migration strategy is determined under constraints such as resource constraints, request routing constraints, and service capability constraints. This effectively reduces latency and energy consumption and improves the responsiveness and resource utilization efficiency of the edge network.
[0093] Furthermore, in one embodiment, a deep reinforcement learning (DRL) framework is introduced to learn the optimal microservice migration strategy through continuous interaction between the agent and the environment. Each interaction between the agent and the environment can be represented as a quadruple. This is used to represent a single step of experience. Specifically: This represents the environmental state observed by the agent at time t; This represents the action taken by the agent at time t; This represents the reward the agent receives after performing an action; This refers to the new state to which the environment transitions after an action is performed.
[0094] The agent uses the policy function Map each state to an action probability; optimal microservice migration strategy. The goal is to maximize the expected cumulative discount reward. ,in, This is a discount factor used to avoid unbounded cumulative rewards. In summary, the three core representations of an interactive environment are state, action, and reward, where:
[0095] State design:
[0096] The states perceived by the reinforcement learning model include: communication state, current microservice deployment state, and available computing resource state. Defined as:
[0097]
[0098] in, This represents the propagation delay matrix between the service node and its neighboring nodes. This represents the currently deployed collection of microservices. Indicates the remaining computing resource capacity;
[0099] Motion Design:
[0100] The agent's action refers to migrating microservice instances to a target service node to meet system constraints. The agent needs to comprehensively consider the heterogeneity of the target node, available computing resources, and propagation latency between the target and source nodes. During the migration decision-making process, a balance needs to be struck between the selection of the target node and the number of migration instances. In practical applications, large-scale, high-concurrency requests often involve joint calls to multiple microservices, easily leading to an exponential expansion of the action space, significantly reducing the algorithm's deployment efficiency and search capability. Therefore, this embodiment proposes an action space modeling method based on microservice type granularity. By prioritizing the migration of high-priority microservices, the size of the action space is significantly compressed, improving decision-making efficiency. The action space is defined as:
[0101]
[0102] in, This represents the total number of service nodes in the edge network. This represents a probability vector for selecting migration actions based on the microservice type.
[0103] At the same time, after the microservice migration is completed, the request load will be redistributed according to the number of microservice instances on each service node in the following proportions:
[0104]
[0105] Wherein, linear variables are defined. This represents the routing decision variable. Migration decisions must satisfy the computational resource constraints of the target service node. microservices At the service node The number of CPU cores used. Indicates the total number of service nodes;
[0106] Reward Design:
[0107] In the MDP architecture, reinforcement learning algorithms require immediate rewards after each action. Migrating all microservice instances can lead to slow and volatile reward convergence; therefore, this embodiment treats the migration of each microservice as an independent action. However, this design may result in certain types of user requests being prioritized, failing to achieve optimal latency and energy consumption across the entire network. To address this, this embodiment treats the migration of each microservice as an independent action and designs a sparse reward function to quantify the quality of each action and ensure efficient and stable training. The expected result is a significant improvement in overall network latency and energy consumption compared to existing deployment strategies after each microservice migration. The reward design consists of two phases:
[0108] Phase 1: After the migration action is completed, the improvement in latency and energy consumption brought about by the current action is given as an immediate reward;
[0109] Phase 2: After a single round of training, compare the final overall performance improvement, using the result of the previous round as an additional reward for the final move of this round;
[0110] The reward function is defined as:
[0111]
[0112] in, Indicates the number of microservice types; Indicates the first Round Step-by-step execution action Latency and power consumption of post-edge networks; This represents the latency and energy consumption of the edge network after the last action in a single training round; and This represents the reward weighting coefficient.
[0113] like Figure 3 As shown, the microservice migration strategy optimization method PA-PMPO based on reinforcement learning proposed in this embodiment mainly includes an Actor network and a Critic network. Wherein:
[0114] Actor Network: Input the current network state, output the action probability distribution;
[0115] Critic network: A value function that evaluates the current policy.
[0116] After applying the sparse reward function, the reward is fed back to guide the model in discovering better transfer and routing strategies. Before training, the Actor network, Critic network, and experience replay cache are initialized. At the start of each training round, the environment state is initialized. This includes propagation latency, microservice deployment, and remaining resource information. At each time t, the agent selects an action based on a probability distribution:
[0117]
[0118] in, For sampling operations, It is determined by parameters Defined probability distribution function.
[0119] The environment returns to the next state. With rewards :
[0120]
[0121] For the step function of the environment, reward The experience is calculated using a reward function and stored in a cache. When the number of samples accumulated in the cache reaches the update threshold... At that time, the Critic network is updated, and the current state value is... Next state The time difference error TD is calculated from the Critic forward propagation.
[0122]
[0123] As a discount factor, generalized advantage estimation (GAE) is used to improve training stability and reduce variance.
[0124]
[0125] t is the time step. As an intermediate related term of advantage, These are the importance sampling coefficients. In each round of training, [the following is executed]... Subgradient descent randomly samples experience from the cache. The Actor network is updated using the probability ratio of the current policy to the old policy.
[0126]
[0127] in, The sampling probability under the new strategy, This represents the sampling probability under the old strategy.
[0128] The objective loss function of the Actor network is:
[0129]
[0130] For experience expectations, For the cropping operation, This is the cutting factor.
[0131] The Critic network updates by minimizing the mean square error:
[0132]
[0133] in, For mean square error loss, The target difference.
[0134] During training, a validation process is performed every other round to evaluate the policy convergence. In the evaluation phase, the agent selects the action with the highest probability.
[0135]
[0136] This is a maximum value operation. If the observed reward... If stable convergence is achieved, the current optimal strategy is preserved. And the training was terminated.
[0137] In this embodiment, microservices are first prioritized based on the latency tolerance of user requests, the request arrival rate of microservices, and the call frequency of microservices in user requests. By prioritizing the migration needs of high-priority microservices, the overall network service performance is improved.
[0138] After sorting, high-quality migration strategies are rapidly generated in complex and dynamic environments using reinforcement learning. Service migration behavior and resource allocation strategies are dynamically adjusted based on changes in the environment to minimize unnecessary migration operations. This embodiment establishes an energy consumption-latency model and objective function based on the M / M / C queuing theory, evaluating the merits of deployment and routing schemes by calculating the service latency and network energy consumption of requests.
[0139] This embodiment employs a fine-grained optimization approach to address microservice migration at the microservice instance level. Based on the current microservice deployment status, it utilizes reinforcement learning to optimize migration strategies in real time. Furthermore, it dynamically evaluates migration strategies based on service latency and energy consumption calculated from request routing results, fully leveraging the strong coupling between migration and routing. The migration mechanism designed in this embodiment adapts to various types of latency-sensitive services under resource constraints, supports massive IoT requests, and possesses excellent dynamic adaptability. Simultaneously, it fully considers the dependencies between microservices, effectively reducing request queuing latency, routing delay, and system energy consumption through priority sorting and dependency chain adjustment, thereby improving the responsiveness and resource utilization efficiency of the edge network.
[0140] Secondly, embodiments of this application also provide a microservice migration apparatus.
[0141] In one embodiment, reference is made to Figure 4 , Figure 4 This is a functional module diagram of an embodiment of the microservice migration device of this application. Figure 4 As shown, the microservice migration apparatus includes:
[0142] Priority determination module 10 is used to calculate the priority of each microservice in the microservice set S, and determine the microservices that need to be migrated first according to the priority order.
[0143] The migration strategy formulation module 20 is used to construct an objective function containing constraints and optimization objectives for microservices that need to be migrated first, and solve the objective function to obtain the microservice migration strategy. The constraints include computing resource constraints, request routing constraints, and service capability constraints. The optimization objectives include minimizing the latency and energy consumption of the edge network after migration. The edge network consists of service nodes composed of edge servers and IoT computing devices. Multiple microservice instances are distributed and deployed in the service nodes. Different types of microservices are combined to form a service chain structure through chained call relationships. Each microservice has one or more instances in the edge network, and different request types correspond to different service chain paths.
[0144] Furthermore, in one embodiment, the computational resource constraints are represented as follows:
[0145]
[0146]
[0147] in, microservices From node Migrate to node The number of CPU cores, microservices At the service node The number of CPU cores used. microservices At the service node The number of CPU cores used. Indicates service node Total number of CPU cores;
[0148] The request routing constraints are represented as follows:
[0149]
[0150]
[0151] in, Indicates at the service node Complete microservices The request is then routed to the service node. Microservices The probability, microservices From service node Migrate to service node The number of CPU cores, Indicates service node Total number of CPU cores microservices At the service node The number of CPU cores used. This represents the set of all service nodes;
[0152] Service capacity constraints are expressed as follows:
[0153]
[0154]
[0155] in, Indicates service node Microservice Examples Total request delivery rate This indicates the basic processing capacity of the service node server. The calculation formula is as follows:
[0156]
[0157] in, Indicates service node Microservice Examples Total request delivery rate Represents the set of user requests A user request;
[0158] express .
[0159] Furthermore, in one embodiment, according to the little formula, the user request is made at the service node. Microservices Queue delay for:
[0160]
[0161] in, express , Indicates service node Microservice Examples Total request delivery rate The calculation formula is:
[0162]
[0163] in:
[0164]
[0165]
[0166]
[0167] Represents a node Microservices Total number of CPU cores used microservices From service node Migrate to service node The number of CPU cores, microservices At the service node The number of CPU cores used. Indicates service node Microservice Examples Total request delivery rate This indicates the basic processing capacity of the service node server. Indicates service node Microservices The steady-state probability of arrival without request. Indicates service node Microservices The intensity of real-time service;
[0168] node Microservices The sum of queuing and processing delays Expressed using the convolution formula of the probability distribution function and the little rule:
[0169]
[0170] In a MEC network, user requests are forwarded across multiple service nodes via wireless links. Simultaneously, user requests must be processed sequentially according to the predetermined order of microservices within the service chain. For user requests The set of all routing paths, where This indicates the number of paths. Each route is routed according to the order of the microservices in the service chain. Path It contains the sequence of service nodes visited in turn. Indicates the first The total number of service nodes for each path Indicates the first The first of the routing paths The node, the Propagation delay of each routing path The calculation is as follows:
[0171]
[0172] In summary, delay Represented as:
[0173]
[0174] in, Indicates user request The total length of the micro-service chain, Indicates at the service node Complete microservices The request is then routed to the service node. Microservices The probability, Indicates at the service node Processing microservices Queuing delay and processing delay, among which Refers to user requests The The first of the routing paths Each node.
[0175] Furthermore, in one embodiment, energy consumption Represented as:
[0176]
[0177] Among them, when the service node When the device is powered on, idle power consumption occurs. The total idle energy consumption is expressed as:
[0178]
[0179] This represents the set of all service nodes;
[0180] In edge networks, communication between service nodes is accomplished through base stations, and its communication energy consumption varies depending on various user requests. exist Arrival rate at time Related, The total communication energy consumption is expressed as:
[0181]
[0182] The unit communication energy consumption coefficient, For the collection of user requests;
[0183] During the process of processing user requests, the service node The energy consumption sources include the CPU, and its utilization rate is expressed as:
[0184]
[0185] Therefore, the total processing energy consumption can be obtained. for:
[0186]
[0187] in, This represents the energy consumption coefficient during server operation.
[0188] Migration energy consumption depends on the changes in CPU core allocation caused by the migration of microservice instances between different nodes. This represents the energy consumed to complete a single CPU core migration, or the total migration energy consumption. Represented as:
[0189]
[0190] microservices From service node Migrate to service node The number of CPU cores.
[0191] Furthermore, in one embodiment, each microservice in the microservice set S priority The priority of a microservice is determined by the following formula:
[0192]
[0193] in, Indicates user request The types of microservices included in it, This indicates that it includes microservices. The minimum latency tolerance for user requests. Indicates user request Request delivery rate microservices In user request The frequency of calls in and These are the weighting factors for latency tolerance and arrival rate, respectively.
[0194] Furthermore, in one embodiment, the microservice migration apparatus further includes a policy optimization module, used for:
[0195] By introducing a deep reinforcement learning framework, the agent learns the optimal microservice migration strategy through continuous interaction with the environment. The agent then uses the policy function... Map each state to an action probability; optimal microservice migration strategy. The goal is to maximize the expected cumulative discount reward. ,in, It is a discount factor used to avoid unbounded cumulative rewards; the three core representations of the interactive environment are state, action, and reward, among which:
[0196] State design includes:
[0197] The states perceived by the reinforcement learning model include: communication state, current microservice deployment state, and available computing resource state. These states are defined as follows:
[0198]
[0199] in, This represents the propagation delay matrix between the service node and its neighboring nodes. This represents the currently deployed collection of microservices. Indicates the remaining computing resource capacity;
[0200] Action design includes:
[0201] The action space modeling method based on microservice type granularity significantly compresses the size of the action space and improves decision-making efficiency by prioritizing the migration of high-priority microservices. The action space is defined as follows:
[0202]
[0203] in, This represents the total number of service nodes in the edge network. This represents a probability vector for selecting migration actions based on the microservice type.
[0204] At the same time, after the microservice migration is completed, the request load will be redistributed according to the number of microservice instances on each service node in the following proportions:
[0205]
[0206] Wherein, linear variables are defined. This represents the routing decision variable. Migration decisions must satisfy the computational resource constraints of the target service node. microservices At the service node The number of CPU cores used. Indicates the total number of service nodes;
[0207] The reward design includes:
[0208] Each microservice migration is treated as an independent action, and a sparse reward function is designed to quantify the quality of each action. The reward design consists of two phases:
[0209] Phase 1: After the migration action is completed, the improvement in latency and energy consumption brought about by the current action is given as an immediate reward;
[0210] Phase 2: After a single round of training, compare the final overall performance improvement, using the result of the previous round as an additional reward for the final move of this round;
[0211] The reward function is defined as:
[0212]
[0213] in, Indicates the number of microservice types; Indicates the first Round Step-by-step execution action Latency and power consumption of post-edge networks; This represents the latency and energy consumption of the edge network after the last action in a single training round; and This represents the reward weighting coefficient.
[0214] The functions of each module in the microservice migration device correspond to the steps in the microservice migration method embodiment, and their functions and implementation processes will not be described in detail here.
[0215] Thirdly, embodiments of this application provide a microservice migration device, which can be a personal computer (PC), laptop computer, server, or other device with data processing capabilities.
[0216] Reference Figure 5 , Figure 5 This is a schematic diagram of the hardware structure of the microservice migration device involved in the embodiments of this application. In this embodiment, the microservice migration device may include a processor, memory, communication interface, and communication bus.
[0217] The communication bus can be of any type and is used to interconnect the processor, memory, and communication interface.
[0218] Communication interfaces include input / output (I / O) interfaces, physical interfaces, and logical interfaces used for interconnecting devices within the microservice migration device, as well as interfaces used for interconnecting the microservice migration device with other devices (such as other computing devices or user devices). Physical interfaces can be Ethernet interfaces, fiber optic interfaces, ATM interfaces, etc.; user devices can be displays, keyboards, etc.
[0219] Memory can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), flash memory, optical storage, hard disk, programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), etc.
[0220] The processor can be a general-purpose processor, which can call the microservice migration program stored in memory and execute the microservice migration method provided in the embodiments of this application. For example, the general-purpose processor can be a central processing unit (CPU). The method executed when the microservice migration program is called can be referred to in the various embodiments of the microservice migration method of this application, and will not be repeated here.
[0221] Those skilled in the art will understand that Figure 5 The hardware structure shown does not constitute a limitation of this application and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0222] Fourthly, embodiments of this application also provide a computer-readable storage medium.
[0223] The present application provides a computer-readable storage medium storing a microservice migration program, wherein when the microservice migration program is executed by a processor, it implements the steps of the microservice migration method described above.
[0224] The method implemented when the microservice migration procedure is executed can be referred to in various embodiments of the microservice migration method of this application, and will not be repeated here.
[0225] It should be noted that the sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0226] The terms "comprising" and "having," and any variations thereof, in the specification, claims, and accompanying drawings of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus 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 such process, method, product, or apparatus. The terms "first," "second," and "third," etc., are used to distinguish different objects, etc., and do not indicate a sequence, nor do they limit "first," "second," and "third" to different types.
[0227] In the description of the embodiments of this application, terms such as "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a concrete manner.
[0228] In the description of the embodiments of this application, unless otherwise stated, " / " means "or". For example, A / B can mean A or B. The "and / or" in the text is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of this application, "multiple" means two or more.
[0229] In some processes described in the embodiments of this application, multiple operations or steps are included in a specific order. However, it should be understood that these operations or steps may not be executed in the order they appear in the embodiments of this application, or they may be executed in parallel. The sequence number of the operation is only used to distinguish different operations, and the sequence number itself does not represent any execution order. In addition, these processes may include more or fewer operations, and these operations or steps may be executed sequentially or in parallel, and these operations or steps may be combined.
[0230] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device to execute the methods described in the various embodiments of this application.
[0231] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, 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 migration method, characterized by, The microservice migration method includes: Calculate the priority of each microservice in the microservice set S, and sort them according to priority to determine the microservices that need to be migrated first; For microservices that need to be migrated first, an objective function containing constraints and optimization goals is constructed, and the microservice migration strategy is obtained by solving the objective function. The constraints include computing resource constraints, request routing constraints, and service capability constraints. The optimization goals include minimizing the latency and energy consumption of the edge network after migration. The edge network consists of service nodes composed of edge servers and IoT computing devices. Multiple microservice instances are distributed and deployed in the service nodes. Different types of microservices are combined to form a service chain structure through chained call relationships. Each microservice has one or more instances in the edge network, and different request types correspond to different service chain paths. Priorities of the microservices in the microservice set S The priority of the microservice is determined by a microservice priority calculation formula, and the microservice priority calculation formula is as follows: in, Indicates user request The types of microservices included in it, This indicates that it includes microservices. The minimum latency tolerance for user requests. Indicates user request Request delivery rate microservices In user request The frequency of calls in and These are the weighting factors for latency tolerance and arrival rate, respectively. By introducing a deep reinforcement learning framework, the agent learns the optimal microservice migration strategy through continuous interaction with the environment. The agent then uses the policy function... Map each state to an action probability; optimal microservice migration strategy. The goal is to maximize the expected cumulative discount reward. ,in, It is a discount factor used to avoid unbounded cumulative rewards; the three core representations of the interactive environment are state, action, and reward.
2. The microservice migration method as described in claim 1, characterized in that, Computational resource constraints are represented as follows: in, microservices From node Migrate to node The number of CPU cores, microservices At the service node The number of CPU cores used. microservices At the service node The number of CPU cores used. Indicates service node Total number of CPU cores; The request routing constraints are represented as follows: in, Indicates at the service node Complete microservices The request is then routed to the service node. Microservices The probability, microservices From service node Migrate to service node The number of CPU cores, Indicates service node Total number of CPU cores microservices At the service node The number of CPU cores used. This represents the set of all service nodes; Service capacity constraints are expressed as follows: in, Indicates service node Microservice Examples Total request delivery rate This indicates the basic processing capacity of the service node server. The calculation formula is as follows: in, Indicates service node Microservice Examples Total request delivery rate Represents the set of user requests A user request; express .
3. The microservice migration method as described in claim 1, characterized in that, According to the little formula, user requests are made on the service node. Microservices Queue delay for: in, express , Indicates service node Microservice Examples Total request delivery rate The calculation formula is: in: Represents a node Microservices Total number of CPU cores used microservices From service node Migrate to service node The number of CPU cores, microservices At the service node The number of CPU cores used. Indicates service node Microservice Examples Total request delivery rate This indicates the basic processing capacity of the service node server. Indicates service node Microservices The steady-state probability of arrival without request. Indicates service node Microservices The intensity of real-time service; node Microservices The sum of queuing and processing delays Expressed using the convolution formula of the probability distribution function and the little rule: In a MEC network, user requests are forwarded across multiple service nodes via wireless links. Simultaneously, user requests must be processed sequentially according to the predetermined order of microservices within the service chain. For user requests The set of all routing paths, where This indicates the number of paths. Each route is routed according to the order of the microservices in the service chain. Path It contains the sequence of service nodes visited in turn. Indicates the first The total number of service nodes for each path Indicates the first The first of the routing paths The node, the Propagation delay of each routing path The calculation is as follows: In summary, delay Represented as: in, Indicates user request The total length of the micro-service chain, Indicates at the service node Complete microservices The request is then routed to the service node. Microservices The probability, Indicates at the service node Processing microservices Queuing delay and processing delay, among which Refers to user requests The The first of the routing paths Each node.
4. The microservice migration method as described in claim 1, characterized in that, Energy consumption Represented as: Among them, when the service node When the device is powered on, idle power consumption occurs. The total idle energy consumption is expressed as: This represents the set of all service nodes; In edge networks, communication between service nodes is accomplished through base stations, and its communication energy consumption varies depending on various user requests. exist Arrival rate at time Related, The total communication energy consumption is expressed as: The unit communication energy consumption coefficient, For the collection of user requests; During the process of processing user requests, the service node The energy consumption sources include the CPU, and its utilization rate is expressed as: Therefore, the total processing energy consumption can be obtained. for: in, This represents the energy consumption coefficient during server operation. Migration energy consumption depends on the changes in CPU core allocation caused by the migration of microservice instances between different nodes. This represents the energy consumed to complete a single CPU core migration, or the total migration energy consumption. Represented as: microservices From service node Migrate to service node The number of CPU cores.
5. The microservice migration method as described in claim 1, characterized in that, The microservice migration method also includes: State design includes: The states perceived by the reinforcement learning model include: communication state, current microservice deployment state, and available computing resource state. These states are defined as follows: in, This represents the propagation delay matrix between the service node and its neighboring nodes. This represents the currently deployed collection of microservices. Indicates the remaining computing resource capacity; Action design includes: The action space modeling method based on microservice type granularity significantly compresses the size of the action space and improves decision-making efficiency by prioritizing the migration of high-priority microservices. The action space is defined as follows: in, This represents the total number of service nodes in the edge network. This represents a probability vector for selecting migration actions based on the microservice type. At the same time, after the microservice migration is completed, the request load will be redistributed according to the number of microservice instances on each service node in the following proportions: Wherein, linear variables are defined. This represents the routing decision variable. Migration decisions must satisfy the computational resource constraints of the target service node. microservices At the service node The number of CPU cores used. Indicates the total number of service nodes; The reward design includes: Each microservice migration is treated as an independent action, and a sparse reward function is designed to quantify the quality of each action. The reward design consists of two phases: Phase 1: After the migration action is completed, the improvement in latency and energy consumption brought about by the current action is given as an immediate reward; Phase 2: After a single round of training, compare the final overall performance improvement, using the result of the previous round as an additional reward for the final move of this round; The reward function is defined as: in, Indicates the number of microservice types; Indicates the first Round Step-by-step execution action Latency and power consumption of post-edge networks; This represents the latency and energy consumption of the edge network after the last action in a single training round; and This represents the reward weighting coefficient.
6. A microservice migration device, characterized in that, The microservice migration apparatus includes: The priority determination module is used to calculate the priority of each microservice in the microservice set S, and determine the microservices that need to be migrated first according to the priority order. The migration strategy formulation module is used to construct an objective function containing constraints and optimization objectives for microservices that need to be migrated first, and solve the objective function to obtain the microservice migration strategy. The constraints include computing resource constraints, request routing constraints, and service capability constraints. The optimization objectives include minimizing the latency and energy consumption of the edge network after migration. The edge network consists of service nodes composed of edge servers and IoT computing devices. Multiple microservice instances are distributed and deployed in the service nodes. Different types of microservices are combined to form a service chain structure through chained call relationships. Each microservice has one or more instances in the edge network, and different request types correspond to different service chain paths. Each microservice in the microservice set S priority The priority of a microservice is determined by the following formula: in, Indicates user request The types of microservices included in it, This indicates that it includes microservices. The minimum latency tolerance for user requests. Indicates user request Request delivery rate microservices In user request The frequency of calls in and These are the weighting factors for latency tolerance and arrival rate, respectively. It also includes a policy optimization module, which introduces a deep reinforcement learning framework to learn the optimal microservice migration strategy through continuous interaction between the agent and the environment. The agent then uses the policy function... Map each state to an action probability; optimal microservice migration strategy. The goal is to maximize the expected cumulative discount reward. ,in, It is a discount factor used to avoid unbounded cumulative rewards; the three core representations of the interactive environment are state, action, and reward.
7. The microservice migration apparatus as described in claim 6, characterized in that, Computational resource constraints are represented as follows: in, microservices From node Migrate to node The number of CPU cores, microservices At the service node The number of CPU cores used. microservices At the service node The number of CPU cores used. Indicates service node Total number of CPU cores; The request routing constraints are represented as follows: in, Indicates at the service node Complete microservices The request is then routed to the service node. Microservices The probability, microservices From service node Migrate to service node The number of CPU cores, Indicates service node Total number of CPU cores microservices At the service node The number of CPU cores used. This represents the set of all service nodes; Service capacity constraints are expressed as follows: in, Indicates service node Microservice Examples Total request delivery rate This indicates the basic processing capacity of the service node server. The calculation formula is as follows: in, Indicates service node Microservice Examples Total request delivery rate Represents the set of user requests A user request; express .
8. A microservice migration device, characterized in that, The microservice migration device includes a processor, a memory, and a microservice migration program stored in the memory and executable by the processor, wherein when the microservice migration program is executed by the processor, it implements the steps of the microservice migration method as described in any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a microservice migration program, wherein when the microservice migration program is executed by a processor, it implements the steps of the microservice migration method as described in any one of claims 1 to 5.