Microservice Scheduling Method, Device, Equipment and Storage Medium under k8s Cluster

By building a dynamic microservice topology relationship diagram and comprehensively evaluating candidate nodes, the problem that the traditional k8s cluster scheduling mechanism cannot meet the overall performance balance of the system under the microservice architecture is solved, and a scheduling solution with the best resource load balancing and communication performance is realized.

CN119892905BActive Publication Date: 2025-07-29CHINA TELECOM CLOUD TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510371571.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-27
Publication Date
2025-07-29
Estimated Expiration
2045-03-27

AI Technical Summary

Technical Problem

The traditional k8s cluster scheduling mechanism cannot meet the balanced needs of the overall performance of the system under the microservice architecture, especially under the influence of the complex call relationship between microservices and the dynamic network conditions, it cannot optimize resource utilization and communication performance.

Method used

By collecting data from k8s cluster nodes and microservice instances, a dynamic microservice topology relationship diagram is constructed, and the node resource utilization rate, microservice communication network cost and communication performance are comprehensively considered, candidate nodes are evaluated from multiple dimensions, and target nodes are selected for scheduling.

Benefits of technology

The microservice scheduling strategy has been optimized, node resource load balancing and microservice communication costs have been minimized, and communication performance has been improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119892905B_ABST
    Figure CN119892905B_ABST
Patent Text Reader

Abstract

The present application relates to a microservice scheduling method, apparatus, device, and storage medium under a k8s cluster. The method includes: collecting node data of each node under the k8s cluster and service traffic data of each microservice instance; constructing a dynamic microservice topology relationship graph according to the service traffic data; wherein, the dynamic microservice topology relationship graph includes: microservice nodes, call links, and link traffic information and link weight information; based on the dynamic microservice topology relationship graph and the node data, evaluating candidate nodes from multiple dimensions, and screening to obtain target nodes; scheduling microservice pods to the target nodes. Thus, it is possible to comprehensively consider the resource utilization rate of the server and the network topology structure between microservices, greatly optimize the microservice scheduling strategy, and obtain a scheduling scheme that not only conforms to the node resource load balancing but also minimizes the communication cost between microservices and has the best communication performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of cloud computing technology, and in particular, to a microservice scheduling method, device, computer device, computer-readable storage medium, and computer program product under a k8s cluster. Background Art

[0002] With the wide application of the distributed microservice architecture in the Kubernetes cluster, higher requirements are put forward for the quality of service QoS. In the Kubernetes cluster, a pod is the basis for all business types and the smallest unit level managed by k8s. It is a combination of one or more containers. These containers share storage, network, and namespace, as well as the specifications for how to run. In a pod, all containers are uniformly arranged and scheduled and run in a shared context.

[0003] In traditional technologies, the k8s cluster scheduling mechanism mainly considers the resource utilization rate of nodes (central processing unit, memory, etc.) and the resource requirements of individual applications.

[0004] However, in the microservice architecture, the call relationships between services are intricate, and the diversity, dynamics of the call chain, and the network conditions of the servers will all affect the overall performance of the system. Therefore, the traditional k8s cluster scheduling mechanism cannot meet the balanced requirements of the overall system performance. Summary of the Invention

[0005] Based on this, in view of the above technical problems, it is necessary to provide a microservice scheduling method, device, computer device, computer-readable storage medium, and computer program product under a k8s cluster that can dynamically construct the microservice call topology relationship and optimize the system service performance from multiple dimensions.

[0006] In a first aspect, this application provides a microservice scheduling method under a k8s cluster, including:

[0007] Collect node data of each node under the k8s cluster and service traffic data of each microservice instance;

[0008] According to the service traffic data, construct a dynamic microservice topology relationship graph; wherein, the dynamic microservice topology relationship graph includes: microservice nodes, call chains, as well as link traffic information and link weight information;

[0009] Based on the dynamic microservice topology relationship graph and the node data, evaluate candidate nodes from multiple dimensions, and filter to obtain target nodes;

[0010] Schedule the microservice pod to the target node.

[0011] In one embodiment, collecting node data of each node in the k8s cluster and service traffic data of each microservice instance includes:

[0012] Collecting node data of each node in the k8s cluster according to a preset time period; the node data includes: resource usage data, network data;

[0013] Tracking and capturing service traffic data of each microservice instance; the service traffic data includes at least one of: request ID, trace ID, source service name, target service name, request duration.

[0014] In one embodiment, constructing a dynamic microservice topology relationship graph according to the service traffic data includes:

