Efficient serverless resource allocation method and system based on reinforcement learning

By applying reinforcement learning decision makers and pipeline decision-making on the serverless platform, combined with preheated container management, optimizing resource configuration and scheduling, the problem of resource efficiency and tail delay trade-offs is solved, and efficient resource utilization and low-latency Serverless resource allocation are achieved. .

WO2024192952A1PCT designated stage expired Publication Date: 2024-09-26ZHEJIANG LAB

Patent Information

Application Number
PCT/CN2023/112109
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-23
Filing Date
2023-08-10
Publication Date
2024-09-26

AI Technical Summary

Technical Problem

It is difficult for existing serverless platforms to make a trade-off between resource efficiency and tail latency in resource configuration management. Active control relies on the accuracy of machine learning models, and high-frequency control may lead to increased resource and time overhead, resulting in low resource utilization. effect.

Method used

Adopting a serverless efficient resource allocation method based on reinforcement learning, by building a reinforcement learning decision maker, using the status module, strategy module and reward module to make resource allocation decisions, and combining pipeline decision-making and preheated container management systems to optimize resource allocation and container scheduling , reduce resource waste and time overhead.

Benefits of technology

Achieved 99% of the request time delay target, reduced resource usage by 30%, and reduced end-to-end delay variance by 1.9 times, improving resource utilization and system efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023112109_26092024_PF_FP
    Figure CN2023112109_26092024_PF_FP
Patent Text Reader

Abstract

Disclosed in the present invention are an efficient serverless resource allocation method and system based on reinforcement learning. In the method, by means of the observation of a relationship between a tail latency, a decision frequency and a resource efficiency, a set performance delay objective is guaranteed while the resource allocation consumption of a serverless system is minimized. The method makes full use of the advantage of efficient resource management brought about by high-frequency management, and by means of observing the state of each request, a decision is made, by using a reinforcement learning model, on a resource configuration of an instance for processing the request. By means of taking into account the characteristic of multi-stage operation of a function workflow and a lightweight design for a decision-making model, a high-frequency control layer conceals time overheads and reduces resource overheads. Compared with the latest workflow task scheduling system, the present invention improves the CPU utilization rate, and provides a delay service level objective (SLO) guarantee for 99% requests, thereby reducing an end-to-end delay variance.
Need to check novelty before this filing date? Find Prior Art

Description

A Serverless efficient resource allocation method and system based on reinforcement learning Technical Field

[0001] The present invention relates to the technical field of cloud computing, and in particular to a serverless efficient resource allocation method and system based on reinforcement learning. Background Art

[0002] Serverless computing's high scalability, ease of development, fine-grained nature, and low cost have made it a mainstream approach to microservices architecture. Supported and rapidly adopted by major cloud providers like Amazon, it is widely used in a variety of user-facing scenarios, including web applications, video processing, and machine learning inference. To meet the high scalability and elasticity requirements of these applications, these complex application services are deconstructed into a set of serverless functions, forming a directed acyclic graph.

[0003] In most cases, these user-facing applications have stringent latency requirements. However, due to various factors, these applications generate significant tail latencies, making performance prediction extremely difficult. Current commercial platforms, such as Amazon's serverless platform Lambda, or open source platforms like Open Whisk, do not provide any guarantees for application latency, instead relying on developers to determine the resource allocation for their functions. Consequently, on these platforms, developers are forced to choose larger resource allocations (such as memory and CPU) to meet their application's SLO (Service Level Objective), resulting in poor resource utilization.

[0004] To reduce the uncertainty of application latency, the platform requires a control layer for management. Existing work is mainly divided into active types that are scheduled or configured in advance, and passive types that are triggered by thresholds. The mainstream solutions for both types of work rely on machine learning models to configure resources. However, based on existing work, we further observed that 1) passive control has difficulty balancing resource efficiency and tail latency. Efficient resource utilization comes at the expense of high tail latency, and vice versa; 2) active control relies on the accuracy of machine learning models. When the prediction error is low, active control will have higher resource efficiency than passive control; 3) high-frequency control can effectively improve the resource efficiency of serverless systems; 4) resource and time overheads increase with the control frequency, which may offset the benefits of high frequency. These phenomena become more obvious and severe in function workflow tasks.

[0005] Furthermore, it was discovered that the directed acyclic graph (DAG) comprising the function workflow is itself a Markov process. At each state transition between different function stages, the function can choose one of several configurations, and the transition probability depends on the chosen configuration. Unlike traditional supervised or unsupervised learning, this process does not involve right or wrong answers, nor does it require precise correction of suboptimal solutions. This is a reinforcement learning process that emphasizes how to act based on the environment to maximize expected benefits. It focuses on finding a balance between exploration and exploitation, emphasizing the "exploration-exploitation" trade-off in learning, which aligns with the goal of developing efficient serverless resource allocation technologies.

