Microservice elastic resource scheduling method, device and electronic equipment
By constructing a long-term scheduling optimization model and combining it with a deep reinforcement learning model, the allocation of microservice resources is dynamically adjusted, which solves the performance and stability problems of microservice systems under dynamic loads and achieves optimization of low latency and resource utilization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-13
- Publication Date
- 2026-03-17
AI Technical Summary
In existing technologies, microservice systems face dynamic changes in request load, resulting in poor service performance and resource utilization, difficulty in accurately and efficiently selecting appropriate routing paths, and increased request response latency and load imbalance.
A long-term scheduling optimization model is constructed to minimize the long-term average request latency of the microservice system. The model is transformed into a time-slot scheduling optimization model by combining the Lyapunov optimization method. The initial solution is then optimized by a pre-trained deep reinforcement learning model, and resource allocation is dynamically adjusted to cope with load changes.
It achieves high performance, high stability and adaptability of microservice systems under dynamic load, optimizes scaling and migration costs and user request latency, and improves system reliability and operational efficiency.
Smart Images

Figure CN120909746B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of microservices technology, and in particular to a method, apparatus and electronic device for elastic resource scheduling of microservices. Background Technology
[0002] Microservice architecture breaks down monolithic network services into a series of lightweight services that can be deployed and managed independently, greatly improving the scalability and flexibility of internet applications. With the maturity of cloud computing and containerization technologies, microservices have become even more powerful in terms of dynamic deployment, rapid startup, and elastic scaling, and have gradually become the mainstream architectural choice for cloud data center software systems.
[0003] Microservice architecture demonstrates unique advantages in the design and management of modern complex distributed systems. User requests received by a microservice system often require the collaborative processing of multiple microservices. Since these microservices are highly decoupled and work together via remote calls, complex request invocation and routing are necessary. Accurately and efficiently selecting appropriate routing paths for user requests, reducing request response latency, and balancing request load among microservices are key to improving system service performance and resource utilization.
[0004] In practical operation, microservice systems face dynamically changing request loads. To cope with uneven distribution and rapid growth of request loads, elastic resource scheduling is required, which involves migrating microservice instances from one resource node to another, or dynamically increasing and decreasing the number of microservice instances. Finding an appropriate method for elastic resource scheduling of microservices to meet users' Quality of Service (QoS) requirements in the long term while reducing overhead is a pressing issue. Summary of the Invention
[0005] This invention provides a method, apparatus, and electronic device for elastic resource scheduling of microservices, which addresses the shortcomings of existing technologies in terms of poor service performance and resource utilization of microservice systems when faced with dynamically changing request loads.
[0006] This invention provides a method for elastic resource scheduling of microservices, comprising:
[0007] Identify the microservice system to be scheduled, wherein the microservice system includes a server and microservice instances deployed on the server;
[0008] A long-term scheduling optimization model is constructed with the goal of minimizing the long-term average request latency of the microservice system. The constraints of the long-term scheduling optimization model include the long-term total overhead constraint of the microservice system, the memory and CPU resource constraints of each server.
[0009] The long-term scheduling optimization model is transformed into a time-slot scheduling optimization model within each time slot based on the Lyapunov optimization method. The constraints of the time-slot scheduling optimization model include memory and CPU resource constraints for each server.
[0010] The initial solution of the optimization model is obtained based on the near-end optimization strategy. Then, the initial solution is optimized for dynamically changing requests using a pre-trained deep reinforcement learning model. Based on the optimization results, elastic resource scheduling of microservices is performed.
[0011] According to the microservice deployment and elastic resource scheduling method provided by the present invention, the step of optimizing the initial solution for dynamically changing requests using a pre-trained deep reinforcement learning model includes:
[0012] Obtain the current state of the microservice system, which includes the remaining memory and CPU information of each server, the microservice information already deployed on each server, and the historical information of microservice requests;
[0013] Based on the deep neural network in the deep reinforcement learning model, extract the state features of the current state;
[0014] Based on the policy network in the deep reinforcement learning model and the state features, the initial solution is optimized for dynamically changing requests to obtain an optimization result, which includes changes in the target server, the target microservice instance, and the number of the target microservice instances.
[0015] According to the microservice deployment and elastic resource scheduling method provided by the present invention, the reward function of the deep reinforcement learning model is determined based on the backlog of the virtual queue at the end of the current time slot, the total cost in the current time slot, and the average request latency of the microservice system in the current time slot.
[0016] According to the microservice deployment and elastic resource scheduling method provided by the present invention, the step of transforming the long-term scheduling optimization model into a time-slot scheduling optimization model based on the Lyapunov optimization method includes:
[0017] The upper boundary of Lyapunov drift is determined based on the number of microservice instances, the number of servers, the number of microservice instance changes, the number of server changes, and the difference between the total overhead and the overhead budget in each time slot.
[0018] Based on the upper boundary of the Lyapunov drift, the backlog of the virtual queue at the end of each time slot, and the average request latency of the microservice system in each time slot, the upper boundary of the Lyapunov drift plus penalty function in each time slot is determined.
[0019] Based on the upper boundary of the Lyapunov drift plus penalty function in each time slot, the optimization objective of the time slot scheduling optimization model in each time slot is determined.
[0020] According to the microservice deployment and elastic resource scheduling method provided by the present invention, the total overhead within each time slot is determined based on the following steps:
[0021] Based on the total number of microservice instances in each time slot, the resources required for a single microservice instance to run, the total number of servers in each time slot, and the resources required for a single server to run, the deployment overhead in each time slot is determined.
[0022] Based on the number of microservice instances that need to be changed in each time slot, the resource overhead of deploying or deleting a single microservice instance, the number of servers that need to be changed in each time slot, and the resource overhead of opening or closing a single server, determine the scaling overhead in each time slot.
[0023] The total cost within each time slot is determined based on the deployment cost and scaling cost within each time slot.
[0024] According to the microservice deployment and elastic resource scheduling method provided by the present invention, the long-term average request latency of the microservice system is determined based on the following steps:
[0025] Based on the average number of requests waiting at each microservice instance in any request flow and the request arrival rate of each microservice instance, the average waiting latency of the request flow on any routing path is determined.
[0026] Based on the request processing capabilities of each microservice instance, determine the average processing latency of any request flow on any routing path;
[0027] The average communication latency of any request flow on any routing path is determined based on whether the predecessor microservice instance of each microservice instance on the routing path is on the same server as it.
[0028] The long-term average request latency of the microservice system is determined based on the importance weight of each request flow, the probability weight of each routing path, the average waiting latency, the average processing latency, and the average communication latency.
[0029] According to the microservice deployment and elastic resource scheduling method provided by the present invention, before determining the microservice system to be scheduled, the method further includes performing an initial deployment of the microservice using a first-fit decreasing algorithm, wherein the initial deployment specifically includes:
[0030] Sort the microservices according to their resource requirements and prioritize deploying the microservices with higher resource requirements;
[0031] Based on the total arrival rate of various microservices in all request streams, determine the number of instances required for each microservice.
[0032] Iterate through each server and, based on the maximum number of microservice instances each server can host, deploy all instances required for each type of microservice onto the server.
[0033] According to the microservice deployment and elastic resource scheduling method provided by the present invention, the training steps of the deep reinforcement learning model include:
[0034] Candidate actions are obtained based on the state features of the current time step and the initial policy network. The candidate actions are sampled to obtain the action to be executed, and the reward for the current time step is calculated.
[0035] Based on the state characteristics and initial value network at the current time step, the value function at the current time step is obtained;
[0036] The advantage function is determined based on the reward at the current time step, and the reward at the current time step is determined based on the advantage function and the value function.
[0037] Based on the advantage function, value function, and reward at the current time step, the strategy loss, value loss, and entropy loss are determined respectively, and the total loss is determined based on the strategy loss, value loss, and entropy loss.
[0038] Based on the total loss, the parameters of the initial policy network and the initial value network are iterated to obtain the deep reinforcement learning model.
[0039] The present invention also provides a microservice elastic resource scheduling device, comprising:
[0040] A microservice system determination unit is used to determine the microservice system to be scheduled, wherein the microservice system includes a server and microservice instances deployed on the server;
[0041] The long-term model building unit is used to build a long-term scheduling optimization model with the goal of minimizing the long-term average request latency of the microservice system. The constraints of the long-term scheduling optimization model include the long-term total overhead constraints of the microservice system, the memory and CPU resource constraints of each server.
[0042] The time slot model construction unit is used to transform the long-term scheduling optimization model into a time slot scheduling optimization model within each time slot based on the Lyapunov optimization method. The constraints of the time slot scheduling optimization model include memory and CPU resource constraints for each server.
[0043] An optimization scheduling unit is used to obtain an initial solution of the optimization model based on a near-end optimization strategy, and then optimize the initial solution for dynamically changing requests using a pre-trained deep reinforcement learning model, and perform elastic resource scheduling of microservices based on the optimization results.
[0044] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the elastic resource scheduling method for microservices as described above.
[0045] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the elastic resource scheduling method for microservices as described above.
[0046] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the elastic resource scheduling method for microservices as described above.
[0047] The present invention provides a microservice elastic resource scheduling method, apparatus, and electronic device. By constructing a long-term scheduling optimization model with the objective of minimizing the long-term average request latency of the microservice system, it ensures that the system meets users' low-latency requirements globally, improving user experience. Through constraints, it achieves Pareto optimality in performance and cost. Based on the Lyapunov optimization method, the long-term scheduling optimization model is transformed into a slot-based scheduling optimization model within each slot, decomposing the long-term problem into a local optimization problem within each slot, ensuring system stability under dynamic load. An initial solution to the optimization model is obtained based on a near-end optimization strategy. Then, a pre-trained deep reinforcement learning model optimizes the initial solution for dynamically changing requests, and elastic resource scheduling of microservices is performed based on the optimization results. This achieves multi-objective optimization of microservice scaling and migration costs and user request latency, realizing high performance, high stability, and adaptability in microservice scheduling. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0049] Figure 1 This is a flowchart illustrating the elastic resource scheduling method for microservices provided by the present invention.
[0050] Figure 2This is a schematic diagram of a scenario for the microservice elastic resource scheduling method provided by the present invention.
[0051] Figure 3 This is a schematic diagram of the training structure of the deep reinforcement learning model provided by the present invention.
[0052] Figure 4 This is a schematic diagram of the elastic resource scheduling device for microservices provided by the present invention.
[0053] Figure 5 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0055] To address the challenges of accurately and efficiently selecting appropriate routing paths for user requests, reducing request response latency, and balancing request load among microservices, this invention proposes an elastic resource scheduling method for microservices. This method first constructs a long-term scheduling optimization model with the goal of minimizing the long-term average request latency of the microservice system. This ensures that the system meets users' low-latency requirements globally, improving user experience, and achieving Pareto optimality in performance and cost through constraints. Then, based on the Lyapunov optimization method, the long-term scheduling optimization model is transformed into a slot-based scheduling optimization model, decomposing the long-term problem into a local optimization problem within each slot, ensuring system stability under dynamic load. An initial solution to the optimization model is obtained based on a near-end optimization strategy. Then, a pre-trained deep reinforcement learning model is used to optimize the initial solution for dynamically changing requests, and elastic resource scheduling of microservices is performed based on the optimization results.
[0056] The embodiments of the present invention achieve multi-objective optimization of microservice scaling and migration costs and user request latency, and realize high performance, high stability and adaptability of microservice scheduling. It is suitable for elastic scaling and resource optimization in cloud-native environments, and significantly improves system reliability and operational efficiency.
[0057] This invention can be applied to scenarios requiring elastic resource scheduling for microservices, such as cloud-native microservices, edge computing, and hybrid cloud architectures. The executing entity of this method can be an electronic device such as a terminal device, computer, server, server cluster, or a specially designed elastic resource scheduling device, or an elastic resource scheduling device installed within that electronic device. This elastic resource scheduling device can be implemented through software, hardware, or a combination of both.
[0058] Figure 1 This is a flowchart illustrating the elastic resource scheduling method for microservices provided by the present invention, as shown below. Figure 1 As shown, the method includes the following steps:
[0059] Step 110: Determine the microservice system to be scheduled. The microservice system includes the server and the microservice instances deployed on the server.
[0060] Specifically, a microservice system is an architectural style that breaks down an application into multiple independently deployed, loosely coupled service units. Each service unit (microservice) focuses on a single business function and works together through lightweight communication protocols.
[0061] A server can be a physical machine or a virtual machine, providing computing resources (CPU, memory, storage, etc.). A microservice instance refers to a single copy of a microservice deployed on a server, which can be independently scaled and extended.
[0062] Microservice systems awaiting scheduling refer to systems that require dynamic adjustment of resource allocation (such as scaling up, down, and migration) to meet performance requirements (such as low latency and high throughput) and optimize costs.
[0063] Figure 2 This is a schematic diagram illustrating an application scenario of the microservice elastic resource scheduling method provided by the present invention. (Refer to...) Figure 2 The microservice system includes servers S1-S5 and microservice instances m1-m5. Server S1 has microservice instances m1, m2, and m4 deployed; server S2 has microservice instances m3 and m5 deployed; server S3 has microservice instances m1 and m2 deployed; server S4 has microservice instances m2 and m3 deployed; and server S5 has microservice instances m4, m4, and m5 deployed. There are three user request flows: R1, R2, and R3. Request flow R1 corresponds to the microservice instance m4→m1→m5→m2; request flow R2 corresponds to the microservice instance m1→m3→m4→m2; and request flow R3 corresponds to the microservice instance m5→m4→m1→m3. Microservice instance m3 has request queues R1 and R3, and microservice instance m5 has request queue R1.
[0064] Step 120: Construct a long-term scheduling optimization model with the goal of minimizing the long-term average request latency of the microservice system. The constraints of the long-term scheduling optimization model include the long-term total overhead constraint of the microservice system, the memory and CPU resource constraints of each server.
[0065] Specifically, long-term average request latency refers to the average response time of a microservice system processing all requests over a long period of time. It is an important metric for measuring system performance and directly impacts user experience. Minimizing long-term average request latency ensures that the system can still provide low-latency service under high load.
[0066] Long-run total overhead refers to the total cost of using all resources (such as servers, storage, network bandwidth, etc.) of a microservice system over a long period of time. During optimization, it is necessary to ensure that the long-run total overhead does not exceed a preset budget limit.
[0067] At the same time, the memory and CPU resources of each server are limited, and the deployment and operation of microservice instances cannot exceed these resource limits.
[0068] In some embodiments, queuing theory can be used to mathematically model the problem to obtain the request delay, and combined with the cost function to obtain the long-term optimization problem, thereby obtaining a long-term scheduling optimization model.
[0069] The long-term average request latency of a microservice system is determined based on the following steps:
[0070] Based on the average number of requests waiting at each microservice instance in any request flow and the request arrival rate of each microservice instance, determine the average waiting latency of the request flow on the routing path;
[0071] Based on the request processing capabilities of each microservice instance, determine the average processing latency of the request flow on the routing path;
[0072] The average communication latency of the request flow on the routing path is determined based on whether the predecessor microservice instance of each microservice instance on the routing path is on the same server as it.
[0073] The long-term average request latency of the microservice system is determined based on the importance weight of each request flow, the probability weight of each routing path, the average waiting latency, the average processing latency, and the average communication latency.
[0074] Specifically, the model parameters and their definitions are as follows:
[0075]
[0076] Multiple instances of the same microservice can be deployed on each server to improve the server's ability to handle requests for a particular microservice. Each instance has its own core, thus ensuring independence between instances. When multiple instances of the same microservice exist on the same server, they can be modeled as a single... A queuing system, which contains all instances of the microservice. The service strength of this queuing system is defined as follows: Specifically, it is expressed as:
[0077]
[0078] Represents a microservice The instance's ability to handle requests This represents the request delivery rate of microservice m. This represents the number of microservice instances deployed on the server that handle microservice m. For a single server, when the queuing system reaches a steady state, the number of microservice instances... The average number of requests waiting at a location is expressed as Its expression is:
[0079]
[0080] Among them, parameters The expression for is:
[0081]
[0082] There are three sources of request-response latency: waiting latency, processing latency, and communication latency. Let's take a routing path as an example for a specific analysis:
[0083] (1) Waiting latency: The time spent waiting for a request to be processed by a microservice instance, expressed as a percentage of the total latency. Indicates a request for a microservice The average waiting time is calculated using the following formula:
[0084]
[0085] Then request stream Average waiting time on a routing path for:
[0086]
[0087] In the formula, Indicates request flow The required set of microservices.
[0088] (2) Handling latency: Microservices The time spent processing the request, using microservices The processing latency is calculated using the following formula:
[0089]
[0090] The sequence of microservices traversed by any route in the request flow is identical, and the core processing capabilities of the servers are also completely the same. Therefore, the request flow... The processing latency is independent of the routing path, and the average processing latency of any routing path is... All are:
[0091]
[0092] (3) Communication latency: The time spent transferring requests within the microservice system, expressed in terms of latency. This represents a microservice on a routing path. The latency of communication between the predecessor microservice and the microservice is calculated using the following formula:
[0093]
[0094] in, It is a binary decision variable, representing the microservices on the routing path. Whether the predecessor microservice is on the same service as it; if so, the value is 0; otherwise, the value is 1. Request flow. The average communication delay for a given routing path is:
[0095]
[0096] Based on the above analysis, the request flow can be obtained. In a routing path Average request response latency This can be expressed as a formula:
[0097]
[0098] The request flow can be obtained by using the probability of each path as a weighting factor. Average request response time across all routing paths :
[0099]
[0100] In the formula, Indicates the routing path The probability of.
[0101] Finally, based on each request stream The importance is defined by a weighting coefficient. After weighted averaging, the average request response latency of the entire microservice system can be obtained. :
[0102]
[0103] The time-averaged average request latency of a microservice system, i.e., the long-term average request latency. It can be represented as:
[0104]
[0105] In the formula, t is the time variable, and T is the termination time. To find the average function.
[0106] To ensure system performance stability and balance resource consumption with user response speed, a resource consumption function needs to be defined. This means the constraints of the long-term scheduling optimization model include the long-term total overhead constraints of the microservice system, and the memory and CPU resource constraints for each server.
[0107] To assess the long-term total overhead of a microservice system, we can first model the total overhead within each time slot.
[0108] In some embodiments, the total overhead within each time slot is determined based on the following steps:
[0109] Based on the total number of microservice instances in each time slot, the resources required for a single microservice instance to run, the total number of servers in each time slot, and the resources required for a single server to run, the deployment overhead in each time slot is determined.
[0110] Based on the number of microservice instances that need to be changed in each time slot, the resource overhead of deploying or deleting a single microservice instance, the number of servers that need to be changed in each time slot, and the resource overhead of opening or closing a single server, determine the scaling overhead in each time slot.
[0111] The total cost within each time slot is determined based on the deployment and scaling costs within each time slot.
[0112] Specifically, the system's resource consumption and time slots If the number of microservice instances deployed within the instance is positively correlated, then time slots can be defined. Internal deployment overhead for:
[0113]
[0114] in, These are the resources required for a single microservice instance to run. These are the resources required for a single server to run. It is a time slot Total number of microservice instances within It is a time slot The total number of servers within.
[0115] The resource overhead caused by instance scaling mainly comes from the deployment and deletion of microservices and the startup and shutdown of servers, and is directly proportional to changes in the number of microservices and servers. Therefore, time slots are defined. Internal scaling overhead for:
[0116]
[0117] in, It is the resource overhead of deploying or deleting a single microservice instance. It is the resource overhead of turning a single server on or off. It is a time slot The number of microservice instances that need to be changed. It is a time slot The number of servers that need to be changed internally.
[0118] Time slots can be defined Total internal expenses for:
[0119]
[0120] in, and These are the non-negative weighted coefficients that balance operating costs and resource scheduling costs.
[0121] Express the time-average long-term overhead budget provided by the service provider. Therefore, the total cost needs to satisfy the following constraint, that is, the long-run total cost constraint can be expressed as:
[0122]
[0123] In addition, the long-term scheduling optimization model needs to meet the memory and CPU resource constraints of each server.
[0124] In summary, the long-term optimization problem of elastic resource scheduling under dynamic changes in system load can be represented as problem P1, that is, the long-term scheduling optimization model can be represented as: That is, minimizing the average request latency of the microservice system. The constraints of this long-term scheduling optimization model include:
[0125]
[0126]
[0127]
[0128] In the formula, Indicates server microservices deployed on Quantity, Indicates the deployment of microservices Required CPU resources Indicates server CPU resources available Indicates the deployment of microservices Required memory resources Indicates server The available memory resources.
[0129] Step 130: Based on the Lyapunov optimization method, the long-term scheduling optimization model is transformed into a time-slot scheduling optimization model within each time slot. The constraints of the time-slot scheduling optimization model include the memory and CPU resource constraints of each server.
[0130] Specifically, a day is divided into 288 time slots, each lasting 5 minutes. The long-term optimization problem of the system is transformed into a problem within each time slot using a Lyapunov drift-penalty function. The time slot scheduling optimization model independently optimizes local decisions within each time slot, while long-term stability is ensured through Lyapunov drift constraints. Lyapunov drift measures the change in system state (such as a virtual queue) and is used to constrain system stability. The drift-penalty function adds penalty terms (such as cost or delay) to the drift constraints, achieving a trade-off between stability and performance.
[0131] In some embodiments, step 130 specifically includes:
[0132] Step 131: Determine the upper boundary of Lyapunov drift based on the number of microservice instances, the number of servers, the number of microservice instance changes, the number of server changes, and the difference between the total overhead and the overhead budget in each time slot.
[0133] Step 132: Based on the upper boundary of Lyapunov drift, the backlog of the virtual queue at the end of each time slot, and the average request latency of the microservice system within each time slot, determine the upper boundary of the Lyapunov drift plus penalty function within each time slot.
[0134] Step 133: Based on the upper boundary of the Lyapunov drift plus penalty function in each time slot, determine the time slot scheduling optimization model in each time slot.
[0135] Specifically, problem P1 is a time-averaged optimization problem. Lyapunov optimization theory can transform this time-averaged optimization problem into an optimization problem within each time slot by constructing a virtual queue. A virtual queue is defined for the total cost. , indicating time slot The backlog of the virtual queue at the end, and the update equation for the virtual queue in each time slot are:
[0136]
[0137] in, Initial virtual queue backlog at time 1 ; The meaning is the remaining budget at the end of the previous time slot. According to Lyapunov optimization theory, when the virtual queue reaches average stability, we have:
[0138]
[0139] Lemma 1: If virtual queue If the above stability conditions are met, then the time-averaged constraint on total cost is also met.
[0140] Lyapunov function is introduced based on Lyapunov optimization methods. for:
[0141]
[0142] This allows us to define Lyapunov drift. for:
[0143]
[0144] Lemma 2: The Lyapunov drift within each time slot must have an upper bound. The upper bound of the Lyapunov drift can be determined based on the number of microservice instances, the number of servers, the number of microservice instance changes, the number of server changes, and the difference between the total overhead and the overhead budget within each time slot, expressed by the formula:
[0145]
[0146]
[0147] in, It is a constant. , , , These are the maximum values of the number of microservices, the number of servers, the number of microservice changes, and the number of server changes within time slot t, respectively, and can all be treated as known constants. , , , , These are all corresponding weighting factors.
[0148] To maintain the stability of the virtual queue while minimizing the average response latency, the optimization objective can be decomposed into each time slot. Simultaneously, the minimum values of Lyapunov drift and the average request response latency of the microservice graph are calculated, and then a non-negative coefficient is used. We need to weigh these two factors. This leads to the "drift plus penalty" function for each time slot, expressed by the formula:
[0149]
[0150] The drift plus penalty function has an upper bound:
[0151]
[0152] According to Lyapunov optimization theory, the original problem can be transformed into minimizing the upper bound of a given "drift plus penalty" function, i.e.:
[0153]
[0154] The summary yields:
[0155]
[0156] Among them, the first item The second term is a constant. middle For time slots The known quantities observed internally, therefore the second term is also a constant, and the third term... middle For total expenses, The average response latency of a microservice system after elastic resource scheduling is determined by the elastic resource scheduling scheme.
[0157] Based on the above analysis, the original problem P1 can be transformed into a problem P2 within each time slot using the "drift plus penalty" principle. Furthermore, according to the framework of minimizing conditional expectation, it can be transformed into a solution that minimizes unconditional expectation. That is, the time slot scheduling optimization model within each time slot can be expressed as follows: The constraints of this time slot scheduling optimization model include:
[0158]
[0159]
[0160] Step 140: Obtain the initial solution of the optimization model based on the near-end optimization strategy, and then optimize the initial solution for dynamically changing requests using a pre-trained deep reinforcement learning model. Based on the optimization results, perform elastic resource scheduling for microservices.
[0161] Specifically, the goal of the proximal optimization strategy is to quickly generate a high-quality initial resource allocation solution that satisfies the basic constraints, providing a starting point for subsequent DRL optimization. This initial resource allocation scheme, i.e., the initial solution, can be generated using a heuristic algorithm applicable to global search.
[0162] Deep reinforcement learning is a machine learning method that combines deep learning and reinforcement learning. In deep reinforcement learning, an agent learns optimal behavioral policies by interacting with its environment and receiving reward signals from the environment. Deep reinforcement learning models are typically composed of neural networks to approximate the policy function (i.e., the probability distribution of choosing an action given a state) and the value function (i.e., the estimate of future rewards). A trained deep reinforcement learning model can adjust resource allocation based on the dynamic environment and optimize long-term goals.
[0163] Elastic resource scheduling refers to dynamically adjusting the computing resources (such as CPU, memory, storage, etc.) allocated to each microservice based on the real-time status and load changes of the microservice system, in order to meet the system's performance requirements and improve resource utilization. When the system load increases, the number of microservice instances is automatically increased or more resources are allocated; when the system load decreases, the number of instances is reduced or excess resources are released, thereby achieving elastic scaling of resources.
[0164] In this embodiment of the invention, a fast initial solution is provided through near-end optimization, and combined with the dynamic adjustment capability of DRL, efficient and adaptive microservice resource scheduling can be achieved.
[0165] In some embodiments, step 140 specifically includes:
[0166] Step 141: Obtain the current state of the microservice system. The current state includes the remaining memory and CPU information of each server, the microservice information already deployed on each server, and the historical information of microservice requests.
[0167] Step 142: Extract the state features of the current state based on the deep neural network in the deep reinforcement learning model;
[0168] Step 143: Based on the policy network and state features in the deep reinforcement learning model, optimize the initial solution for dynamically changing requests to obtain the optimization result, which includes the changes in the number of target servers, target microservice instances, and target microservice instances.
[0169] Specifically, the deep reinforcement learning model is an Actor-Critic structure, mainly consisting of a deep neural network (DNN), a policy network (actor), and a value network (critic). The DNN employs a multi-layer Tanh-activated fully connected network to process the input environmental state features. The policy network (actor) determines the action to be executed through the outputs of three parallel heads: the server selection (s), the microservice type selection (m), and the selection of the number of microservices to increase or decrease. This three-headed output transforms the action space from a product-based form to an additive form, significantly reducing the action space and greatly improving the algorithm's efficiency while ensuring stable convergence. The value network (critic) outputs a scalar representing the value function V(s) of the current state. The algorithm calculates the response based on predicted load changes in the previous time slot and quickly adjusts at the beginning of the next time slot, reflecting real-world conditions.
[0170] The environment and action design for this algorithm are as follows:
[0171] State: The state that the reinforcement learning model needs to perceive mainly includes the current data center network state (including the remaining memory and CPU information of each server), the information of the deployed microservices, and the historical information of the microservice chain requests received by the data center. The state space can be specifically represented as:
[0172]
[0173] in This represents the remaining memory information of each server in a microservice system. This represents the remaining CPU information for each server in the microservice system. This represents information about the microservices deployed on each server in a microservice system. Specifically, it includes the types and quantities of microservices deployed on each server. This represents historical information about microservice chain requests received by the data center. This information is used to predict the arrival status of microservice requests in the next time slot so that adjustments can be made in advance.
[0174] Action: The action space design is as follows:
[0175]
[0176] in, This represents the server selected by the strategy, i.e., which server to operate on. This represents the type of microservice selected. This represents a change in the number of microservices. Therefore, "action" represents an action... On the server The number of microservices is The increase or decrease of.
[0177] In this embodiment, the current state of the microservice system is first obtained, and then input into the deep neural network of the deep reinforcement learning model to extract state features. These state features are then input into the policy network of the deep reinforcement learning model, and the policy network outputs the optimized execution action, thus obtaining the optimization result for the current time slot. Here, the target server refers to the server selected by the policy, the target microservice instance refers to the selected microservice instance, and the change in the number of target microservice instances refers to the addition or removal of target microservice instances on the target server.
[0178] Based on the above embodiments, the reward function of the deep reinforcement learning model is determined based on the backlog of the virtual queue at the end of the current time slot, the total cost in the current time slot, and the average request latency of the microservice system in the current time slot.
[0179] Specifically, this embodiment uses a reward function design strategy that combines reward and risk avoidance. This allows the agent to focus more on optimizing the objective and discovering potential optimal solutions, while simultaneously avoiding erroneous actions through risk avoidance. The reward is designed based on the results of Lyapunov optimization as follows:
[0180]
[0181] Additionally, the execution of an action is prohibited when the agent performs the following actions:
[0182] a. When an agent wants to add a certain microservice instance to a server, it exceeds the server's memory and CPU limits. Instead, it adds the maximum number of such microservice instances while not exceeding the server's resource limits.
[0183] b. If an agent wants to reduce the number of instances of a certain microservice on a server, but there are no instances of that microservice on that server, then the action will be canceled.
[0184] Based on the above embodiments, the deep reinforcement learning model can be pre-trained before performing step 140. The training steps include:
[0185] Candidate actions are obtained based on the state features of the current time step and the initial policy network. The candidate actions are sampled to obtain the action to be executed, and the reward for the current time step is calculated.
[0186] Based on the state characteristics and initial value network at the current time step, the value function at the current time step is obtained;
[0187] The advantage function is determined based on the reward at the current time step, and the reward at the current time step is determined based on the advantage function and the value function.
[0188] Based on the advantage function, value function, and reward at the current time step, determine the policy loss, value loss, and entropy loss respectively, and determine the total loss based on the policy loss, value loss, and entropy loss;
[0189] Based on the total loss, the parameters of the initial policy network and the initial value network are iterated to obtain a deep reinforcement learning model.
[0190] Specifically, Figure 3 This is a schematic diagram of the training structure of the deep reinforcement learning model provided by the present invention, with reference to... Figure 3 The agent is trained by interacting with the microservice environment, causing it to converge on the reward function. The agent then adjusts its state based on the conditions it receives from the environment. The initial policy network outputs possible actions, i.e., candidate actions. The execution action is then obtained by sampling these candidate actions. Simultaneously, the value function is output through the initial value network. After the action is executed, a new state is obtained. and rewards .
[0191] At the end of each training cycle, generalized advantage estimation (GAE) is used to calculate the advantage function for each step. The advantage function indicates the advantage of the action chosen by the agent relative to the remaining choices. Solve it using the recursive formula:
[0192]
[0193] in, It is a discount factor. It is the attenuation factor of GAE. This is the TD error, calculated as follows:
[0194]
[0195] This allows us to calculate the return. :
[0196]
[0197] In this embodiment, in order to balance the exploratory nature and stability of the algorithm, the calculation of loss mainly includes three parts: strategy loss, value loss, and entropy loss.
[0198] The policy loss is used to optimize the initial policy network and is calculated as follows:
[0199]
[0200] in It is the importance sampling ratio, which measures the difference between the current policy and the old policy. The clip function is used to limit instability caused by excessive policy updates. It is a hyperparameter (usually with a small value, such as 0.1 or 0.2) that controls the magnitude of policy updates.
[0201] Entropy loss is used to encourage exploratory strategies and prevent the model from getting trapped in local optima. The specific calculation is as follows:
[0202]
[0203] The value loss is used to update the initial value network. It is calculated using mean squared error (MSE) and measures the difference between the current extreme network estimate and the actual return. The specific calculation is as follows:
[0204]
[0205] The total loss can be obtained as follows, where The total loss can be expressed as follows, corresponding to the coefficients of the three losses:
[0206]
[0207] Based on this, the obtained total loss is used for gradient backpropagation and the network parameters are updated to obtain the trained deep reinforcement learning model.
[0208] Based on any of the above embodiments, before determining the microservice system to be scheduled, the method further includes performing an initial deployment of the microservice using a first-fit decrement algorithm, wherein the initial deployment specifically includes:
[0209] Sort the microservices according to their resource requirements and prioritize deploying the microservices with higher resource requirements;
[0210] Based on the total arrival rate of various microservices in all request streams, determine the number of instances required for each microservice.
[0211] Iterate through each server and, based on the maximum number of microservice instances each server can support, deploy all instances required by various microservices onto the servers.
[0212] Specifically, the initial deployment of a microservice system can be achieved using the first-fit decay algorithm. The algorithm steps are as follows:
[0213] Step 1: Sort the microservices according to their resource requirements. Specifically, arrange them in descending order of CPU and memory requirements. This prioritizes the deployment of microservices with higher resource requirements, as they consume more resources and should therefore be processed first to better match node resources.
[0214] Step 2: Calculate the overall arrival rate of various microservices across all request flows. This is to ensure service strength. First, calculate the number of instances required for each microservice, and then deploy the required number of instances of that microservice to the server.
[0215] Step 3: Iterate through each server and calculate the maximum number of microservice instances that the current server can support. If the current server has sufficient resources, deploy the microservice instance to that server and update the server status. If the current server cannot fully deploy all instances of the microservice, calculate the remaining number of instances after the server is fully deployed, and deploy the remaining instances to other servers. This process will continue until all instances of the microservice are deployed, or there are not enough resources to deploy more instances.
[0216] In summary, this invention applies an open queuing network model to model the microservice system and, based on Liyapunov theory, transforms the long-term stability problem of microservice deployment cost and latency into an optimization problem within a single time slot. The first-adaptive decreasing algorithm is used for the initial deployment, while a novel reinforcement learning algorithm is designed to scale and migrate microservice instances based on dynamic request arrival rates, thereby achieving multi-objective optimization of microservice scaling and migration costs and user request latency.
[0217] The elastic resource scheduling device for microservices provided by the present invention is described below. The elastic resource scheduling device for microservices described below can be referred to in correspondence with the elastic resource scheduling method for microservices described above.
[0218] Based on the above embodiments, Figure 4 This is a schematic diagram of the microservice elastic resource scheduling device provided by the present invention, as shown below. Figure 4 As shown, the device includes:
[0219] The microservice system determination unit 410 is used to determine the microservice system to be scheduled, wherein the microservice system includes a server and microservice instances deployed on the server;
[0220] The long-term model building unit 420 is used to build a long-term scheduling optimization model with the goal of minimizing the long-term average request latency of the microservice system. The constraints of the long-term scheduling optimization model include the long-term total overhead constraints of the microservice system, the memory and CPU resource constraints of each server.
[0221] The time slot model construction unit 430 is used to transform the long-term scheduling optimization model into a time slot scheduling optimization model within each time slot based on the Lyapunov optimization method. The constraints of the time slot scheduling optimization model include memory and CPU resource constraints for each server.
[0222] The optimization scheduling unit 440 is used to obtain the initial solution of the optimization model based on the near-end optimization strategy, and then optimize the initial solution for dynamically changing requests through a pre-trained deep reinforcement learning model, and perform elastic resource scheduling of microservices based on the optimization results.
[0223] Based on the above embodiments, the optimized scheduling unit is specifically used for:
[0224] Obtain the current state of the microservice system, which includes the remaining memory and CPU information of each server, the microservice information already deployed on each server, and the historical information of microservice requests;
[0225] Based on the deep neural network in the deep reinforcement learning model, extract the state features of the current state;
[0226] Based on the policy network in the deep reinforcement learning model and the state features, the initial solution is optimized for dynamically changing requests to obtain an optimization result, which includes changes in the target server, the target microservice instance, and the number of the target microservice instances.
[0227] Based on the above embodiments, the reward function of the deep reinforcement learning model is determined based on the backlog of the virtual queue at the end of the current time slot, the total cost in the current time slot, and the average request latency of the microservice system in the current time slot.
[0228] Based on the above embodiments, the time slot model construction unit is specifically used for:
[0229] The upper boundary of Lyapunov drift is determined based on the number of microservice instances, the number of servers, the number of microservice instance changes, the number of server changes, and the difference between the total overhead and the overhead budget in each time slot.
[0230] Based on the upper boundary of the Lyapunov drift, the backlog of the virtual queue at the end of each time slot, and the average request latency of the microservice system in each time slot, the upper boundary of the Lyapunov drift plus penalty function in each time slot is determined.
[0231] Based on the upper boundary of the Lyapunov drift plus penalty function in each time slot, the optimization objective of the time slot scheduling optimization model in each time slot is determined.
[0232] Based on the above embodiments, the time slot model construction unit is specifically used for:
[0233] Based on the total number of microservice instances in each time slot, the resources required for a single microservice instance to run, the total number of servers in each time slot, and the resources required for a single server to run, the deployment overhead in each time slot is determined.
[0234] Based on the number of microservice instances that need to be changed in each time slot, the resource overhead of deploying or deleting a single microservice instance, the number of servers that need to be changed in each time slot, and the resource overhead of opening or closing a single server, determine the scaling overhead in each time slot.
[0235] The total cost within each time slot is determined based on the deployment cost and scaling cost within each time slot.
[0236] Based on the above embodiments, the long-term model building unit is specifically used for:
[0237] Based on the average number of requests waiting at each microservice instance in any request flow and the request arrival rate of each microservice instance, the average waiting latency of the request flow on any routing path is determined.
[0238] Based on the request processing capabilities of each microservice instance, determine the average processing latency of any request flow on any routing path;
[0239] The average communication latency of any request flow on any routing path is determined based on whether the predecessor microservice instance of each microservice instance on the routing path is on the same server as it.
[0240] The long-term average request latency of the microservice system is determined based on the importance weight of each request flow, the probability weight of each routing path, the average waiting latency, the average processing latency, and the average communication latency.
[0241] Based on the above embodiments, the device further includes an initial deployment unit, specifically used for:
[0242] Sort the microservices according to their resource requirements and prioritize deploying the microservices with higher resource requirements;
[0243] Based on the total arrival rate of various microservices in all request streams, determine the number of instances required for each microservice.
[0244] Iterate through each server and, based on the maximum number of microservice instances each server can host, deploy all instances required for each type of microservice onto the server.
[0245] Based on the above embodiments, the device further includes a model training unit, specifically used for:
[0246] Candidate actions are obtained based on the state features of the current time step and the initial policy network. The candidate actions are sampled to obtain the action to be executed, and the reward for the current time step is calculated.
[0247] Based on the state characteristics and initial value network at the current time step, the value function at the current time step is obtained;
[0248] The advantage function is determined based on the reward at the current time step, and the reward at the current time step is determined based on the advantage function and the value function.
[0249] Based on the advantage function, value function, and reward at the current time step, the strategy loss, value loss, and entropy loss are determined respectively, and the total loss is determined based on the strategy loss, value loss, and entropy loss.
[0250] Based on the total loss, the parameters of the initial policy network and the initial value network are iterated to obtain the deep reinforcement learning model.
[0251] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530, and a communications bus 540, wherein the processor 510, the communications interface 520, and the memory 530 communicate with each other through the communications bus 540. Processor 510 can invoke logical instructions in memory 530 to execute a microservice elastic resource scheduling method. This method includes: determining a microservice system to be scheduled, the microservice system including servers and microservice instances deployed on the servers; constructing a long-term scheduling optimization model with the goal of minimizing the long-term average request latency of the microservice system, the constraints of which include long-term total overhead constraints, memory and CPU resource constraints for each server; transforming the long-term scheduling optimization model into a time-slot scheduling optimization model based on a Lyapunov optimization method, the constraints of which include memory and CPU resource constraints for each server; optimizing the time-slot scheduling optimization model based on the current state of the microservice system using a pre-trained deep reinforcement learning model based on near-end policy optimization; and performing elastic resource scheduling of the microservice based on the optimization results.
[0252] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0253] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the elastic resource scheduling method for microservices provided by the above methods. The method includes: determining a microservice system to be scheduled, the microservice system including servers and microservice instances deployed on the servers; constructing a long-term scheduling optimization model with the goal of minimizing the long-term average request latency of the microservice system, the constraints of the long-term scheduling optimization model including the long-term total overhead constraint of the microservice system, the memory and CPU resource constraints of each server; transforming the long-term scheduling optimization model into a time-slot scheduling optimization model based on the Lyapunov optimization method, the constraints of the time-slot scheduling optimization model including the memory and CPU resource constraints of each server; optimizing the time-slot scheduling optimization model based on the current state of the microservice system using a pre-trained deep reinforcement learning model based on proximal policy optimization, and performing elastic resource scheduling of the microservices based on the optimization results.
[0254] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements an elastic resource scheduling method for microservices provided by the methods described above. The method includes: determining a microservice system to be scheduled, the microservice system including servers and microservice instances deployed on the servers; constructing a long-term scheduling optimization model with the objective of minimizing the long-term average request latency of the microservice system, the constraints of which include long-term total overhead constraints of the microservice system, memory and CPU resource constraints for each server; transforming the long-term scheduling optimization model into a time-slot scheduling optimization model based on a Lyapunov optimization method, the constraints of which include memory and CPU resource constraints for each server; optimizing the time-slot scheduling optimization model based on the current state of the microservice system using a pre-trained deep reinforcement learning model based on proximal policy optimization; and performing elastic resource scheduling of the microservices based on the optimization results.
[0255] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0256] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, 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 can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0257] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for elastic resource scheduling of microservices, characterized in that, The application comprises the following steps: determining a micro-service system to be scheduled, the micro-service system comprising servers and micro-service instances deployed on the servers; constructing a long-term scheduling optimization model with the objective of minimizing the long-term average request latency of the micro-service system, the constraint conditions of the long-term scheduling optimization model comprising a long-term total cost constraint of the micro-service system, memory and central processing unit (CPU) resource constraints of each server; transforming the long-term scheduling optimization model into a time-slot scheduling optimization model in each time slot based on a Lyapunov optimization method, the constraint conditions of the time-slot scheduling optimization model comprising the memory and CPU resource constraints of each server; obtaining an initial solution of the optimization model based on a proximal optimization strategy, and then optimizing the initial solution for dynamic changes in requests by using a pre-trained deep reinforcement learning model, and performing elastic resource scheduling of micro-services based on the optimization result; the step of transforming the long-term scheduling optimization model into a time-slot scheduling optimization model in each time slot based on the Lyapunov optimization method comprises the following steps: determining an upper bound of Lyapunov drift based on the number of micro-service instances in each time slot, the number of servers, the number of changes in micro-service instances and the number of changes in servers, and the difference between the total cost in each time slot and the cost budget; determining an upper bound of Lyapunov drift plus a penalty function in each time slot based on the upper bound of Lyapunov drift, the backlog of a virtual queue at the end of each time slot, and the average request latency of the micro-service system in each time slot; determining an optimization objective of the time-slot scheduling optimization model in each time slot based on the upper bound of Lyapunov drift plus the penalty function in each time slot.
2. The method of claim 1, wherein, the step of optimizing the initial solution for dynamic changes in requests by using the pre-trained deep reinforcement learning model comprises the following steps: obtaining a current state of the micro-service system, the current state comprising the remaining memory and CPU information of each server, the micro-service information already deployed on each server, and the historical information of micro-service requests; extracting state features of the current state based on a deep neural network in the deep reinforcement learning model; optimizing the initial solution for dynamic changes in requests based on a policy network in the deep reinforcement learning model and the state features to obtain an optimization result, the optimization result comprising target servers, target micro-service instances, and the number of changes in the target micro-service instances.
3. The method of claim 2, wherein, a reward function of the deep reinforcement learning model is determined based on the backlog of the virtual queue at the end of the current time slot, the total cost in the current time slot, and the average request latency of the micro-service system in the current time slot.
4. The method of claim 1, wherein, the total cost in each time slot is determined based on the following steps: determining a deployment cost in each time slot based on the total number of micro-service instances in each time slot, the resources required for running a single micro-service instance, the total number of servers in each time slot, and the resources required for running a single server. determine a scaling overhead in each time slot based on a number of microservice instances that need to be changed in each time slot, a resource overhead of deploying or deleting a single microservice instance, a number of servers that need to be changed in each time slot, and a resource overhead of turning on or off a single server; determine a total overhead in each time slot based on the deployment overhead and the scaling overhead in each time slot.
5. The method of claim 1, wherein, determine a long-term average request latency of the microservice system based on the following steps: determine an average waiting latency of any request stream in any routing path based on an average number of requests waiting at each microservice instance and a request arrival rate of each microservice instance; determine an average processing latency of the any request stream in any routing path based on a processing capacity of each microservice instance; determine an average communication latency of the any request stream in any routing path based on whether a predecessor microservice instance of each microservice instance on a routing path is on the same server as the microservice instance; determine the long-term average request latency of the microservice system based on an importance weight of each request stream, a probability weight of each routing path, the average waiting latency, the average processing latency, and the average communication latency.
6. The method of claim 1 to 5, wherein, Before the determining the microservice system to be scheduled, the method further comprises performing an initial deployment of microservices by a first-fit decreasing algorithm, and the initial deployment specifically comprises: sorting the microservices according to resource requirements of the microservices, and preferentially deploying microservices with larger resource requirements; determining a required number of instances of each microservice based on a total arrival rate of the microservice in all request streams; deploying all instances of each microservice on servers based on a maximum number of microservice instances that each server can carry.
7. The method of claim 1 to 5, wherein, The training steps of the deep reinforcement learning model comprise: obtaining candidate actions based on state features of a current time step and an initial policy network, sampling the candidate actions to obtain executed actions, and calculating a reward of the current time step; obtaining a value function of the current time step based on the state features of the current time step and an initial value network; determining an advantage function based on the reward of the current time step, and determining a return of the current time step based on the advantage function and the value function; determining a policy loss, a value loss, and an entropy loss based on the advantage function, the value function, and the return of the current time step, and determining a total loss based on the policy loss, the value loss, and the entropy loss; performing parameter iteration on the initial policy network and the initial value network based on the total loss to obtain the deep reinforcement learning model.
8. An elastic resource scheduling device for microservices, characterized in that, comprise: a microservice system determination unit configured to determine a microservice system to be scheduled, the microservice system comprising servers and microservice instances deployed on the servers; a long-term model construction unit configured to construct a long-term scheduling optimization model with a goal of minimizing a long-term average request latency of the microservice system, and the constraint conditions of the long-term scheduling optimization model comprising a long-term total overhead constraint of the microservice system and a memory and central processing unit (CPU) resource constraint of each server; a time slot model construction unit, configured to convert the long-term scheduling optimization model into a time slot scheduling optimization model in each time slot based on a Lyapunov optimization method, and a constraint condition of the time slot scheduling optimization model includes memory and central processing unit (CPU) resource constraints of each server; an optimization scheduling unit, configured to obtain an initial solution of the optimization model based on a proximal optimization strategy, and then optimize the initial solution for dynamic changes in requests by using a pre-trained deep reinforcement learning model, and perform elastic resource scheduling of the microservice based on an optimization result; the time slot model construction unit is specifically configured to: determine an upper boundary of Lyapunov drift based on a number of microservice instances, a number of servers, a number of microservice instance changes, and a number of server changes in each time slot, and a difference between total overhead and an overhead budget in each time slot; determine an upper boundary of a Lyapunov drift plus penalty function in each time slot based on the upper boundary of the Lyapunov drift, an accumulated amount of a virtual queue at the end of each time slot, and an average request delay of the microservice system in each time slot; determine an optimization objective of the time slot scheduling optimization model in each time slot based on the upper boundary of the Lyapunov drift plus penalty function in each time slot.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, The processor implements the elastic resource scheduling method of the microservice when executing the computer program.
Citation Information
Patent Citations
Resource joint scheduling method and system facing edge cloud fusion industrial Internet, and server
CN120568478A
Mixed heterogeneous cloud workflow scheduling method based on reinforcement learning
CN120578476A