[0015] Aggregating and analyzing the service traffic data to obtain call links between multiple microservice nodes and microservice nodes;

[0016] Constructing a topology relationship of microservices according to the microservice nodes and the call links;

[0017] In the topology relationship of the microservices, adding link traffic information and link weight information to obtain a dynamic microservice topology relationship graph; wherein, the link traffic information is calculated according to the integral of the total traffic of the microservices at both ends of the link within a sliding window time, and the calculation method of the link weight information includes at least one of the following:

[0018] Calculated according to the call frequency of the microservices at both ends of the link within a given time;

[0019] Calculated according to the callback frequency of the microservices at both ends of the link within a given time;

[0020] Calculated by comprehensively considering an empirical coefficient according to the service importance.

[0021] In one embodiment, evaluating candidate nodes from multiple dimensions based on the dynamic microservice topology relationship graph and the node data, and screening out target nodes includes:

[0022] When there are microservice pods to be scheduled in the scheduling queue, determining at least two candidate nodes based on the dynamic microservice topology relationship graph;

[0023] Evaluating each candidate node from the dimensions of node resource utilization rate, microservice communication network cost dimension, and communication performance dimension according to the node data to obtain an evaluation result;

[0024] Based on the evaluation result, screening out target nodes from the candidate nodes.

[0025] In one embodiment, each candidate node is evaluated from the dimensions of node resource utilization, microservice communication network cost, and communication performance to obtain an evaluation result, including:

[0026] Respectively establish a node resource utilization evaluation function, a microservice communication network cost evaluation function, and a communication performance evaluation function;

[0027] Convert the solution problems of the node resource utilization evaluation function, the microservice communication network cost evaluation function, and the communication performance evaluation function into a multi-objective optimization problem to obtain an objective function;

[0028] Based on the objective function, each candidate node is evaluated to obtain an evaluation result.

[0029] In one embodiment, after scheduling the microservice pod to the target node, the method further includes:

[0030] Determine whether the microservice pod is successfully scheduled;

[0031] If the scheduling is successful, end the process;

[0032] If the scheduling is not successful, add the microservice pod back to the scheduling queue.

[0033] In a second aspect, the present application also provides a microservice scheduling device under a k8s cluster, and the device includes:

[0034] A data collection module, configured to collect node data of each node under the k8s cluster and service traffic data of each microservice instance;

[0035] A topology awareness module, configured to construct a dynamic microservice topology relationship graph according to the service traffic data; wherein, the dynamic microservice topology relationship graph includes: microservice nodes, call links, and link traffic information and link weight information;

[0036] A scheduler extension module, configured to evaluate candidate nodes from multiple dimensions based on the dynamic microservice topology relationship graph and the node data, and screen out a target node;

[0037] A scheduling module, configured to schedule the microservice pod to the target node.

[0038] In a third aspect, the present application also provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0039] Collect node data of each node under the k8s cluster and service traffic data of each microservice instance;

[0040] Construct a dynamic microservice topology relationship graph according to the service traffic data; wherein, the dynamic microservice topology relationship graph includes: microservice nodes, call links, and link traffic information and link weight information;

[0041] Evaluate candidate nodes from multiple dimensions based on the dynamic microservice topology relationship graph and the node data, and filter out the target nodes;

[0042] Schedule the microservice pod to the target node.

[0043] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0044] Collect node data of each node in the k8s cluster and service traffic data of each microservice instance;

[0045] Construct a dynamic microservice topology relationship graph according to the service traffic data; wherein, the dynamic microservice topology relationship graph includes: microservice nodes, call links, and link traffic information and link weight information;

[0046] Evaluate candidate nodes from multiple dimensions based on the dynamic microservice topology relationship graph and the node data, and filter out the target nodes;

[0047] Schedule the microservice pod to the target node.

[0048] In a fifth aspect, the present application further provides a computer program product, including a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0049] Collect node data of each node in the k8s cluster and service traffic data of each microservice instance;

[0050] Construct a dynamic microservice topology relationship graph according to the service traffic data; wherein, the dynamic microservice topology relationship graph includes: microservice nodes, call links, and link traffic information and link weight information;

[0051] Evaluate candidate nodes from multiple dimensions based on the dynamic microservice topology relationship graph and the node data, and filter out the target nodes;

[0052] Schedule the microservice pod to the target node.