[0006] Summary of the Invention

[0007] To address the shortcomings of existing technologies, this paper provides a reinforcement learning-based efficient serverless resource allocation method and system. This method utilizes reinforcement learning to make targeted resource allocation decisions and control for each request, effectively improving resource utilization while ensuring a 99% request latency target. Furthermore, this paper utilizes pipeline decision-making and container management mechanisms to effectively mitigate the impact of resource and time overhead on the system.

[0008] The present invention is achieved through the following technical solutions:

[0009] A serverless efficient resource allocation method based on reinforcement learning, comprising the following steps:

[0010] (1) Constructing a reinforcement learning decision maker: The reinforcement learning decision maker is predicted using a reinforcement learning model, which includes a state module, a policy module, an action module, and a reward module;

[0011] (2) Decision pipeline: The reinforcement learning decision maker constructed in step (1) is used to pipeline the resource allocation of each stage function. In each decision process, the reinforcement learning decision maker uses the remaining time to the target as input and derives the resource allocation of the next function, using the maximum execution time recorded for the currently executed function for estimation.

[0012] (3) Container management: When the reinforcement learning decision in step (2) determines an inconsistent function resource configuration, a preheating container management system is used to forward the function execution instance to the target container for execution during the scheduling process; the preheating container management system includes a prediction module responsible for predicting the future request arrival rate, a proxy module responsible for node container management, and a forwarding module responsible for fast scheduling of execution requests;

[0013] (4) When each request arrives, the resource configuration of each stage is performed in sequence using the method in step (2). After obtaining the resource configuration of the corresponding stage each time, the forwarding module in step (3) is used to schedule the request to the corresponding configuration container to perform calculations.

[0014] Furthermore, the state module in step (1) is mainly composed of three types: application state, request state, and cluster state. The state module uses a graph neural network to perform dimension compression on the application DAG information.

[0015] The application status is used to describe the status of the workflow application, including the structure of the workflow directed acyclic graph (DAG), the average execution time of each function, and the average resource utilization of each function, that is, the average resource utilization of CPU and memory obtained through offline analysis of the function;

[0016] The request status is used to describe the access load, including the number of requests per second (QPS), the remaining time before reaching the target latency SLO, and the number of unexecuted functions in the workflow, which are obtained by the request monitor;

[0017] The cluster state is used to describe the status of physical resources, including available CPU and memory, which are obtained by the cluster monitor.

[0018] Furthermore, the state module uses graph neural networks to perform dimensionality compression on application DAG information. Specifically, the GraphSAGE method in the GCN graph convolutional neural network is used. The method adopts a node embedding method to extract high-dimensional information of the node graph neighborhood into dense vector embedding, and quickly generates a new graph embedding with the ability to generalize and meet the resource allocation requirements of various workflow applications. After the application state information is characterized and obtained, the system will transmit its application state information starting from the tail node of its DAG graph, and recursively pass the information of each node to the parent node and the root node.

[0019] Furthermore, in step (1), the strategy module calculates the state information based on the Actor-Critic algorithm and the advantage function; the Actor is a strategy network, and the Actor uses a fully connected neural network to output a value for each action, and uses the SoftMax function to convert the value into a corresponding probability, and selects an action according to the probability, and is responsible for selecting an action and interacting with the environment; the Critic is an evaluation network, that is, using the advantage function A(s t ,a t )=Q(s t ,a t )-V(s t ) as the evaluation network Critic, its Q(st ,a t ) and V(s t ) refer to the trajectory of accumulated experience and the simulated approximation of average experience, respectively, which are used to score the Actor's behavior. The Actor then adjusts its own parameters based on the Critic's score; the action module implements a separate policy network for each function resource, and each network determines the corresponding resource allocation amount.

[0020] Specifically, in step (1), the reward module uses the resource allocation amount and the request end-to-end execution time as the reward and punishment values ​​to train the accuracy of the decision module. It constructs the following function for reward, and its expression is:

[0021] Where R represents the amount of resources allocated by the function, and W represents the actual amount of wasted resources; elapsed Represents the time after the request arrives, t slo represents the target latency set by the application, n represents the number of remaining sub-functions of the function; θ and μ are constant parameters used to control the relationship between the two.

[0022] Specifically, the pipeline decision in step (2) is that when the first stage is executed, the decision maker simultaneously decides the resource configuration of the second stage; when the second stage is executed, the resource configuration of the third stage is decided, and so on.

[0023] Furthermore, the preheating container management system in step (3) is specifically as follows: the prediction module reads historical QPS data and uses an exponential weighted average model to predict, obtains the future maximum arrival rate, uses the action probability table divided by QPS in the training phase, and multiplies the maximum arrival rate and the action probability one by one to obtain the number of container instances in the future time window; after obtaining the number of container instances with different resource configuration quantities, the prediction module will allocate the resource configuration to different cluster machines, and the agent module will receive the corresponding information, that is, receive the instruction. After receiving the instruction, the agent module first determines the total number of cluster containers, cold-starts the container when the number is insufficient, and uses Cgroup to modify the configuration when the container is idle, and sends the IP and port of the finally configured instance to the forwarding module; the forwarding module maintains a queue of multiple container IPs with different resource configurations. When the reinforcement learning decision maker determines the function to be executed and the corresponding configuration, the forwarding module obtains an executable idle container IP by dequeuing the queue, forwards the scheduling information and schedules the instance, and re-queues the relevant information after the container is executed, thereby reusing the container to save the cold start overhead.

[0024] Specifically, the working process of the preheating container management system in step (3) is to configure the container using the reinforcement learning action probability table and the predicted load.

[0025] Furthermore, in step (4), the system is responsible for managing the complete process of each request, including decision-making, scheduling, and triggering operations of the next stage function.

[0026] A serverless efficient resource allocation system based on reinforcement learning, which includes the following modules:

[0027] Gateway module: The gateway module adds a set of interfaces to the original system gateway to forward requests to the forwarding module. The system gateway uses Prometheus to continuously monitor the request arrival rate and regularly sends statistical data to the request volume prediction module for decision-making;

[0028] Controller module: The controller module is the main module, which includes pipeline prediction, reinforcement learning decision maker, forwarding module and request volume prediction module. The pipeline prediction uses semaphores and coroutines in programming languages ​​to manage the execution of applications in a workflow manner; the reinforcement learning decision maker integrates the trained model into the system and simultaneously observes the application, request and cluster status through the container monitoring program, and passes the status to the reinforcement learning decision maker; the forwarding module maintains a hash queue in memory, which stores IP information corresponding to different configurations for fast search and sending of requests; the request volume prediction module uses historical data transmitted by the gateway to regularly decide the number of containers for the next stage;

[0029] Proxy module: This module is implemented on the daemon process set of the container management platform. This module performs resource adjustment operations after receiving a call by exposing the Hypertext Transfer Protocol service port in the cluster. The state resources are adjusted using the control group method of the operating system. Compared with modifying the configuration related to the deployment module of the container management platform, the control group method does not require restarting the container. The state resources are processor quota and memory.

[0030] Simulator module: The simulator module is a serverless simulator used to train reinforcement learning policy networks. It simulates the complete process of workflow requests through a continuous-time and discrete-event driven engine and maintains a logical clock to speed up the training process. The model uses 32 neurons and 16 neurons to form the network structure, respectively, and is implemented using a machine learning platform.

[0031] The beneficial effects of the present invention are as follows:

[0032] In order to improve the resource utilization efficiency in serverless systems, existing work has proposed passive and active dynamic adjustment strategies. However, the passive approach will only react when a violation occurs, and decision-making is extremely difficult when balancing tail latency and resource waste. Active predictive dynamic decision-making relies on the accuracy of machine learning model predictions, and it is difficult to be effective in scenarios with large changes. In order to make up for the shortcomings of the above two methods, the present invention proposes a request-level granularity function workflow resource management system based on reinforcement learning, which makes resource allocation decisions for each request, thereby reducing the problem of inefficient resource utilization caused by emergencies and coarse-grained management.

[0033] Compared to existing work, the present invention proposes a resource allocation strategy for request-level granularity management, and designs a reinforcement learning algorithm to decide the resource allocation for each step of the serverless function workflow based on the different states of each request arrival. At the same time, in order to avoid the problem of excessive time overhead caused by decision-making, the present invention proposes a pipelined prediction method, which executes the prediction process in parallel with the function execution process, reducing the linearly increasing prediction time overhead to a single decision time overhead. In order to solve the problem of cold start caused by inconsistent resource configuration, the present invention proposes a preheating container management solution, which uses the decision maker's action probability table to prepare the required container instances in advance.

[0034] Compared to existing technologies, this invention has significant benefits. Compared to the latest existing serverless resource management systems, this invention reduces resource usage by 30%, provides a 99% request latency SLO guarantee, and reduces end-to-end latency variance by 1.9 times. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] FIG1 is a schematic diagram of the system architecture of the present invention;

[0036] FIG2 is a flow chart of the method of the present invention;