[0053] The microservice scheduling method, device, computer equipment, computer-readable storage medium, and computer program product under the above-mentioned k8s cluster collect node data of each node and service traffic data of each microservice instance under the k8s cluster; construct a dynamic microservice topology relationship graph according to the service traffic data; wherein, the dynamic microservice topology relationship graph includes: microservice nodes, call links, and link traffic information and link weight information; thus, the resource utilization rate and network performance of the microservice pod can be obtained in a timely manner, and a dynamic microservice topology relationship graph that changes with the call situation of the microservice instance can be constructed. Based on the dynamic microservice topology relationship graph and the node data, candidate nodes are evaluated from multiple dimensions, and target nodes are selected; the microservice pod is scheduled to the target nodes. Therefore, it is possible to comprehensively consider the resource utilization rate of the server and the network topology structure between microservices, greatly optimize the microservice scheduling strategy, and obtain a scheduling scheme that not only meets the node resource load balance but also minimizes the communication cost between microservices and has the best communication performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for describing the embodiments of the present application or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0055] Figure 1 It is a schematic diagram of the architecture of the k8s cluster in one embodiment;

[0056] Figure 2 It is a schematic flowchart of the microservice scheduling method under the k8s cluster in one embodiment;

[0057] Figure 3 It is a schematic diagram of the microservice call topology structure in one embodiment;

[0058] Figure 4 It is a schematic flowchart of the microservice scheduling method under the k8s cluster in another embodiment;

[0059] Figure 5 It is a schematic flowchart of the microservice scheduling method under the k8s cluster in still another embodiment;

[0060] Figure 6 It is a block diagram of the structure of the microservice scheduling device under the k8s cluster in one embodiment;

[0061] Figure 7 It is a block diagram of the structure of the microservice scheduling device under the k8s cluster in another embodiment;

[0062] Figure 8 It is a schematic diagram of the architecture of a microservice scheduling system under a k8s cluster in an embodiment;

[0063] Figure 9 It is the internal structure diagram of a computer device in an embodiment. Specific embodiments

[0064] In order to make the purpose, technical solutions and advantages of the present application clearer, the following further details the present application in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0065] Exemplarily, Figure 1 It is a schematic diagram of the architecture of a k8s cluster in an embodiment. As Figure 1 shown, the k8s cluster may include: a master node 10 and worker nodes 11. Among them, the master node 10 may include an application programming interface service (kube-apiserver) and a distributed key-value pair storage system (for example: etcd pod). Etcd is used to store data and notify the cluster of running changes in the k8s cluster. The worker node 11 may include a kubelet component, a kube-proxy process, and a pod object. At least one container is included in the pod, and this container is used to run an application process. The kube-proxy process can run on each worker node and can also be used to be responsible for the connection and forwarding of the entire network rules. For example, it can be used to be responsible for the virtual IP service of the service component in the k8s cluster. Among them, the master node 10 can be a physical machine or a virtual machine, and the worker node 11 can be a physical machine or a virtual machine. Optionally, the physical machine can be a computing device or a server, such as a general server, a Graphics Processing Unit (GPU) server, a Data Processing Unit (DPU) server, or an Artificial Intelligence (AI) server, etc.

[0066] In an exemplary embodiment, as Figure 2 shown, a microservice scheduling method under a k8s cluster is provided. Taking the k8s cluster in Figure 1 as an example for description, it includes the following steps 201 to step 204. Among them:

[0067] Step 201, collect the node data of each node under the k8s cluster and the service traffic data of each microservice instance.

[0068] In this embodiment, data collectors deployed on each node of the k8s cluster can collect node data of each node according to a preset time period.

[0069] Among them, the node data includes: resource usage data and network data.

[0070] Exemplarily, the resource usage data (CPU, memory, etc.) and network conditions (bandwidth, latency, packet loss rate, jitter, etc.) of each node can be collected regularly and stored in the time series database in the form of Prometheus metrics.

[0071] Among them, the service traffic data of the micro-service instances includes: call information of each micro-service instance. For example: at least one of request ID, trace ID, source service name, target service name, request duration, etc.

[0072] Exemplarily, traffic tracing of micro-service instances can be implemented based on the Envoy proxy of the Istio framework. Optionally, the service traffic collector is injected into the micro-service pod in the form of a sidecar to trace and capture the call information of each micro-service instance.

[0073] Step 202, construct a dynamic micro-service topology relationship graph according to the service traffic data.

[0074] In this embodiment, the micro-service topology relationship graph shows the scheduling relationship between micro-service nodes. Among them, the dynamic micro-service topology relationship graph includes: micro-service nodes, call links, and link traffic information and link weight information.

[0075] In this embodiment, after obtaining the service traffic data, the service traffic data is aggregated and analyzed to obtain multiple micro-service nodes and call links between the micro-service nodes; according to the micro-service nodes and the call links, the topology relationship of the micro-service is constructed; in the topology relationship of the micro-service, link traffic information and link weight information are added to obtain a dynamic micro-service topology relationship graph.

[0076] Among them, the dynamic micro-service topology relationship graph means that as time goes by (each collection period), a new micro-service topology relationship graph will be continuously generated according to the latest collected service traffic data; that is, the micro-service topology relationship is not static. In a possible case, even if the micro-service nodes and call links do not change, the link traffic information and link weight information of each link will change.

[0077] Optionally, the link traffic information is calculated according to the integral of the total traffic of the micro-services at both ends of the link within the sliding window time.

[0078] Optionally, the calculation method of the link weight information includes at least one of the following:

[0079] Calculated based on the microservice call frequency at both ends of the link within a given time;

[0080] Calculated based on the microservice callback frequency at both ends of the link within a given time;

[0081] Calculated comprehensively by adding an empirical coefficient according to the service importance.

[0082] Exemplarily, a service traffic collector can be injected into the microservice pod, and then based on the development of the distributed tracing system Jaeger, the function of constructing a dynamic microservice topology relationship graph can be realized.

[0083] Optionally, the data reported by the service traffic collector is aggregated, analyzed, and stored in the database after constructing a dynamic microservice topology relationship graph.

[0084] Exemplarily, a schematic diagram of a microservice call topology structure is provided. As Figure 3 shown, taking microservice node A and microservice node B as examples, the total traffic of microservices at both ends (A, B) of the link within the sliding window time is integrated to obtain the link traffic <A, B>. According to the microservice call frequency / callback frequency at both ends (A, B) of the link within a given time, or the service importance, an empirical coefficient is added to comprehensively calculate the link weight <A, B>. Similarly, the link traffic <B, D> represents the link traffic at both ends of the link between microservice node B and microservice node D within the sliding window time, and the link weight <B, D> represents the link weight at both ends of the link between microservice node B and microservice node D within a given time. The link traffic <B, C> represents the link traffic at both ends of the link between microservice node B and microservice node C within the sliding window time, and the link weight <B, C> represents the link weight at both ends of the link between microservice node B and microservice node C within a given time. The link traffic <B, E> represents the link traffic at both ends of the link between microservice node B and microservice node E within the sliding window time, and the link weight <B, E> represents the link weight at both ends of the link between microservice node B and microservice node E within a given time. The link traffic <A, C> represents the link traffic at both ends of the link between microservice node A and microservice node C within the sliding window time, and the link weight <A, C> represents the link weight at both ends of the link between microservice node A and microservice node C within a given time.

[0085] Step 203: Based on the dynamic microservice topology relationship graph and node data, evaluate the candidate nodes from multiple dimensions and screen out the target nodes.

[0086] In this embodiment, the microservice pod to be scheduled can be added to the scheduling queue, and the pods are scheduled according to the order in the scheduling queue.

[0087] Exemplarily, in the case that there are microservice pods to be scheduled in the scheduling queue, based on the dynamic microservice topology relationship graph, at least two candidate nodes are determined; according to the node data, each candidate node is evaluated from the dimensions of node resource utilization rate, microservice communication network cost, and communication performance to obtain an evaluation result; based on the evaluation result, a target node is selected from the candidate nodes.

[0088] Optionally, an evaluation function for node resource utilization rate, an evaluation function for microservice communication network cost, and an evaluation function for communication performance are respectively established; the solution problems of the evaluation function for node resource utilization rate, the evaluation function for microservice communication network cost, and the evaluation function for communication performance are transformed into a multi-objective optimization problem to obtain an objective function; based on the objective function, each candidate node is evaluated to obtain an evaluation result. Thus, the microservice nodes can be evaluated from three aspects of node resource utilization rate, microservice communication network cost, and communication performance, and the optimal microservice node is comprehensively selected for scheduling.

[0089] Exemplarily, assume that after being screened by kube-scheduler in the k8s cluster, there are N eligible schedulable nodes , the microservice pod to be scheduled is denoted as , and the node to be scored is denoted as .

[0090] 1) For node resource utilization rate, Kube-scheduler usually allocates pods to nodes with sufficient resources according to the running status of the nodes, resource usage, and pod resource requirements, without considering the problem of resource balanced allocation. To avoid the risk that a single node's CPU or memory occupancy is too high due to sudden situations (such as a surge in business traffic, a resource leak of a single pod, the execution of a large-scale batch task, etc.), which may lead to node performance bottlenecks or even node failures, the scheduling algorithm is used to take the node resource utilization rate as one of the optimization goals, aiming to preferentially schedule pods to nodes with relatively low resource utilization rates to achieve resource balanced allocation.