[0037] FIG3 is a schematic diagram of an implementation of a reinforcement learning model according to the present invention;

[0038] FIG4 is a schematic diagram of a system implementation of the present invention;

[0039] FIG5 is a schematic diagram of the system flow of the present invention. DETAILED DESCRIPTION

[0040] In order to make the methods, techniques, objectives and effects introduced in the present invention easier to understand, the present invention is further described below in conjunction with specific implementation methods and drawings.

[0041] The present invention utilizes a machine learning technique, namely reinforcement learning, which enables an agent to learn in an interactive environment through trial and error, using feedback from its own actions and experience. The goal is for the agent to learn a strategy that maximizes reward. In serverless resource allocation, the agent refers to the controller, and the environment is the serverless cluster. Its purpose is to find the resource allocation strategy that the controller uses to determine the resource configuration for the next instance based on the current application, request, and cluster state. To implement the application of reinforcement learning in request-level granularity function workflow scenarios, the present invention first constructs a reinforcement learning model, which includes four modules: state, strategy, action, and reward.

[0042] A serverless efficient resource allocation method based on reinforcement learning, comprising the following steps:

[0043] (1) Constructing a reinforcement learning decision maker: The reinforcement learning decision maker is predicted using a reinforcement learning model, which includes a state module, a policy module, an action module, and a reward module;

[0044] (2) Decision pipeline: The reinforcement learning decision maker constructed in step (1) is used to pipeline the resource allocation of each stage function. In each decision process, the reinforcement learning decision maker uses the remaining time to the target as input and derives the resource allocation of the next function, using the maximum execution time recorded for the currently executed function for estimation.

[0045] (3) Container management: When the reinforcement learning decision in step (2) determines an inconsistent function resource configuration, a preheating container management system is used to forward the function execution instance to the target container for execution during the scheduling process; the preheating container management system includes a prediction module responsible for predicting the future request arrival rate, a proxy module responsible for node container management, and a forwarding module responsible for fast scheduling of execution requests;

[0046] (4) When each request arrives, the resource configuration of each stage is performed in sequence using the method in step (2). After obtaining the resource configuration of the corresponding stage each time, the forwarding module in step (3) can be used to quickly schedule the request to the corresponding configuration container to perform calculations.

[0047] Specifically:

[0048] 1. Build a reinforcement learning model

[0049] (1.1) State Module

[0050] The state module describes the specific conditions of the environment and the agent. The present invention uses three types of information to define the state in serverless resource allocation. The first type of application state is used to describe the situation of the workflow application, including the structure of the workflow directed acyclic graph DAG, the average execution time of each function, and the average resource utilization of each function, that is, the average resource utilization of CPU and memory, which is obtained through offline analysis of the function; the second type of request state is used to describe the access load situation, including the number of requests per second QPS (Query Per Second), that is, the number of requests per second, the remaining time before reaching the target latency SLO, and the number of functions that have not been executed in the workflow, which are obtained by the request monitor; the third type of cluster state is used to describe the status of physical resources, including available CPU and memory, which are obtained by the cluster monitor.

[0051] The DAG structure of serverless workflows can vary significantly, resulting in varying state space sizes. Therefore, reconciling this with the fixed size of the RL network input layer is a challenge. This paper utilizes the GraphSAGE (Graph SAmple and aggreGatE) method from the GCN (Graph Convolutional Network) graph convolutional neural network. This method uses node embedding to extract high-dimensional information about the node graph neighborhood into a dense vector embedding. This method rapidly generates novel graph embeddings, demonstrating the generalization capabilities required to meet the resource allocation needs of various workflow applications.

[0052] After the application state information is captured, the system will transmit the application state information starting from the tail node of its DAG graph, and recursively pass the information of each node to the parent node and the root node. In this process, the present invention enhances the expression effect of application features through nonlinear functions.

[0053] (1.2) Strategy

[0054] The Actor-Critic algorithm is used as the policy network algorithm of the present invention. The Actor is the policy network responsible for selecting actions and interacting with the environment; the Critic is the evaluation network used to score the Actor's behavior. The Actor then adjusts its own parameters within a certain range based on the Critic's score.

[0055] The present invention uses a fully connected neural network as the actor of the present invention, which will output a value for each action, and use the SoftMax function to convert the value into a corresponding probability, and then select the action based on the probability, so as to effectively avoid the local optimal dilemma caused by taking the highest value. At the same time, the present invention uses the advantage function A(s t ,a t )=Q(st ,a t )-V(s t ) is the evaluation network Critic of the present invention, and its Q(s t ,a t ) and V(s t ) refer to the trajectory of cumulative experience and the simulated approximation of average experience, respectively. Compared with the method of directly using numerical calculations, this method has smaller variance and faster convergence.