[0091] Define the node resource utilization rate USE x as:

[0092]

[0093] where: represents the resource dimension, represents the resources already allocated on node x, represents the total resources on node x, represents the resources required by the pod to be scheduled, is the resource weight of different dimensions, and their sum is 1.

[0094] 2) Regarding communication cost, the microservices architecture splits an application into multiple small, independent services to improve the maintainability, scalability, and flexibility of the system. However, this approach also increases the complexity of communication between services, and the resource consumption of communication between individual microservices directly affects the response time and performance of the entire application. Therefore, the scheduling algorithm takes communication cost as one of the optimization objectives, and uses the ratio of link traffic to node bandwidth in the topology relationship graph of microservices to quantify the communication cost between two microservices, aiming to preferentially schedule pods to nodes with relatively lower communication costs with other services, thereby reducing service communication overhead.

[0095] Assume that the pod is scheduled to At this time, the communication cost COST of this service with other microservices x is defined as:

[0096]

[0097] where: represents the microservice deployed on node ; represents the total link traffic generated by the service to be scheduled and all microservices on ; is the network bandwidth between node x and node n. Considering that the actual utilization rate of bandwidth will be affected by the network state, a penalty factor based on the node network state is introduced here, and its value is automatically adjusted according to network performance indicators such as network latency and packet loss rate.

[0098] 3) Regarding communication performance, in the microservices architecture, the key links are called frequently and have a large network traffic, which often become the bottleneck restricting the overall service performance. Therefore, it is hoped to preferentially allocate communication channels with better network performance (such as more abundant network bandwidth, lower latency, and better stability) to key links. Therefore, the scheduling algorithm takes communication performance as one of the optimization objectives, evaluates the node network state score in real time, and uses the product of the link weight and the node network state score in the microservice topology relationship graph to quantify the communication performance between two microservices, aiming to preferentially guarantee the communication quality of key links, allocate network transmission channels with better performance to key links, thereby improving the communication efficiency of key links and enhancing the overall service performance.

[0099] Assume that the pod is scheduled to At this time, the communication performance PERFORM of this service with other microservices x is defined as:

[0100]

[0101] where: is the network state score between node x and node n, calculated according to network performance metrics such as bandwidth, latency, packet loss rate, and jitter; represents the service to be scheduled and the total link weight between all microservices on

[0102] Optionally, the scheduling problems of the above functions are transformed into a multi-objective optimization problem, and the following objective function is obtained:

[0103]

[0104]

[0105] Optionally, the above objective functions are combined by weights and transformed into a single-objective function for solution. The genetic algorithm can also be used for solution to obtain the non-dominated solution closest to the ideal point, so as to realize scheduling the pod to the node that can make the resource utilization relatively balanced, the microservice communication network cost relatively low, and the communication performance relatively good.

[0106] Step 204, schedule the microservice pod to the target node.

[0107] In this embodiment, by analyzing the request information between microservices, the call relationship topology of microservices is dynamically constructed, and at the same time, multiple dimensions such as call frequency, link traffic, and service importance are comprehensively considered, and the link weights are dynamically calculated, so that it can be used to monitor the service state and optimize the service performance. In addition, by comprehensively considering the resource utilization rate of the server and the network topology structure between microservices, the nodes are evaluated from three aspects: node resource utilization rate, microservice communication cost, and communication performance. According to the topological relationship, link traffic, link weight, node resources, node network metrics and other data, an optimization target mathematical model is constructed, and the scheduling problem can be transformed into a multi-objective optimization problem for solution, so as to screen out the best target node.

[0108] In the microservice scheduling method under the above-mentioned Kubernetes cluster, node data of each node in the Kubernetes cluster and service traffic data of each microservice instance are collected; according to the service traffic data, a dynamic microservice topology relationship graph is constructed; wherein, the dynamic microservice topology relationship graph includes: microservice nodes, call links, as well as link traffic information and link weight information; thus, the resource utilization rate and network performance of microservice pods can be obtained in a timely manner, and a dynamic microservice topology relationship graph that changes following the call situation of microservice instances is constructed. Based on the dynamic microservice topology relationship graph and the node data, candidate nodes are evaluated from multiple dimensions, and target nodes are selected; the microservice pods are scheduled to the target nodes. Thereby, it is possible to comprehensively consider the resource utilization rate of the server and the network topology structure between microservices, greatly optimize the microservice scheduling strategy, and obtain a scheduling scheme that not only conforms to the node resource load balance but also can minimize the communication cost between microservices and achieve the best communication performance.

[0109] In an exemplary embodiment, as Figure 4 shown, a microservice scheduling method under a Kubernetes cluster is provided. Taking the Kubernetes cluster in Figure 1 as an example, the following steps 401 to 405 are included. Wherein:

[0110] Step 401, collect node data of each node in the Kubernetes cluster and service traffic data of each microservice instance.

[0111] Step 402, construct a dynamic microservice topology relationship graph according to the service traffic data.

[0112] Step 403, based on the dynamic microservice topology relationship graph and the node data, evaluate candidate nodes from multiple dimensions, and select target nodes.

[0113] Step 404, schedule the microservice pods to the target nodes.

[0114] For the specific implementation process and technical effects of steps 401 to 404 in this embodiment, please refer to Figure 2 the relevant descriptions of steps 201 to 204 in the method embodiment shown, which will not be elaborated here.

[0115] Step 405, determine whether the microservice pods are scheduled successfully. If the scheduling is not successful, add the microservice pods back to the scheduling queue.

[0116] In this embodiment, a subsequent judgment step for the pod scheduling situation is added to determine whether the pod is successfully scheduled to the target node. If it cannot be scheduled to the target node, it is considered that a scheduling failure may have occurred. At this time, the pod can be re-added to the scheduling queue for subsequent rescheduling to avoid scheduling jams and ensure scheduling efficiency and correctness.

[0117] Exemplarily, as Figure 5 shown, first, node resource and service traffic data are collected to construct a microservice topology relationship graph; then, it is judged whether there is a microservice pod to be scheduled in the scheduling queue. If there is a microservice pod to be scheduled, the nodes are scored based on the network topology and resource utilization rate, and the pod is scheduled to the optimal node. If there is no microservice pod to be scheduled, the process ends; after the pod is scheduled to the optimal node, it is further judged whether the pod scheduling is successful. If it is successful, the process ends. If it is not successful, it is re-added to the scheduling queue.

[0118] In this embodiment, by analyzing the traffic between microservice pods, a microservice call topology relationship graph is constructed, which includes microservice nodes, call links, and traffic and weight information of the links; at the same time, the resource utilization rate and network performance of the nodes are monitored; the node network status is scored according to indicators such as bandwidth, delay, and packet loss rate; the node resource utilization rate is evaluated according to the available resources, occupied resources of the node, and resources required by the pod, the network resource overhead of the microservice call is evaluated according to the link traffic and node network bandwidth, and the communication performance between microservices is evaluated according to the link weight and node network status, so as to transform the microservice pod scheduling problem into a multi-objective optimization problem and solve the Pareto optimal solution with the most balanced resource utilization rate, the lowest network resource consumption, and the best communication performance.

[0119] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are displayed in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or steps in other steps.

[0120] Based on the same inventive concept, an embodiment of the present application further provides a microservice scheduling device in a k8s cluster for implementing the microservice scheduling method in the k8s cluster involved above. The implementation solution provided by this device to solve problems is similar to the implementation solution described in the above method. Therefore, the specific limitations in one or more embodiments of the microservice scheduling device in the k8s cluster provided below can refer to the limitations on the microservice scheduling method in the k8s cluster above, and will not be repeated here.

[0121] In an exemplary embodiment, as Figure 6 shown, a microservice scheduling device in a k8s cluster is provided, including: a data collection module 601, a topology awareness module 602, a scheduler extension module 603, and a scheduling module 604, where:

[0122] The data collection module 601 is used to collect node data of each node in the k8s cluster and service traffic data of each microservice instance;

[0123] The topology awareness module 602 is used to construct a dynamic microservice topology relationship graph according to the service traffic data; wherein, the dynamic microservice topology relationship graph includes: microservice nodes, call links, and link traffic information and link weight information;

[0124] The scheduler extension module 603 is used to evaluate candidate nodes from multiple dimensions based on the dynamic microservice topology relationship graph and the node data, and filter out target nodes;

[0125] The scheduling module 604 is used to schedule microservice pods to the target nodes.

[0126] Exemplarily, the data collection module 601 is specifically used to: collect node data of each node in the k8s cluster according to a preset time period; the node data includes: resource usage data, network data; track and capture service traffic data of each microservice instance; the service traffic data includes at least one of: request ID, trace ID, source service name, target service name, and request duration.

[0127] Exemplarily, the topology awareness module 602 is specifically used to aggregate and analyze the service traffic data to obtain multiple microservice nodes and call links between microservice nodes;