[0056] (1.3) Action

[0057] A separate decision network is trained for each resource type, and each network determines the corresponding resource allocation amount. This significantly improves training speed while ensuring decision accuracy.

[0058] (1.4) Rewards

[0059] Since the controller adjusts resource allocation based on the request and each function, a single request is considered as a complete training phase. The present invention constructs the following function for reward, which is expressed as:

[0060] Where R represents the amount of resources allocated by the function, and W represents the actual amount of wasted resources; elapsed Represents the time after the request arrives, t slo represents the target latency set by the application, and n represents the number of remaining sub-functions of the function. To minimize resource usage, this invention configures a penalty agent based on the resources used, treating SLO violations differently at different stages. Early SLO violations are much more severe than later ones, so timeouts in these stages are multiplied by the number of sub-functions as the penalty value. θ and μ are constant parameters that control the relationship between them. μ should be set larger than θ to improve training speed and effectiveness.

[0061] 2. Pipeline module

[0062] In an application workflow, when a request arrives, the reinforcement learning decider determines the resource allocation for the first-stage function. While the first stage is executing, the decider also determines the resource allocation for the second stage. Similarly, while the second stage is executing, the decision is made for the third stage, and so on. For complex, nonlinear DAG graph structures, the decider identifies the parent function that started last for each function and makes parallel predictions during the execution of this parent function. This pipelined decision-making reduces the linearly increasing time overhead to the time required for a single inference.

[0063] In each decision-making process, the reinforcement learning decision maker uses the remaining time to the target as input and derives the resource allocation for the next function. However, when making parallel decisions, it is impossible to know the remaining time for the next stage of execution. To address this, the present invention uses the maximum execution time recorded for the currently executing function for estimation.

[0064] 3. Container Management

[0065] It is mainly divided into a prediction module responsible for predicting future request arrival rates, a proxy module responsible for node container management, and a forwarder module responsible for executing fast request scheduling.

[0066] (3.1) Prediction module

[0067] The prediction module reads historical QPS data and uses the exponentially weighted average model (EWMA) to make predictions, while also increasing the result by a 20% offset. After obtaining the future maximum arrival rate, the present invention uses the action probability table divided by QPS during the training phase and multiplies the maximum arrival rate by the action probability to obtain the number of container instances in the future time window. At the same time, the present invention continuously monitors the container operation queue status. When the queue time of a configured container exceeds the cold start time, a new instance is cold started.

[0068] (3.2) Proxy Module

[0069] After determining the number of container instances with different resource configurations, the prediction module greedily allocates the resources to different cluster machines. The proxy module then receives the corresponding information. Upon receiving the instructions, the proxy module first determines the total number of cluster containers. If the number is insufficient, it cold-starts the container and uses Cgroup to modify the configuration when the container is idle. The proxy module then sends the IP address and port number of the final configured instance to the forwarding module.

[0070] (3.3) Forwarding module

[0071] The forwarding module maintains a queue of multiple container IP addresses with different resource configurations. When the reinforcement learning decider determines the function to execute and the corresponding configuration, the forwarding module dequeues an idle container IP address available for execution, forwards the scheduling information, and schedules the instance. After the container completes execution, the relevant information is requeued, allowing container reuse and reducing cold start overhead.

[0072] System architecture of the present invention: Figure 1 shows the architecture diagram of the present invention. The core of the present invention is that both resource efficiency and predictable latency can be achieved simultaneously through a request-granularity resource allocation strategy based on reinforcement learning. It manages request forwarding, scaling, and resource allocation through the collaboration of controllers deployed on physical servers. In the controller of the present invention, there are two core components: a reinforcement learning predictor determines the resource configuration of each instance; pipelining hides the time overhead generated by each decision process, avoiding SLO violations caused by cumulative effects. Since serverless computing generally adopts "one request to one state mapping" during processing, resource allocation for each request is achieved by calling a reinforcement learning decider in each request and each function. Even if multiple requests share the same instance (that is, reusing an existing instance for a new request), each request will repeatedly call the decider to adjust the resource allocation of the instance.

[0073] Specifically, when a user issues a request, it first arrives at the gateway, which accepts the request and sends it to the forwarding module to search for available instances. The prediction module continuously monitors the workload (i.e., QPS) and uses an exponentially weighted moving average (EWMA) algorithm to predict the number of requests in the next time interval. If the number of instances is insufficient to handle the requests in the following time interval, the controller uses a greedy approach to partition the instances onto one or more servers, notifying its proxy module to scale out more instances and adjust the instance resource configuration. For each workflow application request, the controller organizes resource allocation decisions and function computations into a pipelined module. Based on the workflow structure, the controller sends the currently monitored state information to the reinforcement learning decider to obtain configuration information that meets the SLO with minimal resource waste. For functions that have been decided, the forwarding module is responsible for finding eligible container instances and dispatching the request to the corresponding instance. After the function completes, the controller monitors whether the current request has been executed. If any unexecuted requests remain, the controller repeats the above steps until the final function in the function workflow is executed.