[0128] Construct a topology relationship of microservices according to the microservice nodes and the call links;

[0129] In the topological relationship of the microservices, add link traffic information and link weight information to obtain a dynamic microservice topology relationship diagram; wherein, the link traffic information is calculated based on the integral of the total traffic of the microservices at both ends of the link within the sliding window time, and the calculation method of the link weight information includes at least one of the following:

[0130] Calculated based on the call frequency of the microservices at both ends of the link within a given time;

[0131] Calculated based on the callback frequency of the microservices at both ends of the link within a given time;

[0132] Calculated by comprehensively adding an empirical coefficient according to the service importance.

[0133] Exemplarily, the scheduler extension module 603 is specifically configured to: when there are microservice pods to be scheduled in the scheduling queue, based on the dynamic microservice topology relationship diagram, determine at least two candidate nodes; according to the node data, evaluate each candidate node from the dimensions of node resource utilization rate, microservice communication network cost, and communication performance to obtain an evaluation result; based on the evaluation result, screen out the target node from the candidate nodes.

[0134] Exemplarily, the scheduler extension module 603 is specifically configured to: respectively establish a node resource utilization rate evaluation function, a microservice communication network cost evaluation function, and a communication performance evaluation function; transform the solution problems of the node resource utilization rate evaluation function, the microservice communication network cost evaluation function, and the communication performance evaluation function into a multi-objective optimization problem to obtain an objective function; based on the objective function, evaluate each candidate node to obtain an evaluation result.

[0135] In another exemplary embodiment, as Figure 7 shown, a microservice scheduling device under a k8s cluster is provided. On the basis of the device as Figure 6 shown, it may further include: a judgment module 605, and the judgment module 605 is used to judge whether the microservice pod is scheduled successfully; if the scheduling is successful, the process ends; if the scheduling is not successful, the microservice pod is added back to the scheduling queue.

[0136] Each module in the above-mentioned microservice scheduling device under a k8s cluster can be implemented in whole or in part by software, hardware, and their combination. The above-mentioned modules can be embedded in the processor in the computer device in hardware form or be independent of it, or can be stored in the memory in the computer device in software form so that the processor can call and execute the operations corresponding to the above-mentioned modules.

[0137] In an exemplary embodiment, as Figure 8The figure also provides an architectural diagram of a microservice scheduling system in a Kubernetes cluster. This system includes a data collection module consisting of a node data collector and a service traffic collector, a topology awareness module, and a scheduler extension module. The node data collector is deployed on each node in the Kubernetes cluster and regularly collects node resource usage (CPU, memory, etc.) and network conditions (bandwidth, latency, packet loss rate, jitter, etc.), storing them as Prometheus metrics in a time series database. The service traffic collector is implemented based on the Envoy proxy in the Istio framework and can be injected into microservice pods as a sidecar. It tracks and captures call information for each microservice instance (such as request ID, tracing ID, source service name, target service name, request duration, etc.) and reports this call information to the topology awareness module for subsequent processing. The topology awareness module is used to construct a dynamic microservice topology diagram, which includes microservice call nodes, microservice call links, link traffic information, and link weight information. The scheduler extension module is used to extend the scheduling function of k8s so as to evaluate nodes from three aspects: node resource utilization, microservice communication network cost, and communication performance, and comprehensively select the optimal node for scheduling.

[0138] In an exemplary embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as shown in FIG. Figure 9 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store node data and service traffic data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a microservice scheduling method under a k8s cluster is implemented.

[0139] Those skilled in the art will understand that Figure 9The structure shown is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0140] In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.

[0141] In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0142] In an embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0143] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.

[0144] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, a database, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, artificial intelligence (AI) processors, etc., without limitation.

[0145] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this application.

[0146] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the scope of the patent of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims

1. A microservice scheduling method under a k8s cluster, characterized in that: The method comprises: Collect node data of each node in the k8s cluster and service traffic data of each microservice instance; Constructing a dynamic microservice topology diagram based on the service traffic data; wherein the dynamic microservice topology diagram includes: microservice nodes, call links, and link traffic information and link weight information; When there are microservice pods to be scheduled in the scheduling queue, at least two candidate nodes are determined based on the dynamic microservice topology graph; based on the node data, each candidate node is evaluated from the perspectives of node resource utilization, microservice communication network cost, and communication performance to obtain an evaluation result; based on the evaluation result, a target node is screened from the candidate nodes; wherein the microservice communication network cost is determined based on the ratio of link traffic to node bandwidth in the microservice topology graph and a penalty factor of the node network status, and the value of the penalty factor of the node network status is automatically adjusted based on the network personality indicator; Schedule the microservice pod to the target node; Determine whether the microservice pod is successfully scheduled; if the scheduling is successful, end the process; if the scheduling is unsuccessful, add the microservice pod back to the scheduling queue.