[0074] Regarding the reinforcement learning model implementation of this invention: Figure 2 illustrates the reinforcement learning model implementation architecture. After the system collects requests, applications, and cluster status from a serverless cluster environment, it delivers the data to the GCN model for state compression, converting the two-dimensional information into one-dimensional content. After processing the state data, it is passed to the policy network for calculation, generating the corresponding action. The action is returned to the serverless function cluster, and this value is used as the resource allocation value for request management. This completes the resource allocation decision-making process.

[0075] Regarding the reinforcement learning model implementation of this invention: Figure 3 illustrates the reinforcement learning model implementation architecture. The system monitors the state of the serverless cluster. After collecting requests, applications, and the corresponding cluster state within the cluster environment, it delivers the data to a graph neural network for state compression. The graph neural network model uses recursive propagation to transform the application pipeline from two-dimensional information to one-dimensional information. After processing the state data, it is passed to the policy network for calculation, resulting in the corresponding action. The action is returned to the serverless function cluster, and the controller uses this value as the resource configuration for the request phase to manage the request. This completes the resource allocation decision-making process.

[0076] System Implementation: This invention is implemented in OpenFaaS, an open-source serverless platform based on Go and Kubernetes. As shown in Figure 4 , this invention reuses the request methods provided by OpenFaaS, primarily modifying the modules related to request scheduling and resource allocation, including the OpenFaaS gateway and the OpenFaaS processor. Two new modules are also added to facilitate deployment and rapid reinforcement learning training: the agent and the simulator.

[0077] The gateway module adds a set of interfaces to the existing OpenFaaS gateway, which forwards requests to the forwarding module. The OpenFaaS gateway uses a monitoring program (Prometheus) to continuously monitor the query per second (QPS) arrival rate and regularly sends statistical data to the QPS prediction module for decision-making.

[0078] About the controller module: It includes pipeline prediction, reinforcement learning decision maker, forwarding module and QPS prediction module. Pipeline prediction uses semaphores and Goroutines in the Go language to manage the execution of applications in a workflow manner. The reinforcement learning decision maker integrates the trained model into OpenFaaS through Tensorflow Go. At the same time, the present invention observes the application, request and cluster status through two container monitoring programs, Prometheus and Cadvisor, and passes the status to the reinforcement learning decision maker. The decision maker uses a graph neural network to convert and combine the data, and inputs it into the corresponding reinforcement learning model for decision-making. The forwarding module maintains a hash queue in memory. The hash queue stores IP information corresponding to different configurations for fast search and sending requests. The QPS prediction module uses historical data transmitted by the OpenFaaS gateway to regularly decide the number of containers for the next stage.

[0079] The proxy module is implemented in Kubernetes' DaemonSet. It exposes an HTTP service port in the cluster and performs resource adjustments upon receiving a call. Stateful resources (such as CPU quotas and memory) are adjusted using Cgroups. Compared to modifying Kubernetes' Deployment configuration, Cgroups do not require container restarts.

[0080] The simulator: This paper designs a serverless simulator for more efficient training of reinforcement learning policy networks. It uses a continuous-time and discrete-event driven engine to simulate the complete workflow request process and maintains a logical clock to accelerate the training process. Training a single model takes four hours. The model uses 32 and 16 neurons to construct the network structure, respectively, and is implemented using TensorFlow. During operation, the present invention uses the Glorot method to initialize parameters.

[0081] As shown in Figure 5, the present invention also provides a serverless efficient resource allocation system based on reinforcement learning, which includes the following modules:

[0082] Gateway module: The gateway module adds a set of interfaces to the original system gateway to forward requests to the forwarding module. The system gateway uses a set of methods to continuously monitor the request arrival rate and regularly sends statistical data to the request volume prediction module for decision-making;

[0083] Controller module: The controller module is the main module, which includes pipeline prediction, reinforcement learning decision maker, forwarding module and request volume prediction module. The pipeline prediction uses semaphores and coroutines in programming languages ​​to manage the execution of applications in a workflow manner; the reinforcement learning decision maker integrates the trained model into the system and simultaneously observes the application, request and cluster status through the container monitoring program, and passes the status to the reinforcement learning decision maker; the forwarding module maintains a hash queue in memory, which stores IP information corresponding to different configurations for fast search and sending of requests; the request prediction module uses historical data transmitted by the gateway to regularly decide the number of containers for the next stage;