2. The method according to claim 1, characterized in that: The node data of each node in the k8s cluster and the service traffic data of each microservice instance are collected, including: Collect node data of each node in the k8s cluster according to the preset time period; the node data includes: resource usage data and network data; Track and capture service traffic data for each microservice instance; the service traffic data includes: at least one of the request ID, tracking ID, source service name, target service name, and request duration.

3. The method according to claim 1, characterized in that The step of constructing a dynamic microservice topology diagram based on the service traffic data includes: Aggregating and analyzing the service traffic data to obtain call links between multiple microservice nodes; Constructing a topological relationship of microservices based on the microservice nodes and the call links; Link flow information and link weight information are added to the topological relationship of the microservices to obtain a dynamic microservice topological relationship diagram; wherein the link flow information is calculated based on the integral of the total flow of the microservices at both ends of the link within the sliding window time, and the calculation method of the link weight information includes at least one of the following: Calculated based on the frequency of microservice calls at both ends of the link within a given time period; Calculated based on the callback frequency of microservices at both ends of the link within a given time period; It is calculated by adding the experience coefficient according to the importance of the service.

4. The method according to claim 1, wherein The candidate nodes are evaluated from the perspectives of node resource utilization, microservice communication network cost, and communication performance, and the evaluation results are obtained, including: Establish node resource utilization evaluation function, microservice communication network cost evaluation function, and communication performance evaluation function respectively; Converting the node resource utilization evaluation function, the microservice communication network cost evaluation function, and the communication performance evaluation function into a multi-objective optimization problem to obtain an objective function; Based on the objective function, each candidate node is evaluated to obtain an evaluation result.

5. A microservice scheduling device under a k8s cluster, characterized in that: The device includes: A data collection module, configured to collect node data of each node under the k8s cluster and service traffic data of each microservice instance; A topology awareness module, configured to construct a dynamic microservice topology relationship graph according to the service traffic data; wherein, the dynamic microservice topology relationship graph includes: microservice nodes, call links, and link traffic information and link weight information; A scheduler extension module, configured to, when there are microservice pods to be scheduled in the scheduling queue, determine at least two candidate nodes based on the dynamic microservice topology relationship graph; evaluate each candidate node respectively from the dimensions of node resource utilization rate, microservice communication network cost, and communication performance according to the node data to obtain an evaluation result; based on the evaluation result, screen out a target node from the candidate nodes; wherein, the microservice communication network cost is determined according to the ratio of the link traffic of the microservice topology relationship graph to the node bandwidth and the penalty factor of the node network state, and the value of the penalty factor of the node network state is automatically adjusted according to the network personality index; A scheduling module, configured to schedule the microservice pod to the target node determination module; The determination module is configured to determine whether the microservice pod is successfully scheduled; if it is successfully scheduled, the process ends; if it is not successfully scheduled, the microservice pod is added back to the scheduling queue.

6. The device according to claim 5, characterized in that The data collection module is specifically configured to: collect node data of each node under the k8s cluster according to a preset time period; the node data includes: resource usage data, network data; track and capture the service traffic data of each microservice instance; the service traffic data includes at least one of: request ID, trace ID, source service name, target service name, request duration.

7. The device according to claim 5, characterized in that, The topology awareness module is specifically configured to aggregate and analyze the service traffic data to obtain multiple microservice nodes and call links between microservice nodes; Construct a topology relationship of the microservice according to the microservice nodes and the call links; In the topology relationship of the microservice, add link traffic information and link weight information to obtain a dynamic microservice topology relationship graph; wherein, the link traffic information is calculated according to the integral of the total traffic of the microservices at both ends of the link within the sliding window time, and the calculation method of the link weight information includes at least one of the following: Calculated according to the call frequency of the microservices at both ends of the link within a given time; Calculated according to the callback frequency of the microservices at both ends of the link within a given time; Calculated by comprehensively considering the service importance and adding an empirical coefficient.

8. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 4.

10. A computer program product comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Scheduling method and system based on Kubernetes in cross-domain environment

    CN118784597A

  • Intelligent operation and maintenance method and system for cloud micro-service architecture

    CN119052096A

  • Defense method and device for distributed denial of service attack and electronic equipment

    CN119363410A