[0084] Proxy module: The proxy module is implemented on the daemon process set of the container management platform. This module performs resource adjustment operations after receiving a call by exposing the Hypertext Transfer Protocol service port in the cluster. The state resources are adjusted using the control group method of the operating system. Compared with modifying the relevant configuration of the deployment module of the container management platform, the control group method does not require restarting the container; the state resources are processor quota and memory.

[0085] Simulator module: The simulator module is a serverless simulator used to train reinforcement learning policy networks. It simulates the complete process of workflow requests through a continuous-time and discrete-event driven engine and maintains a logical clock to speed up the training process. The model uses 32 neurons and 16 neurons to form the network structure respectively, and is implemented using the most commonly used machine learning platforms.

[0086] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.

Claims

1. A serverless efficient resource allocation method based on reinforcement learning, It is characterized in that The method comprises the following steps: (1) Constructing a reinforcement learning decision maker: The reinforcement learning decision maker is predicted using a reinforcement learning model, wherein the reinforcement learning model includes a state module, a strategy module, an action module, and a reward module; (2) Decision pipeline: The reinforcement learning decision maker constructed in step (1) is used to pipeline the resource allocation of each stage function. In each decision process, the reinforcement learning decision maker uses the remaining time to the target as input and derives the resource allocation of the next function, using the maximum execution time recorded by the current execution function for estimation. (3) Container management: When the reinforcement learning decision in step (2) determines an inconsistent function resource configuration, a preheating container management system is used to forward the function execution instance to the target container for execution during the scheduling process; the preheating container management system includes a prediction module responsible for predicting the future request arrival rate, a proxy module responsible for node container management, and a forwarding module responsible for fast scheduling of execution requests; (4) When each request arrives, the resource configuration of each stage is performed in turn using the method in step (2). After the resource configuration of the corresponding stage is obtained each time, the forwarding module in step (3) is used to schedule the request to the corresponding configuration container to perform calculations.

2. According to the serverless efficient resource allocation method based on reinforcement learning according to claim 1, It is characterized in that In step (1), the state module mainly consists of three types: application state, request state, and cluster state. The state module uses a graph neural network to perform dimension compression on the application DAG information. The application status is used to describe the situation of the workflow application, including the structure of the workflow directed acyclic graph DAG, the average execution time of each function, and the average resource utilization of each function, that is, the average resource utilization of the CPU and memory obtained through offline analysis of the function; The request status is used to describe the access load, including the number of requests per second (QPS), that is, the number of requests per second, the remaining time before reaching the target latency SLO, and the number of functions that have not been executed in the workflow, which are obtained by the request monitor; The cluster status is used to describe the status of physical resources, including available CPU and memory, which are obtained by the cluster monitor.

3. According to the serverless efficient resource allocation method based on reinforcement learning according to claim 2, It is characterized in that The state module uses a graph neural network to perform dimensional compression on the application DAG information. Specifically, the GraphSAGE method in the GCN graph convolutional neural network is used. The method adopts a node embedding method to extract the high-dimensional information of the node graph neighborhood into a dense vector embedding, and quickly generates a new graph embedding inductive capability to meet the resource allocation requirements of various workflow applications. After the application state information is characterized and obtained, the system will transmit its application state information starting from the tail node of its DAG graph, and recursively transmit the information of each node to the parent node and the root node.

4. According to the serverless efficient resource allocation method based on reinforcement learning according to claim 1, It is characterized in that In step (1), the strategy module calculates the state information based on the Actor-Critic algorithm and the advantage function; the Actor is a strategy network, and the Actor uses a fully connected neural network to output a value for each action, and uses the SoftMax function to convert the value into a corresponding probability, and selects an action according to the probability, and is responsible for selecting actions and interacting with the environment; the Critic is an evaluation network, that is, using the advantage function A(s t ,a t )=Q(s t ,a t )-V(s t ) is used as the evaluation network Critic, whose Q(s t ,a t ) and V(s t ) refer to the trajectory of accumulated experience and the simulated approximation of average experience, respectively, which are used to score the behavior of the Actor. The Actor then adjusts its own parameters according to the Critic's score; the action module implements a separate strategy network for each function resource, and each network determines the corresponding resource configuration amount.

5. According to the serverless efficient resource allocation method based on reinforcement learning according to claim 1, It is characterized in that In step (1), the reward module uses the resource allocation amount and the request end-to-end execution time as the reward and punishment value to train the accuracy of the decision module. It constructs the following function for rewarding, and its expression is: Where R represents the number of resources allocated by the function, and W represents the actual amount of resource waste; elapsed Represents the time after the request arrives, t slo represents the target latency set by the application, n represents the number of remaining sub-functions of the function; θ and μ are constant parameters used to control the relationship between the two.

6. According to the serverless efficient resource allocation method based on reinforcement learning according to claim 1, It is characterized in that The pipeline decision in step (2) means that when the first stage is executed, the decision maker simultaneously decides the resource configuration of the second stage; when the second stage is executed, the resource configuration of the third stage is decided, and so on.

7. According to the serverless efficient resource allocation method based on reinforcement learning according to claim 1, It is characterized in that The preheating container management system in step (3) is specifically as follows: the prediction module reads historical QPS data, uses an exponential weighted average model to predict, obtains the future maximum arrival rate, uses the action probability table divided by QPS in the training phase, and multiplies the maximum arrival rate by the action probability to obtain the number of container instances in the future time window; after obtaining the number of container instances with different resource configuration quantities, the prediction module will allocate the resource configuration to different cluster machines, and the proxy module will receive the corresponding information, that is, receive the instruction. After receiving the instruction, the proxy module first determines the total number of cluster containers, cold-starts the container when the number is insufficient, and uses Cgroup to modify the configuration when the container is idle, and sends the IP and port of the finally configured instance to the forwarding module; the forwarding module maintains a queue of multiple container IPs with different resource configurations. When the reinforcement learning decision maker determines the function to be executed and the corresponding configuration, the forwarding module obtains an executable idle container IP by dequeuing the queue, forwards the scheduling information and schedules the instance, and requeues the relevant information after the container is executed, thereby reusing the container to save the cold start overhead.

8. According to the serverless efficient resource allocation method based on reinforcement learning according to claim 1, It is characterized in that The working process of the preheating container management system in step (3) is to configure the container using the reinforcement learning action probability table and the predicted load.

9. According to the serverless efficient resource allocation method based on reinforcement learning according to claim 1, It is characterized in that In step (4), the system is responsible for managing the complete process of each request, including decision-making, scheduling, and triggering operations of the next stage function.

10. A Serverless efficient resource allocation system based on reinforcement learning, It is characterized in that The system includes the following modules: Gateway module: The gateway module adds a set of interfaces to the original system gateway to forward requests to the forwarding module. The system gateway uses Prometheus to continuously monitor the request arrival rate and regularly sends statistical data to the request volume prediction module for decision-making; Controller module: The controller module is the main module, which includes pipeline prediction, reinforcement learning decision maker, forwarding module and request volume prediction module. The pipeline prediction uses semaphores and coroutines in programming languages ​​to manage the execution of applications in a workflow manner; the reinforcement learning decision maker integrates the trained model into the system, and at the same time observes the application, request and cluster status through the container monitoring program, and passes the status to the reinforcement learning decision maker; the forwarding module maintains a hash queue in the memory, and the hash queue stores IP information corresponding to different configurations for fast search and sending requests; the request volume prediction module uses historical data transmitted by the gateway to regularly decide the number of containers in the next stage; Proxy module: The proxy module is implemented on the daemon set of the container management platform. The module performs resource adjustment operations after receiving a call by exposing a hypertext transfer protocol service port in the cluster. The state resources are adjusted using the control group method of the operating system. Compared with modifying the configuration related to the deployment module of the container management platform, the control group method does not require restarting the container. The state resources are processor quota and memory. Simulator module: The simulator module is a serverless simulator used to train reinforcement learning policy networks. It simulates the complete process of workflow requests through a continuous time and discrete event driven engine, and maintains a logical clock to speed up the training process. The model uses 32 neurons and 16 neurons to form a network structure, and is implemented using a machine learning platform.

Citation Information

Patent Citations

  • Multi-workflow resource supply method under virtualization container resources

    CN107070965A

  • Unmanned aerial vehicle server task unloading scheduling method based on resource exit scene

    CN112911618A

  • Cloud-edge collaborative double-benefit balance taboo reinforcement learning resource allocation method

    CN114116156A

  • Server-free computing resource allocation method based on maximum entropy inverse reinforcement learning

    CN114416343A

  • Scheduling method and device based on micro-service link analysis and reinforcement learning

    CN114780233A

Cited By

  • Facility agriculture monitoring system based on adaptive wireless communication

    CN119071755A

  • Cluster system intelligent operation and maintenance system based on reinforcement learning

    CN119090492A

  • Multivariate data real-time integration and visualization method and system

    CN119166876A

  • Private domain live broadcast content distribution and visitor interaction method and system based on edge computing

    CN119211585A

  • Chip platform hardware abstraction layer construction method

    CN119312219A